Esempio n. 1
0
    def test_serialization(self):
        self.assertEqual(self.container.serialize(), ActionsContainer.deserialize(data=self.container.serialize()).serialize())

        container = ActionsContainer.deserialize(data=self.container.serialize())
        container.initialize(self.hero)
        for action in container.actions_list:
            self.assertEqual(id(action.hero), id(self.hero))
Esempio n. 2
0
    def test_serialization(self):
        self.assertEqual(
            self.container.serialize(),
            ActionsContainer.deserialize(
                self.hero, data=self.container.serialize()).serialize())

        container = ActionsContainer.deserialize(
            self.hero, data=self.container.serialize())
        for action in container.actions_list:
            self.assertEqual(id(action.hero), id(self.hero))
Esempio n. 3
0
    def test_is_single__deserialize(self):
        while self.container.number > 1:
            self.container.pop_action()

        self.assertTrue(self.container.is_single)

        with mock.patch('the_tale.game.actions.prototypes.ActionIdlenessPrototype.SINGLE', False):
            with mock.patch('the_tale.game.actions.prototypes.ACTION_TYPES', dict(ACTION_TYPES, **{TestAction.TYPE: TestAction})):
                self.assertFalse(ActionsContainer.deserialize(self.hero, self.container.serialize()).is_single)
Esempio n. 4
0
    def test_is_single__deserialize(self):
        while self.container.number > 1:
            self.container.pop_action()

        self.assertTrue(self.container.is_single)

        with mock.patch(
                'the_tale.game.actions.prototypes.ActionIdlenessPrototype.SINGLE',
                False):
            with mock.patch(
                    'the_tale.game.actions.prototypes.ACTION_TYPES',
                    dict(ACTION_TYPES, **{TestAction.TYPE: TestAction})):
                self.assertFalse(
                    ActionsContainer.deserialize(
                        self.hero, self.container.serialize()).is_single)
Esempio n. 5
0
 def test_create(self):
     container = ActionsContainer()
     self.assertEqual(container.actions_list, [])
     self.assertFalse(container.is_single)
Esempio n. 6
0
 def actions(self):
     actions_container = ActionsContainer.deserialize(
         self, s11n.from_json(self._model.actions))
     actions_container.initialize(hero=self)
     return actions_container
Esempio n. 7
0
 def actions(self):
     actions_container = ActionsContainer.deserialize(self, s11n.from_json(self._model.actions))
     actions_container.initialize(hero=self)
     return actions_container