1 | import unittest
|
---|
2 |
|
---|
3 | from pyson.ObjectMapper import ObjectMapper
|
---|
4 |
|
---|
5 | from geniusweb.actions.EndNegotiation import EndNegotiation
|
---|
6 | from geniusweb.actions.PartyId import PartyId
|
---|
7 | from geniusweb.inform.ActionDone import ActionDone
|
---|
8 | from geniusweb.inform.Inform import Inform
|
---|
9 | from geniusweb.inform.YourTurn import YourTurn
|
---|
10 | from geniusweb.inform.Voting import Voting
|
---|
11 | from unitpy.GeneralTests import GeneralTests
|
---|
12 | from geniusweb.profileconnection import ProfileConnectionFactory
|
---|
13 | from typing import List
|
---|
14 | import json
|
---|
15 |
|
---|
16 |
|
---|
17 | class ActionDoneTest(unittest.TestCase, GeneralTests[ActionDone]):
|
---|
18 |
|
---|
19 | pyson = ObjectMapper()
|
---|
20 | id1 = PartyId("party1")
|
---|
21 | id2 = PartyId("party2")
|
---|
22 |
|
---|
23 | act1 = EndNegotiation(id1)
|
---|
24 | act2 = EndNegotiation(id2)
|
---|
25 |
|
---|
26 | done1 = ActionDone(act1)
|
---|
27 | done1a = ActionDone(act1)
|
---|
28 | done2 = ActionDone(act2)
|
---|
29 |
|
---|
30 | actiondonejson = {"ActionDone":{"action":{"EndNegotiation":{"actor":"party1"}}}}
|
---|
31 |
|
---|
32 | def getGeneralTestData(self) -> List[List[ActionDone]]:
|
---|
33 | return [[self.done1, self.done1a], [self.done2]]
|
---|
34 |
|
---|
35 | def getGeneralTestStrings(self) -> List[str]:
|
---|
36 | return ["ActionDone.*EndNegotiation.*party1.*",
|
---|
37 | "ActionDone.*EndNegotiation.*party2.*"]
|
---|
38 |
|
---|
39 | def testSerializeAccept(self):
|
---|
40 | json1 = self.pyson.toJson(self.done1)
|
---|
41 | print(json1)
|
---|
42 | self.assertEqual(self.actiondonejson, json1)
|
---|
43 |
|
---|
44 | def testDeserialize(self):
|
---|
45 | self.assertEqual(self.done1, self.pyson.parse(self.actiondonejson, Inform))
|
---|
46 |
|
---|
47 | def testGet(self):
|
---|
48 | self.assertEqual(self.act1, self.done1.getAction())
|
---|
49 |
|
---|
50 |
|
---|
51 | |
---|