File: test_parse_misc.py

package info (click to toggle)
python-aprslib 0.7.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 352 kB
  • sloc: python: 2,973; makefile: 216
file content (38 lines) | stat: -rw-r--r-- 1,171 bytes parent folder | download
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
import unittest

from aprslib.parsing.misc import parse_status, parse_invalid, parse_user_defined


class MiscTC(unittest.TestCase):
    def test_status(self):
        body = "test status text  "
        _, result = parse_status('>', body)

        self.assertEqual(result['format'], 'status')
        self.assertEqual(result['status'], 'test status text')

        # with timestamp
        body = "111111ztest status text  "
        _, result = parse_status('>', body)

        self.assertEqual(result['format'], 'status')
        self.assertEqual(result['status'], 'test status text')
        self.assertTrue('timestamp' in result)

    def test_invalid(self):
        body = "invalid packet text"
        _, result = parse_invalid(body)

        self.assertEqual(result['format'], 'invalid')
        self.assertEqual(result['body'], body)

    def test_user_defined(self):
        body = "{zinvalid packet text"
        _, result = parse_user_defined(body)

        self.assertEqual(result['format'], 'user-defined')
        self.assertEqual(result['body'], body[2:])
        self.assertEqual(result['id'], body[0])
        self.assertEqual(result['type'], body[1])