-
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.
- Loading branch information
1 parent
b701b2f
commit 72332e9
Showing
2 changed files
with
68 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import sys | ||
import os | ||
import inspect | ||
from rkd.api.testing import BasicTestingCase | ||
|
||
path = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) + '/../' | ||
sys.path.insert(0, path) | ||
|
||
from infracheck.infracheck.model import ExecutedChecksResultList, ExecutedCheckResult | ||
|
||
|
||
class ExecutedChecksResultListTest(BasicTestingCase): | ||
def test_is_global_status_success(self): | ||
""" | ||
Checks if global status of the endpoint works as expected in basing on checks results | ||
""" | ||
|
||
with self.subTest('One check is failing, then global status is failure'): | ||
results = ExecutedChecksResultList() | ||
results.add('first', ExecutedCheckResult( | ||
configured_name='first', | ||
output='Test', | ||
exit_status=False, | ||
hooks_output='' | ||
)) | ||
results.add('second', ExecutedCheckResult( | ||
configured_name='second', | ||
output='Test', | ||
exit_status=True, | ||
hooks_output='' | ||
)) | ||
|
||
self.assertFalse(results.is_global_status_success()) | ||
|
||
with self.subTest('All checks are passing, then we have a success'): | ||
results = ExecutedChecksResultList() | ||
results.add('first', ExecutedCheckResult( | ||
configured_name='first', | ||
output='Test', | ||
exit_status=True, | ||
hooks_output='' | ||
)) | ||
results.add('second', ExecutedCheckResult( | ||
configured_name='second', | ||
output='Test', | ||
exit_status=True, | ||
hooks_output='' | ||
)) | ||
|
||
self.assertTrue(results.is_global_status_success()) | ||
|
||
with self.subTest('All checks are failing, then we have a failure'): | ||
results = ExecutedChecksResultList() | ||
results.add('first', ExecutedCheckResult( | ||
configured_name='first', | ||
output='Test', | ||
exit_status=False, | ||
hooks_output='' | ||
)) | ||
results.add('second', ExecutedCheckResult( | ||
configured_name='second', | ||
output='Test', | ||
exit_status=False, | ||
hooks_output='' | ||
)) | ||
|
||
self.assertFalse(results.is_global_status_success()) |