Ejemplo n.º 1
0
def test_app_student_fails_to_add_first_reservation(mocked_print, mocked_input,
                                                    mocked_requests_post,
                                                    mocked_requests_get,
                                                    mocked_requests_patch):
    App().run()
    mocked_print.assert_any_call(
        '*** Student houses reservations platform ***')
    mocked_print.assert_any_call('0:\tExit')
    mocked_print.assert_any_call('SUCCESSFUL LOGIN')
    mocked_print.assert_any_call('*** Students panel ***')
    mocked_print.assert_any_call(
        'Your new preferences will overwrite the previous ones, do you now? Y/N'
    )
    mocked_print.assert_any_call('I, lets go!')
    assert len(
        list(
            filter(
                lambda x:
                'Invalid keys entered: please, choose to add a new reservation and retry with correct ones'
                in str(x), mocked_print.mock_calls))) == 2
    assert len(
        list(
            filter(
                lambda x:
                'Your new preferences will overwrite the previous ones, do you now? Y/N'
                in str(x), mocked_print.mock_calls))) == 5
    mocked_print.assert_any_call('Reservation successfully updated')
    mocked_print.assert_any_call(
        'Something went wrong with reservation updating...')
    mocked_print.assert_any_call('Successfully logged out from the system!')
    mocked_print.assert_any_call('Bye!')
    mocked_input.assert_called()
Ejemplo n.º 2
0
def test_app_fail_login_student_correct_format(mocked_print, mocked_input,
                                               mocked_requests_post):
    App().run()
    mocked_print.assert_any_call(
        '*** Student houses reservations platform ***')
    mocked_print.assert_any_call('1:\tLogin as student')
    mocked_print.assert_any_call('No account found with these credentials')
    mocked_print.assert_any_call('Bye!')
    mocked_input.assert_called()
Ejemplo n.º 3
0
def test_app_wrong_entry(mocked_print, mocked_input):
    App().run()
    mocked_print.assert_any_call('Invalid selection. Please, try again...')
    sys.stdout.write(str(mocked_input.call_args_list) + '\n')
    assert mocked_input.call_count == 4  # 3 request answered with errors + 1 with 0
    assert len(
        list(
            filter(
                lambda x: 'Invalid selection. Please, try again..' in str(x),
                mocked_print.mock_calls))) == 3
Ejemplo n.º 4
0
def test_app_fail_login_employee_wrong_format(mocked_print, mocked_input):
    App().run()
    mocked_print.assert_any_call(
        '*** Student houses reservations platform ***')
    mocked_print.assert_any_call('2:\tLogin as employee')
    mocked_print.assert_any_call(
        'Access failed: please, choose to login and retry with correct credentials...'
    )
    mocked_print.assert_any_call('Bye!')
    mocked_input.assert_called()
Ejemplo n.º 5
0
def test_app_login_employee(mocked_print, mocked_input, mocked_requests_post):
    App().run()
    mocked_print.assert_any_call(
        '*** Student houses reservations platform ***')
    mocked_print.assert_any_call('2:\tLogin as employee')
    mocked_print.assert_any_call('SUCCESSFUL LOGIN')
    mocked_print.assert_any_call('*** Administration panel ***')
    mocked_print.assert_any_call('1:\tShow all required reservations')
    mocked_print.assert_any_call('Bye!')
    mocked_requests_post.assert_called_once()
    mocked_input.assert_called()
Ejemplo n.º 6
0
def test_app_login_student(mocked_print, mocked_input, mocked_requests_post):
    App().run()
    mocked_requests_post.assert_called_once()
    mocked_print.assert_any_call(
        '*** Student houses reservations platform ***')
    mocked_print.assert_any_call('1:\tLogin as student')
    mocked_print.assert_any_call('SUCCESSFUL LOGIN')
    mocked_print.assert_any_call('*** Students panel ***')
    mocked_print.assert_any_call('Successfully logged out from the system!')
    mocked_print.assert_any_call('Bye!')
    mocked_input.assert_called()
Ejemplo n.º 7
0
def test_app_student_fail_to_view_his_reservation_after_adding(
        mocked_print, mocked_input, mocked_requests_post, mocked_requests_get):
    App().run()
    mocked_print.assert_any_call(
        '*** Student houses reservations platform ***')
    mocked_print.assert_any_call('0:\tExit')
    mocked_print.assert_any_call('SUCCESSFUL LOGIN')
    mocked_print.assert_any_call('*** Students panel ***')
    # sys.stdout.write(str(mocked_print.call_args_list) + '\n')
    mocked_print.assert_any_call(
        'Something went wrong with your request: RIPIT')
    mocked_print.assert_any_call('Bye!')
    mocked_input.assert_called()
Ejemplo n.º 8
0
def test_app_student_has_no_reservation(mocked_print, mocked_input,
                                        mocked_requests_post,
                                        mocked_requests_get):
    App().run()
    mocked_print.assert_any_call(
        '*** Student houses reservations platform ***')
    mocked_print.assert_any_call('0:\tExit')
    mocked_print.assert_any_call('SUCCESSFUL LOGIN')
    mocked_print.assert_any_call('*** Students panel ***')
    mocked_print.assert_any_call(
        'No reservation found for your matriculation number')
    # sys.stdout.write(str(mocked_print.call_args_list) + '\n')
    mocked_print.assert_any_call('Bye!')
    mocked_input.assert_called()
Ejemplo n.º 9
0
def test_app_student_add_first_reservation(mocked_print, mocked_input,
                                           mocked_requests_post,
                                           mocked_requests_get):
    App().run()
    mocked_print.assert_any_call(
        '*** Student houses reservations platform ***')
    mocked_print.assert_any_call('0:\tExit')
    mocked_print.assert_any_call('SUCCESSFUL LOGIN')
    mocked_print.assert_any_call('*** Students panel ***')
    mocked_print.assert_any_call(
        'Something went wrong with reservation adding')
    mocked_print.assert_any_call('Reservation successfully added')
    mocked_print.assert_any_call('Successfully logged out from the system!')
    mocked_print.assert_any_call('Bye!')
    mocked_input.assert_called()
Ejemplo n.º 10
0
def test_app_student_view_his_reservation_after_adding(mocked_print,
                                                       mocked_input,
                                                       mocked_requests_post,
                                                       mocked_requests_get):
    App().run()
    mocked_print.assert_any_call(
        '*** Student houses reservations platform ***')
    mocked_print.assert_any_call('0:\tExit')
    mocked_print.assert_any_call('SUCCESSFUL LOGIN')
    mocked_print.assert_any_call('*** Students panel ***')
    mocked_print.assert_any_call('Reservation successfully added')
    # sys.stdout.write(str(mocked_print.call_args_list) + '\n')
    assert list(filter(lambda x: 'NRV' in str(x), mocked_print.mock_calls))
    assert list(filter(lambda x: 'SIN' in str(x), mocked_print.mock_calls))
    mocked_print.assert_any_call('Bye!')
    mocked_input.assert_called()
Ejemplo n.º 11
0
def test_app_student_wrong_reservation_added_wrong_format(
        mocked_print, mocked_input, mocked_requests_post, mocked_requests_get):
    App().run()
    mocked_print.assert_any_call(
        '*** Student houses reservations platform ***')
    mocked_print.assert_any_call('0:\tExit')
    mocked_print.assert_any_call('SUCCESSFUL LOGIN')
    mocked_print.assert_any_call('*** Students panel ***')
    assert len(
        list(
            filter(
                lambda x:
                'Invalid keys entered: please, choose to add a new reservation and retry with '
                'correct ones' in str(x), mocked_print.mock_calls))) == 3
    mocked_print.assert_any_call('Successfully logged out from the system!')
    mocked_print.assert_any_call('Bye!')
    mocked_input.assert_called()
Ejemplo n.º 12
0
def test_app_employee_view_all_reservation(mocked_print, mocked_input,
                                           mocked_requests_post,
                                           mocked_requests_get):
    App().run()
    # sys.stdout.write(str(mocked_print.call_args_list) + '\n')

    mocked_print.assert_any_call(
        '*** Student houses reservations platform ***')
    mocked_print.assert_any_call('2:\tLogin as employee')
    mocked_print.assert_any_call('SUCCESSFUL LOGIN')
    mocked_print.assert_any_call('*** Administration panel ***')
    mocked_print.assert_any_call('1:\tShow all required reservations')

    assert list(filter(lambda x: 'NRV' in str(x), mocked_print.mock_calls))
    assert list(filter(lambda x: 'MTB' in str(x), mocked_print.mock_calls))
    assert list(filter(lambda x: 'CH2' in str(x), mocked_print.mock_calls))
    assert list(filter(lambda x: 'DBL' in str(x), mocked_print.mock_calls))
    assert list(filter(lambda x: 'NRV' in str(x), mocked_print.mock_calls))
    assert len(list(filter(lambda x: 'SIN' in str(x),
                           mocked_print.mock_calls))) == 2
    mocked_print.assert_any_call('Bye!')
    mocked_input.assert_called()
Ejemplo n.º 13
0
def test_app_panic_error(mocked_print, mocked_input, mocked_requests_get):
    App().run()
    sys.stdout.write(str(mocked_print.call_args_list) + '\n')
    assert list(
        filter(lambda x: 'Panic error!' in str(x), mocked_print.mock_calls))