Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mongiris
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Duchateau Fabien
mongiris
Commits
2a63a2c7
Commit
2a63a2c7
authored
4 years ago
by
Duchateau Fabien
Browse files
Options
Downloads
Patches
Plain Diff
[M] added a test for switching database
parent
4760aa53
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mongiris/tests/api_tests.py
+11
-4
11 additions, 4 deletions
mongiris/tests/api_tests.py
with
11 additions
and
4 deletions
mongiris/tests/api_tests.py
+
11
−
4
View file @
2a63a2c7
...
@@ -23,7 +23,7 @@ class TestCase(unittest.TestCase):
...
@@ -23,7 +23,7 @@ class TestCase(unittest.TestCase):
def
test_count
(
self
):
def
test_count
(
self
):
# test for counting the number of documents
# test for counting the number of documents
count
=
self
.
db
.
count_documents
(
self
.
db
.
collection_neighbourhoods
,
{})
count
=
self
.
db
.
count_documents
(
self
.
db
.
collection_neighbourhoods
,
{})
assert
(
count
==
49404
),
f
'
Error: expecting 49404 neighbourhood
to be
stored in
MongoDB
, but
store
d
{
count
}
'
assert
(
count
==
49404
),
f
'
Error: expecting 49404 neighbourhood
s
stored in
database dbinsee
, but
foun
d
{
count
}
'
def
test_find_one
(
self
):
def
test_find_one
(
self
):
# test for finding a specific document using a field CODE_IRIS
# test for finding a specific document using a field CODE_IRIS
...
@@ -112,13 +112,20 @@ class TestCase(unittest.TestCase):
...
@@ -112,13 +112,20 @@ class TestCase(unittest.TestCase):
doc
=
self
.
db
.
point_in_which_neighbourhood
([
-
49.016200
,
79.333879
])
doc
=
self
.
db
.
point_in_which_neighbourhood
([
-
49.016200
,
79.333879
])
assert
(
doc
is
None
),
'
Coordinates (79.333879, -49.016200) should return no document (no corresponding neighbourhood)
'
assert
(
doc
is
None
),
'
Coordinates (79.333879, -49.016200) should return no document (no corresponding neighbourhood)
'
def
test_switch_db
(
self
):
self
.
db
=
Mongiris
(
'
dbmigration
'
,
'
collmigration
'
)
self
.
db
.
logger
.
info
(
"
Connection to another database (dbmigration).
"
)
count
=
self
.
db
.
count_documents
(
self
.
db
.
collection_neighbourhoods
,
{})
assert
(
count
==
769
),
f
'
Error: expecting 769 neighbourhoods stored in datase dbmigration, but found
{
count
}
'
def
test_test
(
self
):
def
test_test
(
self
):
# for testing code
# for testing code
coord
=
[
4.8300768
,
45.720019
]
coord
=
[
4.8300768
,
45.720019
]
cursor
=
self
.
db
.
near
(
self
.
db
.
collection_neighbourhoods
,
coord
,
{
"
properties.NOM_IRIS
"
:
1
,
"
properties.CODE_IRIS
"
:
1
},
cursor
=
self
.
db
.
near
(
self
.
db
.
collection_neighbourhoods
,
coord
,
{
"
properties.NOM_IRIS
"
:
1
,
1000
)
"
properties.CODE_IRIS
"
:
1
},
1000
)
for
doc
in
cursor
:
for
doc
in
cursor
:
self
.
db
.
logger
.
info
(
str
(
doc
[
"
_id
"
])
+
"
\t
"
+
doc
[
"
properties
"
][
"
NOM_IRIS
"
]
+
"
\t
"
+
doc
[
"
properties
"
][
"
CODE_IRIS
"
])
self
.
db
.
logger
.
info
(
str
(
doc
[
"
_id
"
])
+
"
\t
"
+
doc
[
"
properties
"
][
"
NOM_IRIS
"
]
+
"
\t
"
+
doc
[
"
properties
"
][
"
CODE_IRIS
"
])
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment