Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
common_helper_mongo
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fact-gitdep
common_helper_mongo
Commits
f19f4642
Commit
f19f4642
authored
May 02, 2019
by
Jörg Stucke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added tests to improve coverage
parent
41435cf9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
test_aggregate.py
tests/test_aggregate.py
+12
-2
No files found.
tests/test_aggregate.py
View file @
f19f4642
from
common_helper_mongo.aggregate
import
(
get_all_value_combinations_of_fields
,
get_field_average
,
get_field_sum
,
get_list_of_all_values
,
get_objects_and_count_of_occurrence
,
get_
list_of_all_values_and_collect_information_of_additional_field
,
get_
objects_and_count_of_occurrence
,
)
from
tests.base_class_database_test
import
MongoDbTest
...
...
@@ -37,7 +37,7 @@ class TestAggregate(MongoDbTest):
def
test_get_all_value_combinations_of_fields_id
(
self
):
self
.
add_list_test_data
()
result
=
get_all_value_combinations_of_fields
(
self
.
test_collection
,
"$test_list"
,
"$_id"
,
unwind
=
True
,
match
=
None
)
result
=
get_all_value_combinations_of_fields
(
self
.
test_collection
,
"$test_list"
,
"$_id"
,
unwind
=
True
)
self
.
assertIsInstance
(
result
,
dict
,
"result should be a dict"
)
self
.
assertEqual
(
len
(
result
.
keys
()),
4
,
"number of results not correct"
)
self
.
assertEqual
(
len
(
result
[
'c'
]),
2
,
"c should have two related object ids"
)
...
...
@@ -77,3 +77,13 @@ class TestAggregate(MongoDbTest):
self
.
add_simple_test_data
()
result
=
get_field_sum
(
self
.
test_collection
,
"$test_int"
,
match
=
{
"test_int"
:
{
"$lt"
:
5
}})
self
.
assertEqual
(
result
,
10
)
def
test_get_field_execute_operation_empty
(
self
):
result
=
get_field_sum
(
self
.
test_collection
,
"$test_int"
)
self
.
assertEqual
(
result
,
0
)
def
test_get_list_of_all_values_and_collect_information_of_additional_field
(
self
):
self
.
add_list_test_data
()
with
self
.
assertLogs
()
as
logger
:
get_list_of_all_values_and_collect_information_of_additional_field
(
self
.
test_collection
,
"$test_list"
,
"$_id"
,
unwind
=
True
)
assert
'deprecation warning'
in
logger
.
output
.
pop
()
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