Пример #1
0
    def _create_ident(value: str) -> 'Value':
        if value == 'true':
            return Bool.create_from(True)
        elif value == 'false':
            return Bool.create_from(False)

        return Text.create_from(value)
Пример #2
0
 def test_write_value_bool(self):
     # Given
     boolean = Bool.create_from(False)
     writer = _ReconWriter()
     # When
     actual = writer._write_value(boolean)
     # Then
     self.assertIsInstance(actual, _OutputMessage)
     self.assertEqual(5, actual._size)
     self.assertEqual('false', actual._value)
     self.assertEqual('e', actual._last_char)
    def test_write_sync_body_bool(self):
        # Given
        envelope = _SyncRequest('bar/baz/',
                                'foo/bar',
                                body=Bool.create_from(False))
        expected = '@sync(node:"bar/baz/",lane:"foo/bar")false'

        # When
        actual = envelope._to_recon()

        # Then
        self.assertEqual(expected, actual)
    def test_write_event_body_bool(self):
        # Given
        envelope = _EventMessage('/this/is/spam',
                                 'hello',
                                 body=Bool.create_from(False))
        expected = '@event(node:"/this/is/spam",lane:hello)false'

        # When
        actual = envelope._to_recon()

        # Then
        self.assertEqual(expected, actual)
    def test_write_command_body_bool(self):
        # Given
        envelope = _CommandMessage('dead/parrot',
                                   'spam/ham',
                                   body=Bool.create_from(True))
        expected = '@command(node:"dead/parrot",lane:"spam/ham")true'

        # 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_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_synced_body_bool(self):
        # Given
        envelope = _SyncedResponse('foo/bar/baz',
                                   'baz/bar/foo',
                                   body=Bool.create_from(True))
        expected = '@synced(node:"foo/bar/baz",lane:"baz/bar/foo")true'

        # When
        actual = envelope._to_recon()

        # Then
        self.assertEqual(expected, actual)