def test_change_from_draft_to_finished(): event = Event(name="Tallinn Meeting", description="Meeting friends in Tallinn", place="Livalia, 23", date=datetime.today().weekday()) with pytest.raises(InvalidTranstionStatus): event.change_status_to(EventStatus.FINISHED) assert event.status == EventStatus.DRAFT
def test_change_from_status1_to_status2_unsuccess(from_status, to_status, expected_exception): # given event = Event(name="Tallinn Meeting", description="Meeting friends in Tallinn", place="Livalia, 23", date=datetime.today().weekday(), status=from_status) # when with pytest.raises(expected_exception): event.change_status_to(to_status)
def test_create_event_with_published_status(): event = Event(name="Tallinn Meeting", description="Meeting friends in Tallinn", place="Livalia, 23", date=datetime.today().weekday(), status=EventStatus.PUBLISHED) assert event.status == EventStatus.PUBLISHED
def event(): print("FIXTURE setuping!") yield Event(name="Tallinn Meeting", description="Meeting friends in Tallinn", place="Livalia, 23", date=datetime.today().weekday()) print("FIXTURE teardown!")
def test_create_event_with_organizer_without_required_fields(): with pytest.raises(InvalidOrganizerError): Event(name="Tallinn Meeting", description="Meeting friends in Tallinn", place="Livalia, 23", date=datetime.today().weekday(), organizer={ "wrongkey1": "data", "wrongkey2": "data2" })
def _translate_from_dict(self, data): if data is None or not isinstance(data, dict): return data if 'day' in data: if data['day'] == "Saturday": data['date'] = 5 return Event(**data)
def test_change_from_status1_to_status2_success(from_status, to_status, expected): # given event = Event(name="Tallinn Meeting", description="Meeting friends in Tallinn", place="Livalia, 23", date=datetime.today().weekday(), status=from_status) if type(expected) == type: # when with pytest.raises(expected): event.change_status_to(to_status) else: # when event.change_status_to(to_status) # assert assert event.status == expected
def test_create_event_on_monday(): with pytest.raises(ValueError): Event(name="Tallinn Meeting", description="Meeting friends in Tallinn", place="Livalia, 23", date=0)
def test_is_possible_day(): assert Event.is_possible_day(0) == False