Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
HEV - High Energy Ventilator
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
5
Issues
5
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
HEV - High Energy Ventilator
Commits
0726439a
Commit
0726439a
authored
Apr 22, 2021
by
Tim Powell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added default handler unittest
parent
ed433a3b
Pipeline
#1375
failed with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
test_handlers.py
NativeUI/tests/unittests/test_handlers.py
+30
-0
No files found.
NativeUI/tests/unittests/test_handlers.py
View file @
0726439a
...
...
@@ -6,8 +6,38 @@ import json
import
os
from
unittest.mock
import
MagicMock
,
patch
from
handler_library.handler
import
Handler
from
handler_library.battery_handler
import
BatteryHandler
def
test_handler
():
"""
Tests the default handler.
Test for set_db and get_db to set the database from a given payload and compare the db imported from get_db.
Test for if active_payload gets fired when set_db is called.
"""
# Initalise the handler and import sample battery json file
handler
=
Handler
()
batt_json_file_path
=
os
.
environ
[
'PYTHONPATH'
]
.
split
(
os
.
pathsep
)[
0
]
+
'/tests/unittests/fixtures/batterySample.json'
batt_json
=
json
.
load
(
open
(
batt_json_file_path
))
# Set the database for the imported json and get the database imported
handler
.
set_db
(
batt_json
)
db
=
handler
.
get_db
()
# Check if the input payload and output database are the same
if
batt_json
==
db
:
payload_database_comparison
=
True
else
:
payload_database_comparison
=
False
# Mock active_payload to return true if it is called.
handler
.
active_payload
=
MagicMock
(
return_value
=
True
)
# Check whether conditions have been met to pass test
assert
handler
.
active_payload
()
is
True
,
'active_payload was not called when set_db was run.'
assert
payload_database_comparison
is
True
,
'set_db does not set the inputted payload to the database.'
def
test_battery_handler
():
"""
...
...
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