Exemplo n.º 1
0
    def test_read_write(self):
        sr = StatementsResult()
        self.assertEqual(len(sr.statements), 0,
                         'Empty StatementsResult inited as non-empty!')

        uuid_str = '016699c6-d600-48a7-96ab-86187498f16f'
        sr.statements = (
            Statement(id=uuid_str),
            Statement(id=uuid_str),
            Statement(id=uuid_str),
        )
        self.assertIsInstance(sr.statements, list,
                              'Did not convert tuple to list!')

        sr.statements.append(Statement(id=uuid_str))
        self.assertEqual(sr.statements[3].id,
                         uuid.UUID('016699c6-d600-48a7-96ab-86187498f16f'),
                         'Did not append value!')

        self.assertIsNone(sr.more)

        sr.more = 'http://www.example.com/more/1234'

        self.assertEqual(sr.more, 'http://www.example.com/more/1234',
                         'Did not set sr.more!')
    def test_serialize_deserialize(self):
        sr = StatementsResult()
        uuid_str = '016699c6-d600-48a7-96ab-86187498f16f'
        sr.statements = [Statement(id=uuid_str), Statement(id=uuid_str), Statement(id=uuid_str), ]
        sr.more = 'http://www.example.com/more/1234'

        self.assertSerializeDeserialize(sr)
Exemplo n.º 3
0
    def test_serialize_deserialize(self):
        sr = StatementsResult()
        uuid_str = '016699c6-d600-48a7-96ab-86187498f16f'
        sr.statements = [Statement(id=uuid_str), Statement(id=uuid_str), Statement(id=uuid_str), ]
        sr.more = 'http://www.example.com/more/1234'

        self.assertSerializeDeserialize(sr)
    def test_read_write(self):
        sr = StatementsResult()
        self.assertEqual(len(sr.statements), 0, 'Empty StatementsResult inited as non-empty!')

        uuid_str = '016699c6-d600-48a7-96ab-86187498f16f'
        sr.statements = (Statement(id=uuid_str), Statement(id=uuid_str), Statement(id=uuid_str),)
        self.assertIsInstance(sr.statements, list, 'Did not convert tuple to list!')

        sr.statements.append(Statement(id=uuid_str))
        self.assertEqual(sr.statements[3].id, uuid.UUID('016699c6-d600-48a7-96ab-86187498f16f'), 'Did not append value!')

        self.assertIsNone(sr.more)

        sr.more = 'http://www.example.com/more/1234'

        self.assertEqual(sr.more, 'http://www.example.com/more/1234', 'Did not set sr.more!')
Exemplo n.º 5
0
    def test_serialize_deserialize_init(self):
        uuid_str = '016699c6-d600-48a7-96ab-86187498f16f'
        data = {
            'statements': [Statement(id=uuid_str), Statement(id=uuid_str), Statement(id=uuid_str),
                           Statement(id=uuid_str), ],
            'more': 'http://www.example.com/more/1234',
        }

        sr = StatementsResult(data)
        self.assertSerializeDeserialize(sr)