]> git.ipfire.org Git - location/debian/libloc.git/blame - tests/python/test-export.py
Update upstream source from tag 'upstream/0.9.16'
[location/debian/libloc.git] / tests / python / test-export.py
CommitLineData
1f2c3ccb
JS
1#!/usr/bin/python3
2###############################################################################
3# #
4# libloc - A library to determine the location of someone on the Internet #
5# #
6# Copyright (C) 2022 IPFire Development Team <info@ipfire.org> #
7# #
8# This library is free software; you can redistribute it and/or #
9# modify it under the terms of the GNU Lesser General Public #
10# License as published by the Free Software Foundation; either #
11# version 2.1 of the License, or (at your option) any later version. #
12# #
13# This library is distributed in the hope that it will be useful, #
14# but WITHOUT ANY WARRANTY; without even the implied warranty of #
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
16# Lesser General Public License for more details. #
17# #
18###############################################################################
19
20import location
21import os
22import unittest
23
24TEST_DATA_DIR = os.environ["TEST_DATA_DIR"]
25
26class Test(unittest.TestCase):
27 def setUp(self):
b1863b64 28 path = os.path.join(TEST_DATA_DIR, "database.db")
1f2c3ccb
JS
29
30 # Load the database
31 self.db = location.Database(path)
32
33 def test_list_networks(self):
34 """
35 Lists all available networks
36 """
37 for network in self.db.networks:
38 print(network)
39
40 def test_list_networks_flattened(self):
41 """
42 Lists all networks but flattened
43 """
44 for i, network in enumerate(self.db.networks_flattened):
45 # Break after the first 1000 iterations
46 if i >= 1000:
47 break
48
49 print(network)
50
51
52if __name__ == "__main__":
53 unittest.main()