コード例 #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!')
コード例 #2
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)
コード例 #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)
コード例 #4
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!')
コード例 #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)