Esempio n. 1
0
    def test_raise_when_setting_non_dictionary_payload(self):
        """ Raise when setting a payload that is not a dict """
        event = Event()
        with self.assertRaises(x.EventError) as cm:
            event.payload = [123]

        self.assertIn('Payload must be a dictionary', str(cm.exception))
Esempio n. 2
0
    def test_save_can_update_existing_event(self):
        """ Save event can update existing event """
        service = EventService(db=self.db)

        # create first
        event = Event(
            type='DUMMY_EVENT',
            object_id=123,
            author=123,
            payload={'body': 'I am the payload 😂'},
            payload_rollback={'body': 'I am rollback payload 😂'},
        )
        service.save_event(event)

        # now update
        event = service.get_event(event.id)
        event.payload = {'body': 'I am updated body 👻'}
        event = service.save_event(event)
        self.assertEquals('I am updated body 👻', event.payload['body'])
        self.assertEquals(1, event.id)
Esempio n. 3
0
 def test_raise_when_fails_to_decode_payload_string(self):
     """ Raise when payload string can not be decoded """
     event = Event()
     with self.assertRaises(x.EventError) as cm:
         event.payload = 'no-a-json-string'
     self.assertIn('Failed to decode payload string', str(cm.exception))