blob: 51dc83785163a436ed0d095217130ffb68e93e89 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
import unittest
import swiftstory.SwiftStory as SwiftStory
from swiftstory.Status import error
class TestSwiftStory(unittest.TestCase):
def test_receive_invalid_json(self):
self.assertEqual(
error("badly formatted json"),
SwiftStory.message_received_handler(client=None, message="{invalid_json}")
)
def test_receive_json_array(self):
self.assertEqual(
error("invalid command"),
SwiftStory.message_received_handler(client=None, message='[]')
)
def test_receive_json_number(self):
self.assertEqual(
error("invalid command"),
SwiftStory.message_received_handler(client=None, message='2.3')
)
def test_receive_json_null(self):
self.assertEqual(
error("invalid command"),
SwiftStory.message_received_handler(client=None, message='null')
)
def test_receive_unknown_command(self):
self.assertEqual(
error("invalid command"),
SwiftStory.message_received_handler(client=None, message='{"op": "unknown"}')
)
def test_receive_without_command(self):
self.assertEqual(
error("invalid command"),
SwiftStory.message_received_handler(client=None, message='{}')
)
|