-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MRG: Merge pull request #92 from octue/feature/validate-monitors
Add ability to validate monitors
- Loading branch information
Showing
6 changed files
with
60 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from twined import Twine, exceptions | ||
from .base import BaseTestCase | ||
|
||
|
||
class TestMonitorMessageTwine(BaseTestCase): | ||
STRAND_WITH_MONITOR_MESSAGE_SCHEMA = """ | ||
{ | ||
"monitor_message_schema": { | ||
"type": "object", | ||
"properties": { | ||
"my_property": { | ||
"type": "number" | ||
} | ||
}, | ||
"required": ["my_property"] | ||
} | ||
} | ||
""" | ||
|
||
def test_validate_monitor_message_raises_error_if_monitor_message_schema_not_met(self): | ||
"""Test that an error is raised if an invalid monitor update is validated.""" | ||
twine = Twine(source=self.STRAND_WITH_MONITOR_MESSAGE_SCHEMA) | ||
|
||
with self.assertRaises(exceptions.InvalidValuesContents): | ||
twine.validate_monitor_message([]) | ||
|
||
def test_validate_monitor_message_with_valid_monitor_update(self): | ||
"""Test that a valid monitor update validates successfully.""" | ||
twine = Twine(source=self.STRAND_WITH_MONITOR_MESSAGE_SCHEMA) | ||
twine.validate_monitor_message({"my_property": 3.7}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters