]> git.ipfire.org Git - location/libloc.git/blob - tests/python/test-export.py
cef87b3a2773e8c956de4baeaa983c6aa0c1a9c0
[location/libloc.git] / tests / python / test-export.py
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
20 import location
21 import os
22 import unittest
23
24 TEST_DATA_DIR = os.environ["TEST_DATA_DIR"]
25
26 class Test(unittest.TestCase):
27 def setUp(self):
28 path = os.path.join(TEST_DATA_DIR, "location-2022-03-30.db")
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 network in self.db.networks_flattened:
45 print(network)
46
47
48 if __name__ == "__main__":
49 unittest.main()