Пример #1
0
def test_update_weekly_business_to_free_week(weekly_business):
    """
    Test if possible to update weekly_business object to a free week
    """
    second_weekly_business = WeeklyBusinessFactory(week=6)
    second_weekly_business.week = 7
    second_weekly_business.save()

    assert weekly_business.week == 5
    assert second_weekly_business.week == 7
Пример #2
0
def test_update_weekly_business_to_taken_week(weekly_business):
    """
    Test if possible to update weekly_business object to a taken week
    """
    with pytest.raises(ValueError) as v_err:
        second_weekly_business = WeeklyBusinessFactory(week=6)
        second_weekly_business.week = 5
        second_weekly_business.save()

    assert "Finnes allerede en ukens bedrift for denne uken" == str(
        v_err.value)
Пример #3
0
def test_update_weekly_business_to_non_existing_week_number():
    """
    Test if possible to update weekly_business object to non existing week numbers
    """
    with pytest.raises(ValueError) as v_err_lt:
        weekly_business = WeeklyBusinessFactory(week=7)
        weekly_business.week = 0
        weekly_business.save()
    with pytest.raises(ValueError) as v_err_gt:
        weekly_business = WeeklyBusinessFactory(week=6)
        weekly_business.week = 53
        weekly_business.save()

    assert "Uke må være mellom 1 og 52" == str(v_err_lt.value)
    assert "Uke må være mellom 1 og 52" == str(v_err_gt.value)