def test_write_link_escaped(self):
        # Given
        envelope = _LinkRequest('/unit/5', '/unit/3')
        expected = '@link(node:"/unit/5",lane:"/unit/3")'

        # When
        actual = envelope._to_recon()

        # Then
        self.assertEqual(expected, actual)
    def test_write_link(self):
        # Given
        envelope = _LinkRequest('test', 'foo')
        expected = '@link(node:test,lane:foo)'

        # When
        actual = envelope._to_recon()

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

        # When
        actual = envelope._to_recon()

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

        # When
        actual = envelope._to_recon()

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

        # When
        actual = envelope._to_recon()

        # Then
        self.assertEqual(expected, actual)
Exemple #6
0
 def test_link_request_empty_body(self):
     # Given
     node_uri = 'foo_link_node'
     lane_uri = 'bar_link_lane'
     # When
     actual = _LinkRequest(node_uri, lane_uri)
     # Then
     self.assertEqual('foo_link_node', actual._node_uri)
     self.assertEqual('bar_link_lane', actual._lane_uri)
     self.assertEqual('link', actual._tag)
     self.assertEqual('foo_link_node/bar_link_lane', actual._route)
     self.assertEqual(_Absent._get_absent(), actual._body)
     self.assertIsInstance(actual._form, _LinkRequestForm)
    def test_write_link_prio_rate(self):
        # Given
        envelope = _LinkRequest('/unit/5',
                                '/unit/3',
                                prio=22.11,
                                rate=0.2,
                                body=Text.create_from('spam and \\ham/'))
        expected = '@link(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)
Exemple #8
0
 def test_link_request_existing_body(self):
     # Given
     node_uri = 'foo_link_node'
     lane_uri = 'bar_link_lane'
     body = Text.create_from('Link_Body')
     priority = 13.1
     rate = 11.3
     # When
     actual = _LinkRequest(node_uri, lane_uri, priority, rate, body)
     # Then
     self.assertEqual('foo_link_node', actual._node_uri)
     self.assertEqual('bar_link_lane', actual._lane_uri)
     self.assertEqual('link', actual._tag)
     self.assertEqual('foo_link_node/bar_link_lane', actual._route)
     self.assertEqual(body, actual._body)
     self.assertIsInstance(actual._form, _LinkRequestForm)
 def test_link_form_mold(self):
     # Given
     form = _LinkRequestForm()
     envelope = _LinkRequest('link_node',
                             'link_lane',
                             prio=1,
                             rate=2,
                             body=Text.create_from('Moo'))
     # When
     actual = form._mold(envelope)
     # Then
     self.assertIsInstance(actual, RecordMap)
     self.assertEqual(2, actual.size)
     self.assertEqual('link', actual._tag)
     self.assertEqual('link_node',
                      actual.get_item(0).value.get_item(0).value.value)
     self.assertEqual('link_lane',
                      actual.get_item(0).value.get_item(1).value.value)
     self.assertEqual(1, actual.get_item(0).value.get_item(2).value.value)
     self.assertEqual(2, actual.get_item(0).value.get_item(3).value.value)
     self.assertEqual('Moo', actual.get_item(1).value)
Exemple #10
0
 async def _establish_downlink(self) -> None:
     link_request = _LinkRequest(self.node_uri, self.lane_uri)
     await self.connection._send_message(link_request._to_recon())