diff options
author | Olivier Gayot <olivier.gayot@sigexec.com> | 2020-05-12 21:20:29 +0200 |
---|---|---|
committer | Olivier Gayot <olivier.gayot@sigexec.com> | 2020-05-12 21:42:40 +0200 |
commit | b6ecd410ee6a826a5756258073398da95157d77e (patch) | |
tree | 768eef042d56e82f42a86be3bbb0e67f787fd45a /tests | |
parent | 310f104734c72cad3b73901d5bf0ee7cef067e3a (diff) |
Add unit tests for swiftstory.Status
Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_status.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/test_status.py b/tests/test_status.py new file mode 100644 index 0000000..5c48cd0 --- /dev/null +++ b/tests/test_status.py @@ -0,0 +1,21 @@ +import json +import unittest + +import swiftstory.Status as Status + + +class TestStatus(unittest.TestCase): + def test_error(self): + error_text = "Some error with utf-8 characters ùðú!" + error_code = 520 + output = json.loads(Status.error(error_text, error_code)) + self.assertEqual(output["type"], "response") + self.assertEqual(output["content"]["info"], error_text) + self.assertEqual(output["content"]["status"], error_code) + + def test_success(self): + text = "Some message with utf-8 characters ùðú!" + output = json.loads(Status.success(text)) + self.assertEqual(output["type"], "response") + self.assertEqual(output["content"]["status"], 0) + self.assertEqual(output["content"]["result"], text) |