Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libloc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
libloc
Commits
c8603967
Commit
c8603967
authored
Aug 22, 2022
by
Michael Tremer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: Add some simple database tests
Signed-off-by:
Michael Tremer
<
michael.tremer@ipfire.org
>
parent
18638ad2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
0 deletions
+44
-0
Makefile.am
Makefile.am
+1
-0
tests/python/test-database.py
tests/python/test-database.py
+43
-0
No files found.
Makefile.am
View file @
c8603967
...
...
@@ -344,6 +344,7 @@ testdata.db: examples/python/create-database.py
$(PYTHON)
$<
$@
dist_check_SCRIPTS
=
\
tests/python/test-database.py
\
tests/python/test-export.py
check_PROGRAMS
=
\
...
...
tests/python/test-database.py
0 → 100755
View file @
c8603967
#!/usr/bin/python3
###############################################################################
# #
# libloc - A library to determine the location of someone on the Internet #
# #
# Copyright (C) 2022 IPFire Development Team <info@ipfire.org> #
# #
# This library is free software; you can redistribute it and/or #
# modify it under the terms of the GNU Lesser General Public #
# License as published by the Free Software Foundation; either #
# version 2.1 of the License, or (at your option) any later version. #
# #
# This library is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
# Lesser General Public License for more details. #
# #
###############################################################################
import
location
import
os
import
unittest
TEST_DATA_DIR
=
os
.
environ
[
"TEST_DATA_DIR"
]
class
Test
(
unittest
.
TestCase
):
def
setUp
(
self
):
path
=
os
.
path
.
join
(
TEST_DATA_DIR
,
"location-2022-03-30.db"
)
# Load the database
self
.
db
=
location
.
Database
(
path
)
def
test_fetch_network
(
self
):
n
=
self
.
db
.
lookup
(
"81.3.27.38"
)
self
.
assertIsInstance
(
n
,
location
.
Network
)
def
test_fetch_network_invalid
(
self
):
with
self
.
assertRaises
(
ValueError
):
self
.
db
.
lookup
(
"XXX"
)
if
__name__
==
"__main__"
:
unittest
.
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment