Skip to content

Commit 918a0bf

Browse files
NolanNolan
authored andcommitted
Fixed StatementsResult tests
1 parent 69b9dfc commit 918a0bf

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

test/statements_result_test.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,28 @@
1515
# limitations under the License.
1616

1717
import unittest
18+
import uuid
1819

1920
if __name__ == '__main__':
2021
from main import setup_tincan_path
2122
setup_tincan_path()
2223
from tincan.statements_result import StatementsResult
24+
from tincan.statement import Statement
2325
from test_utils import TinCanBaseTestCase
2426

25-
2627
class StatementsResultTest(TinCanBaseTestCase):
2728
def test_serialize_deserialize(self):
2829
sr = StatementsResult()
29-
sr.statements = [1, 2, 3, ]
30+
uuid_str = '016699c6-d600-48a7-96ab-86187498f16f'
31+
sr.statements = [Statement(id=uuid_str), Statement(id=uuid_str), Statement(id=uuid_str), ]
3032
sr.more = 'http://www.example.com/more/1234'
3133

3234
self.assertSerializeDeserialize(sr)
3335

3436
def test_serialize_deserialize_init(self):
37+
uuid_str = '016699c6-d600-48a7-96ab-86187498f16f'
3538
data = {
36-
'statements': [1, 2, 3, 4, ],
39+
'statements': [Statement(id=uuid_str), Statement(id=uuid_str), Statement(id=uuid_str), Statement(id=uuid_str), ],
3740
'more': 'http://www.example.com/more/1234',
3841
}
3942

@@ -44,11 +47,12 @@ def test_read_write(self):
4447
sr = StatementsResult()
4548
self.assertEqual(len(sr.statements), 0, 'Empty StatementsResult inited as non-empty!')
4649

47-
sr.statements = (1, 2, 3,)
50+
uuid_str = '016699c6-d600-48a7-96ab-86187498f16f'
51+
sr.statements = (Statement(id=uuid_str), Statement(id=uuid_str), Statement(id=uuid_str),)
4852
self.assertIsInstance(sr.statements, list, 'Did not convert tuple to list!')
4953

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

5357
self.assertIsNone(sr.more)
5458

@@ -59,4 +63,4 @@ def test_read_write(self):
5963

6064
if __name__ == '__main__':
6165
suite = unittest.TestLoader().loadTestsFromTestCase(StatementsResultTest)
62-
unittest.TextTestRunner(verbosity=2).run(suite)
66+
unittest.TextTestRunner(verbosity=2).run(suite)

0 commit comments

Comments
 (0)