def test_create_scheduling_sucess(): service.create('Title', datetime(2018, 9, 1, 10, 0), datetime(2018, 9, 1, 11, 0), 2, 1) schedules = service.get_all(None) assert len(schedules) == 4
def test_create_scheduling_error_meeting_room_not_found(): with pytest.raises(SchedulingException) as e_info: service.create('Title', datetime(2018, 9, 1, 10, 0), datetime(2018, 9, 1, 11, 0), 200, 1) assert e_info.value.message == 'Sala de reunião não encontrada'
def test_create_scheduling_error_user_not_found(): with pytest.raises(SchedulingException) as e_info: service.create('Title', datetime(2018, 9, 1, 10, 0), datetime(2018, 9, 1, 11, 0), 2, 1000) assert e_info.value.message == 'Usuário não encontrado'
def test_create_scheduling_same_room_invalid_period(test_client, init_database): with pytest.raises(SchedulingException) as e_info: service.create('Title', datetime(2018, 9, 1, 10, 0), datetime(2018, 9, 1, 11, 0), 1, 1) assert e_info.value.message == 'Já existe agendamento para o horário desejado.'
def test_create_invalid_period(test_client, init_database): with pytest.raises(SchedulingException) as e_info: service.create('Title', datetime(2018, 1, 2), datetime(2018, 1, 1), 1, 1) assert e_info.value.message == 'Data inicial do agendamento não pode ser maior que a data final do agendamento'
def test_create_title_invalid_length(test_client, init_database): invalid_title = ''.join('a' for _ in range(90)) with pytest.raises(SchedulingException) as e_info: service.create(invalid_title, datetime(2018, 1, 1), datetime(2018, 1, 1), 1, 1) assert e_info.value.message == 'Título do agendamento inválido. Não deve ser vazio, e deve conter no máximo 80 caracteres.'
def test_create_title_invalid(test_client, init_database): with pytest.raises(SchedulingException) as e_info: service.create(None, datetime(2018, 1, 1), datetime(2018, 1, 1), 1, 1) assert e_info.value.message == 'Título do agendamento inválido. Não deve ser vazio, e deve conter no máximo 80 caracteres.'
def post(self): scheduling = post_put_parser.parse_args() scheduling_service.create(scheduling.title, scheduling.initial_date, scheduling.final_date, scheduling.meeting_room_id, scheduling.user_id) return 'Agendamento criado com sucesso'