| Total Complexity | 2 |
| Total Lines | 35 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | # Copyright Pincer 2021-Present |
||
| 2 | # Full MIT License can be found in `LICENSE` at the project root. |
||
| 3 | |||
| 4 | from pincer.core.dispatch import GatewayDispatch |
||
| 5 | |||
| 6 | |||
| 7 | class TestDispatch: |
||
| 8 | op = 123 |
||
| 9 | data = {"foo": "bar", "bar": "foo"} |
||
| 10 | seq = 456 |
||
| 11 | event_name = "test_event" |
||
| 12 | |||
| 13 | dispatch_string = ( |
||
| 14 | '{"op": 123, "d": {"foo": "bar", "bar": "foo"}, ' |
||
| 15 | '"s": 456, "t": "test_event"}' |
||
| 16 | ) |
||
| 17 | |||
| 18 | dispatch = GatewayDispatch(op, data, seq, event_name) |
||
| 19 | |||
| 20 | def test_string_fmt(self): |
||
| 21 | """ |
||
| 22 | Tests whether or not the dispatch class its string conversion |
||
| 23 | is correct. |
||
| 24 | """ |
||
| 25 | assert str(self.dispatch) == self.dispatch_string |
||
| 26 | |||
| 27 | def test_from_string(self): |
||
| 28 | """ |
||
| 29 | Tests whether or not the from_string function is properly |
||
| 30 | parsing the string and creating a GatewayDispatch instance. |
||
| 31 | """ |
||
| 32 | assert ( |
||
| 33 | str(GatewayDispatch.from_string(self.dispatch_string)) |
||
| 34 | == self.dispatch_string |
||
| 35 | ) |
||
| 36 |