def test_to_dict(self): voice_chat_scheduled = VoiceChatScheduled(self.start_date) voice_chat_scheduled_dict = voice_chat_scheduled.to_dict() assert isinstance(voice_chat_scheduled_dict, dict) assert voice_chat_scheduled_dict["start_date"] == to_timestamp( self.start_date)
def test_de_json(self, bot): assert VoiceChatScheduled.de_json({}, bot=bot) is None json_dict = {'start_date': to_timestamp(self.start_date)} voice_chat_scheduled = VoiceChatScheduled.de_json(json_dict, bot) assert pytest.approx( voice_chat_scheduled.start_date == self.start_date)
def test_slot_behaviour(self, recwarn, mro_slots): inst = VoiceChatScheduled(self.start_date) for attr in inst.__slots__: assert getattr(inst, attr, 'err') != 'err', f"got extra slot '{attr}'" assert not inst.__dict__, f"got missing slot(s): {inst.__dict__}" assert len(mro_slots(inst)) == len(set( mro_slots(inst))), "duplicate slot" inst.custom, inst.start_date = 'should give warning', self.start_date assert len(recwarn) == 1 and 'custom' in str( recwarn[0].message), recwarn.list
def test_equality(self): a = VoiceChatScheduled(self.start_date) b = VoiceChatScheduled(self.start_date) c = VoiceChatScheduled(dtm.datetime.utcnow() + dtm.timedelta(seconds=5)) d = VoiceChatStarted() assert a == b assert hash(a) == hash(b) assert a != c assert hash(a) != hash(c) assert a != d assert hash(a) != hash(d)
def test_expected_values(self): assert pytest.approx( VoiceChatScheduled(start_date=self.start_date) == self.start_date)