Пример #1
0
class TestEvent(unittest.TestCase):
    def setUp(self):
        self.evt = Event(foo='bar')

    def test_event_creation(self):
        self.assertEqual(self.evt.foo, 'bar')

    def test_non_existing_event(self):
        self.assertRaises(AttributeError, getattr, self.evt, 'non_existing')

    def test_event_pickle_serialization(self):
        ser_evt = self.evt.serialize()
        deser_evt = Event.deserialize(ser_evt)
        self.assertEqual(deser_evt.foo, 'bar')
        self.assertRaises(AttributeError, getattr, deser_evt, 'non_existing')

    def test_event_json_serialization(self):
        ser_evt = self.evt.to_json()
        deser_evt = Event.from_json(ser_evt)
        self.assertEqual(deser_evt.foo, 'bar')
        self.assertRaises(AttributeError, getattr, deser_evt, 'non_existing')
Пример #2
0
class TestEvent(unittest.TestCase):
    def setUp(self):
        self.evt = Event(foo='bar')

    def test_event_creation(self):
        self.assertEqual(self.evt.foo, 'bar')

    def test_non_existing_event(self):
        self.assertRaises(AttributeError, getattr, self.evt, 'non_existing')

    def test_event_pickle_serialization(self):
        ser_evt = self.evt.serialize()
        deser_evt = Event.deserialize(ser_evt)
        self.assertEqual(deser_evt.foo, 'bar')
        self.assertRaises(AttributeError, getattr, deser_evt, 'non_existing')

    def test_event_json_serialization(self):
        ser_evt = self.evt.to_json()
        deser_evt = Event.from_json(ser_evt)
        self.assertEqual(deser_evt.foo, 'bar')
        self.assertRaises(AttributeError, getattr, deser_evt, 'non_existing')
Пример #3
0
 def test_event_equals_parent_type(self):
     mock_event = Event(id=1, name='foo')
     self.assertTrue(mock_event == self.evt)
Пример #4
0
 def setUp(self):
     self.evt = Event(foo='bar')
Пример #5
0
 def test_event_json_serialization(self):
     ser_evt = self.evt.to_json()
     deser_evt = Event.from_json(ser_evt)
     self.assertEqual(deser_evt.foo, 'bar')
     self.assertRaises(AttributeError, getattr, deser_evt, 'non_existing')
Пример #6
0
 def setUp(self):
     self.evt = Event(foo='bar')
Пример #7
0
 def test_event_json_serialization(self):
     ser_evt = self.evt.to_json()
     deser_evt = Event.from_json(ser_evt)
     self.assertEqual(deser_evt.foo, 'bar')
     self.assertRaises(AttributeError, getattr, deser_evt, 'non_existing')