예제 #1
0
 def assertParse(self, s, cmd, body, headers):
     p = tinystomp.Parser()
     p.receive(s)
     f = p.next()
     assert f.command == cmd
     assert f.body == body
     assert sorted(f.headers.items()) == sorted(headers.items())
예제 #2
0
 def test_one_nobody(self):
     p = tinystomp.Parser()
     p.receive(tinystomp.connect('host'))
     assert p.can_read()
     f = p.next()
     assert f.command == 'CONNECT'
     assert f.body == ''
     assert f.headers == {'accept-version': '1.0,1.1,1.2', 'host': 'host'}
예제 #3
0
    def test_dup_headers_preserve_first(self):
        # STOMP 1.2 "Repeated Header Entries" requires only the first header is
        # preserved.
        p = tinystomp.Parser()
        p.receive('SEND\r\n' 'key:value1\r\n' 'key:value2\r\n' '\r\n' '\x00')

        f = p.next()
        assert f.headers['key'] == 'value1'
예제 #4
0
 def test_one_body(self):
     p = tinystomp.Parser()
     p.receive(tinystomp.send('/foo/bar', 'dave', a='b'))
     assert p.can_read()
     f = p.next()
     assert f.command == 'SEND'
     assert f.body == 'dave'
     assert f.headers == {
         'a': 'b',
         'content-length': '4',
         'destination': '/foo/bar',
     }
예제 #5
0
 def test_one_ignore_eol(self):
     p = tinystomp.Parser()
     eols = '\n\r\n\n'
     p.receive(eols + tinystomp.send('/foo/bar', 'dave', a='b') + eols)
     assert p.can_read()
     f = p.next()
     assert f.command == 'SEND'
     assert f.body == 'dave'
     assert f.headers == {
         'a': 'b',
         'content-length': '4',
         'destination': '/foo/bar',
     }
     assert not p.can_read()
예제 #6
0
    def test_one_partial_inheader(self):
        p = tinystomp.Parser()
        eols = '\n\r\n\n'
        s = eols + tinystomp.send('/foo/bar', 'dave', a='b') + eols
        p.receive(s[:12])
        assert not p.can_read()
        p.receive(s[12:])
        assert p.can_read()

        f = p.next()
        assert f.command == 'SEND'
        assert f.body == 'dave'
        assert f.headers == {
            'a': 'b',
            'content-length': '4',
            'destination': '/foo/bar',
        }
예제 #7
0
 def test_empty_str(self):
     p = tinystomp.Parser()
     p.receive('')
     assert not p.can_read()
예제 #8
0
 def test_constructor(self):
     p = tinystomp.Parser()
     assert p.s == ''
     assert p.frames == collections.deque()
     assert p.frame_eof is None