def test_write_unlinked_escaped(self):
        # Given
        envelope = _UnlinkedResponse('/unit/5', '/unit/3')
        expected = '@unlinked(node:"/unit/5",lane:"/unit/3")'

        # When
        actual = envelope._to_recon()

        # Then
        self.assertEqual(expected, actual)
    def test_write_unlinked(self):
        # Given
        envelope = _UnlinkedResponse('test', 'foo')
        expected = '@unlinked(node:test,lane:foo)'

        # When
        actual = envelope._to_recon()

        # Then
        self.assertEqual(expected, actual)
    def test_write_unlinked_body_string(self):
        # Given
        envelope = _UnlinkedResponse('/unit/5',
                                     '/unit/3',
                                     body=Text.create_from('spam and \\ham/'))
        expected = '@unlinked(node:"/unit/5",lane:"/unit/3")"spam and \\ham/"'

        # When
        actual = envelope._to_recon()

        # Then
        self.assertEqual(expected, actual)
    def test_write_unlinked_body_bool(self):
        # Given
        envelope = _UnlinkedResponse('/unit/5',
                                     '/unit/3',
                                     body=Bool.create_from(False))
        expected = '@unlinked(node:"/unit/5",lane:"/unit/3")false'

        # When
        actual = envelope._to_recon()

        # Then
        self.assertEqual(expected, actual)
    def test_write_unlinked_body_float(self):
        # Given
        envelope = _UnlinkedResponse('/unit/5',
                                     '/unit/3',
                                     body=Num.create_from(-100.0))
        expected = '@unlinked(node:"/unit/5",lane:"/unit/3")-100.0'

        # When
        actual = envelope._to_recon()

        # Then
        self.assertEqual(expected, actual)
Exemplo n.º 6
0
 def test_unlinked_response_empty_body(self):
     # Given
     node_uri = 'foo_unlinked_node'
     lane_uri = 'bar_unlinked_lane'
     # When
     actual = _UnlinkedResponse(node_uri, lane_uri)
     # Then
     self.assertEqual('foo_unlinked_node', actual._node_uri)
     self.assertEqual('bar_unlinked_lane', actual._lane_uri)
     self.assertEqual('unlinked', actual._tag)
     self.assertEqual('foo_unlinked_node/bar_unlinked_lane', actual._route)
     self.assertEqual(_Absent._get_absent(), actual._body)
     self.assertIsInstance(actual._form, _UnlinkedResponseForm)
    def test_write_unlinked_prio_rate(self):
        # Given
        envelope = _UnlinkedResponse('/unit/5',
                                     '/unit/3',
                                     prio=22.11,
                                     rate=0.2,
                                     body=Text.create_from('spam and \\ham/'))
        expected = '@unlinked(node:"/unit/5",lane:"/unit/3",prio:22.11,rate:0.2)"spam and \\ham/"'

        # When
        actual = envelope._to_recon()

        # Then
        self.assertEqual(expected, actual)
Exemplo n.º 8
0
 def test_unlinked_response_existing_body(self):
     # Given
     node_uri = 'foo_unlinked_node'
     lane_uri = 'bar_unlinked_lane'
     body = Text.create_from('Unlinked_Body')
     priority = 5.11
     rate = 6.13
     # When
     actual = _UnlinkedResponse(node_uri, lane_uri, priority, rate, body)
     # Then
     self.assertEqual('foo_unlinked_node', actual._node_uri)
     self.assertEqual('bar_unlinked_lane', actual._lane_uri)
     self.assertEqual('unlinked', actual._tag)
     self.assertEqual('foo_unlinked_node/bar_unlinked_lane', actual._route)
     self.assertEqual(body, actual._body)
     self.assertIsInstance(actual._form, _UnlinkedResponseForm)