예제 #1
0
def test_select_rooms_ok(service: ShowPricesForm, context: Context, house,
                         room):
    service._rooms_repo = Mock(select=Mock(return_value=[room]))
    context.house = house

    result = service.select_rooms(context)
    assert is_successful(result)
    assert result.unwrap().rooms == [room]
예제 #2
0
def test_select_rooms_error(service: ShowPricesForm, context: Context, house):
    service._rooms_repo = Mock(select=Mock(side_effect=RuntimeError('ERR')))
    context.house = house

    result = service.select_rooms(context)
    assert not is_successful(result)
    assert result.failure().failure == ReservationErrors.error
    assert str(result.failure().exc) == 'ERR'