def test_create_event_unknown_kwargs(self, mockobj): m = Mock() m.ts_created = sentinel.old_ts_created mockobj.IonObject.return_value = m with self.assertRaises(EventError) as cm: self._pub.create_event(extra=sentinel.extra) self.assertIn('extra', cm.exception.message)
def test_create_event_with_kwargs(self, mockobj): m = Mock() m.ts_created = sentinel.old_ts_created m.field = sentinel.old_value mockobj.IonObject.return_value = m ev = self._pub.create_event(field=sentinel.value) mockobj.IonObject.assert_called_once_with(self._pub.msg_type) self.assertEquals(m.field, sentinel.value)
def test_create_event_default_timestamp(self, mockobj): m = Mock() m.ts_created = sentinel.old_ts_created mockobj.IonObject.return_value = m ev = self._pub.create_event() mockobj.IonObject.assert_called_once_with(self._pub.msg_type) self.assertTrue(hasattr(ev, 'ts_created')) self.assertNotEquals(ev.ts_created, sentinel.old_ts_created) self.assertIsInstance(ev.ts_created, float)