Ejemplo n.º 1
0
    def test_check_availability_empty(self, mock_conn):
        mock_conn.return_value.cursor.return_value.fetchall.return_value = []
        test_class = EmployeeService.Employee()

        result = test_class.check_availability(1, 'k', 'd', '10:00')

        assert result is False
Ejemplo n.º 2
0
    def test_show_upcoming_bookings_empty(self, mock_conn):
        mock_conn.return_value.cursor.return_value.fetchall.return_value = []
        test_class = EmployeeService.Employee()

        result = test_class.show_upcoming_bookings()

        assert result is False
Ejemplo n.º 3
0
    def test_login_invalid_user(self, inputs, mock_conn):
        inputs.return_value = '*****@*****.**'
        mock_conn.return_value.cursor.return_value.fetchone.return_value = None
        test_class = EmployeeService.Employee()

        result = test_class.employee_login()

        assert result is False
Ejemplo n.º 4
0
    def test_check_availability(self, mock_conn):
        mock_conn.return_value.cursor.return_value.fetchall.return_value = [
            ('cab123', '12:00:00', 2, 'stop', 2)
        ]

        test_class = EmployeeService.Employee()

        result = test_class.check_availability(1, 'k', 'd', '10:00')

        assert result is True
Ejemplo n.º 5
0
    def test_cancel_booking_no_upcoming_bookings(self, mock_conn,
                                                 mock_show_upcoming_bookings):

        mock_show_upcoming_bookings.return_value = []

        test_class = EmployeeService.Employee()

        result = test_class.cancel_booking()

        assert result is False
Ejemplo n.º 6
0
    def test_show_upcoming_bookings(self, mock_conn):
        mock_conn.return_value.cursor.return_value.fetchall.return_value = [
            ('2020-05-28', '21:00', 'test', 'source', 'destination', 1)
        ]

        test_class = EmployeeService.Employee()

        result = test_class.show_upcoming_bookings()

        assert result is True
Ejemplo n.º 7
0
    def test_show_all_routes(self, mock_conn):
        mock_conn.return_value.cursor.return_value.fetchall.return_value = [
            (1, 'test')
        ]

        test_class = EmployeeService.Employee()

        result = test_class.show_all_routes()

        assert result is True
Ejemplo n.º 8
0
    def test_login_password_match(self, inputs, mock_conn, getpass):
        inputs.return_value = '*****@*****.**'
        getpass.return_value = 'pass'
        mock_conn.return_value.cursor.return_value.fetchone.return_value = (
            '*****@*****.**', 'pass', 1, 'TeamName')
        test_class = EmployeeService.Employee()

        result = test_class.employee_login()

        assert result is True
Ejemplo n.º 9
0
    def test_cancel_booking_unknown_error(self, inputs, mock_conn,
                                          mock_show_upcoming_bookings):
        inputs.return_value = ['a']
        mock_show_upcoming_bookings.return_value = ['something']

        test_class = EmployeeService.Employee()

        result = test_class.cancel_booking()

        assert result is False
Ejemplo n.º 10
0
    def test_book_cab_not_available(self, inputs, mock_conn,
                                    mock_show_all_routes,
                                    mock_check_availability):
        inputs.side_effect = ['1', 's', 'd', '12:00']
        mock_show_all_routes.return_value = True
        mock_check_availability.return_value = False
        test_class = EmployeeService.Employee()

        result = test_class.cancel_booking()

        assert result is False
Ejemplo n.º 11
0
    def test_get_booking_by_id(self, mock_conn):
        mock_conn.return_value.cursor.return_value.fetchone.return_value = [
            ('2020-01-01', '12:00:00', 'cab123', 1, 'source', 'destination')
        ]

        test_class = EmployeeService.Employee()

        result = test_class.get_booking_by_id(1)

        assert result == [('2020-01-01', '12:00:00', 'cab123', 1, 'source',
                           'destination')]
Ejemplo n.º 12
0
    def test_employee_tasks(self, inputs, mock_book_cab,
                            mock_show_past_bookings,
                            mock_show_upcoming_bookings, mock_cancel_booking):
        inputs.side_effect = ['1', '2', '3', '4', '6', '5']
        test_class = EmployeeService.Employee()

        test_class.employee_tasks()

        mock_book_cab.assert_called_once_with()
        mock_show_past_bookings.assert_called_once_with()
        mock_show_upcoming_bookings.assert_called_once_with()
        mock_cancel_booking.assert_called_once_with()
Ejemplo n.º 13
0
    def test_cancel_booking_invalid_booking_id(self, inputs, mock_conn,
                                               mock_show_upcoming_bookings,
                                               mock_get_booking_by_id):
        inputs.side_effect = [1]
        mock_show_upcoming_bookings.return_value = ['something']
        mock_get_booking_by_id.return_value = []

        test_class = EmployeeService.Employee()

        result = test_class.cancel_booking()

        assert result is False
Ejemplo n.º 14
0
    def test_book_cab(self, inputs, mock_conn, mock_show_all_routes,
                      mock_check_availability):
        inputs.side_effect = ['1', 's', 'd', '12:00', 'cab', '13:00']

        mock_show_all_routes.return_value = True
        mock_check_availability.return_value = True

        test_class = EmployeeService.Employee()

        result = test_class.book_cab()

        assert result is True
Ejemplo n.º 15
0
from src import EmployeeService, AdminService

if __name__ == '__main__':
    option = ''
    while option != '3':
        print("MAIN MENU")
        print("1. Admin Login")
        print("2. Employee Login")
        print("3. Exit")
        option = input("Select Your Option ")
        if option == '1':
            admin = AdminService.Admin()
            if admin.admin_login():
                admin.admin_tasks()
        elif option == '2':
            employee = EmployeeService.Employee()
            if employee.employee_login():
                employee.employee_tasks()
        elif option == '3':
            print("Thank You.")
        else:
            print("Invalid choice.")
Ejemplo n.º 16
0
    def test_show_past_bookings_unknown_error(self):
        test_class = EmployeeService.Employee()

        result = test_class.show_past_bookings()

        assert result is False
Ejemplo n.º 17
0
    def test_check_availability_unknown_error(self):
        test_class = EmployeeService.Employee()

        result = test_class.check_availability(1, 'k', 'd', '10:00')

        assert result is False
Ejemplo n.º 18
0
    def test_book_cab_unknown_error(self):
        test_class = EmployeeService.Employee()

        result = test_class.book_cab()

        assert result is False
Ejemplo n.º 19
0
    def test_increment_seats(self, mock_conn):
        test_class = EmployeeService.Employee()

        result = test_class.increment_seats('cab123', 1, 's', 'd', '12:00')

        assert result is True
Ejemplo n.º 20
0
    def test_get_booking_by_id_unknown_error(self):
        test_class = EmployeeService.Employee()

        result = test_class.get_booking_by_id('a')

        assert result is False