Exemplo n.º 1
0
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
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
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
Exemplo n.º 4
0
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!")
Exemplo n.º 5
0
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"
              })
Exemplo n.º 6
0
    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)
Exemplo n.º 7
0
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
Exemplo n.º 8
0
def test_create_event_on_monday():
    with pytest.raises(ValueError):
        Event(name="Tallinn Meeting",
              description="Meeting friends in Tallinn",
              place="Livalia, 23",
              date=0)
Exemplo n.º 9
0
def test_is_possible_day():
    assert Event.is_possible_day(0) == False