Example #1
0
 def check_admin(self):
     """
     Login for Admin
     :return: True/False
     """
     username = input("Enter your username: "******".format(username)).fetchall()
             connection.commit()
             cursor.close()
             if retrieve_password:
                 if password.encode() == self.cipher_suite.decrypt(retrieve_password[0][1].encode()):
                     admin().select_choice()
                     print("Access granted")
                     return True
                 print("wrong password")
                 return False
             print("Username not found")
             return False
         except Error as e:
             print(e)
             return False
     print("Password or Username is empty")
     return False
Example #2
0
    def test_delete_team_no_team_record(self, db, input, vci):
        mocksql = mock.Mock()
        db.sql_connection.return_value = mocksql
        mocksql.cursor.return_value = mocksql
        mocksql.execute.return_value = mocksql
        mocksql.fetchall.return_value = []

        assert admin().delete_team() == False
Example #3
0
    def test_validate_roleid_in_valid_role_id(self, db):
        mocksql = mock.Mock()
        db.sql_connection.return_value = mocksql
        mocksql.cursor.return_value = mocksql
        mocksql.execute.return_value = mocksql
        mocksql.fetchall.return_value = []

        assert admin().validate_roleid('f3da47ee-937a-4f2d-9728-1bf8aa4a5ed5,', mocksql) == False
Example #4
0
    def test_validate_complaintid_no_complains(self, db):
        mocksql = mock.Mock()
        db.sql_connection.return_value = mocksql
        mocksql.cursor.return_value = mocksql
        mocksql.execute.return_value = mocksql
        mocksql.fetchall.return_value = []

        assert admin().validate_complaintid('3161af3f-b810-46fd-8fca-7ac5e47966e5', mocksql) == False
Example #5
0
    def test_final_judgement_no_reports_data(self, db):
        mocksql = mock.Mock()
        db.sql_connection.return_value = mocksql
        mocksql.cursor.return_value = mocksql
        mocksql.execute.return_value = mocksql
        mocksql.fetchall.return_value = []

        assert admin().final_judgement() == True
Example #6
0
    def test_validate_team_name(self, db):
        mocksql = mock.Mock()
        db.sql_connection.return_value = mocksql
        mocksql.cursor.return_value = mocksql
        mocksql.execute.return_value = mocksql
        mocksql.fetchall.return_value = ['d', 'u', 'm', 'm', 'y', 'd', 'a', 't']

        assert admin().validate_team_name('dummyteam', mocksql) == False
Example #7
0
    def test_validate_team_name_no_team_data(self, db):
        mocksql = mock.Mock()
        db.sql_connection.return_value = mocksql
        mocksql.cursor.return_value = mocksql
        mocksql.execute.return_value = mocksql
        mocksql.fetchall.return_value = []

        assert admin().validate_team_name('dummyteam', mocksql) == True
Example #8
0
    def test_create_team_no_complaints(self, db):
        mocksql = mock.Mock()
        db.sql_connection.return_value = mocksql
        mocksql.cursor.return_value = mocksql
        mocksql.execute.return_value = mocksql
        mocksql.fetchall.return_value = []

        assert admin().create_team() == False
Example #9
0
    def test_validate_team_name_sqlite_error(self, db):
        mocksql = mock.Mock()
        db.sql_connection.return_value = mocksql
        mocksql.cursor.return_value = mocksql
        mocksql.execute.return_value = mocksql
        mocksql.fetchall.side_effect = _sqlite3.Error

        assert admin().validate_team_name('dummyteam', mocksql) == False
Example #10
0
    def test_delete_member_no_member_data(self, db):
        mocksql = mock.Mock()
        db.sql_connection.return_value = mocksql
        mocksql.cursor.return_value = mocksql
        mocksql.execute.return_value = mocksql
        mocksql.fetchall.return_value = []

        assert admin().delete_member() == False
Example #11
0
    def test_input_username_empty_username(self, db, input):
        input.side_effect = [None, 'qwerty']
        mocksql = mock.Mock()
        db.sql_connection.return_value = mocksql
        mocksql.cursor.return_value = mocksql
        mocksql.execute.return_value = mocksql
        mocksql.fetchone.return_value = []

        assert admin().input_username() == None
Example #12
0
    def test_update__member_no_members(self, db, update):
        mocksql = mock.Mock()
        db.sql_connection.return_value = mocksql
        mocksql.cursor.return_value = mocksql
        mocksql.execute.return_value = mocksql
        mocksql.fetchall.return_value = []
        update.return_value = mocksql

        assert admin().update_member() == False
Example #13
0
    def test_input_username(self, db, input):
        input.return_value = 'abcd'
        mocksql = mock.Mock()
        db.sql_connection.return_value = mocksql
        mocksql.cursor.return_value = mocksql
        mocksql.execute.return_value = mocksql
        mocksql.fetchone.return_value = []
        # mocksql.fetchone.return_value = ['marcus','gAAAAABeuQUAIlvWQkfnrM6TpLGg7WscPttEWX0T7uvcY3UuCxeMxkIffoOIYm9wUSKlURmFT8YWszSpwKFvghn730P7AwtNxA==','employee','335fb7a4-b6d9-48ac-9a67-b9578d758d00','2020-05-11 13:25:44.334476','2020-05-10 17:05:11.008580','False']

        assert admin().input_username() == 'abcd'
Example #14
0
    def test_delete_member_invalid_user_choice(self, db, input):
        mocksql = mock.Mock()
        db.sql_connection.return_value = mocksql
        mocksql.cursor.return_value = mocksql
        mocksql.execute.return_value = mocksql
        mocksql.fetchall.return_value = [['1915b58c-f7c3-4282-b997-76ef3bf75e71', 'C', 'Akash', '9899999999', 'False'],
                                         ['fwr', 'D', 'VK', '12345890', 'False']]
        input.side_effect = ['5', '2']

        assert admin().delete_member() == True
Example #15
0
    def test_update__member_success(self, db, update):
        mocksql = mock.Mock()
        db.sql_connection.return_value = mocksql
        mocksql.cursor.return_value = mocksql
        mocksql.execute.return_value = mocksql
        mocksql.fetchall.return_value = [['1915b58c-f7c3-4282-b997-76ef3bf75e71', 'C', 'Akash', '9899999999', 'False'],
                                         ['fwr', 'D', 'VK', '12345890', 'False']]
        update.return_value = mocksql

        assert admin().update_member() == True
Example #16
0
    def test_create_member_number_validation_failed(self, pwd, usr, input, db):
        usr.return_value = 'abcd'
        pwd.return_value = 'abcdefgh'.encode()
        input.side_effect = ['Factory', 'abc', 'ab123', '9897067188']
        mocksql = mock.Mock()
        db.sql_connection.return_value = mocksql
        db.cursor.return_value = mocksql
        mocksql.execute.return_value = mocksql

        assert admin().create_member() == True
Example #17
0
    def test_create_member_success(self, pwd, usr, input, db):
        usr.return_value = 'abcd'
        pwd.return_value = 'xcvb'.encode()
        input.side_effect = ['Factory', 'abc', '9897043213']
        mocksql = mock.Mock()
        db.sql_connection.return_value = mocksql
        db.cursor.return_value = mocksql
        mocksql.execute.return_value = mocksql

        assert admin().create_member() == True
Example #18
0
    def test_delete_team(self, db, input, vci):
        data1 = [('ea384fc3-a083-425e-b80a-ea88827b39df',
                  '125518f2-5908-4cb5-8754-a20aaac8d55b', '2019-05-10 18:31:52.130590')]
        mocksql = mock.Mock()
        db.sql_connection.return_value = mocksql
        mocksql.cursor.return_value = mocksql
        mocksql.execute.return_value = mocksql
        mocksql.fetchall.side_effect = data1
        input.return_value = '3161af3f-b810-46fd-8fca-7ac5e47966e5'

        assert admin().delete_team() == True
Example #19
0
    def test_final_judgement_invalid_verdict(self, db, input, vci):
        mocksql = mock.Mock()
        db.sql_connection.return_value = mocksql
        mocksql.cursor.return_value = mocksql
        mocksql.execute.return_value = mocksql
        mocksql.fetchall.return_value = [(
            '2d194d0b-43e1-45ed-8086-c3c7e674151d', '125518f2-5908-4cb5-8754-a20aaac8d55b',
            '2020-05-10 18:31:52.130590', 40, 20, 'fire broke out in welding zone', 'fire',
            'reason', '2020-05-11 12:46:10.316064')]
        input.side_effect = ['125518f2-5908-4cb5-8754-a20aaac8d55b', 'verdict123', 'verdict']

        assert admin().final_judgement() == True
Example #20
0
    def test_create_team_no_member_records(self, db, input, vci):
        data1 = [['125518f2-5908-4cb5-8754-a20aaac8d55b', 'desc', 'Factory', 'open', '2020-05-10 18:31:52.130590'],
                 ['ea384fc3-a083-425e-b80a-ea88827b39df', 'description', 'Warehouse', 'open',
                  '2019-05-10 18:31:52.130590']]
        mocksql = mock.Mock()
        db.sql_connection.return_value = mocksql
        mocksql.cursor.return_value = mocksql
        mocksql.execute.return_value = mocksql
        mocksql.fetchall.side_effect = [data1, None]
        input.return_value = 'ea384fc3-a083-425e-b80a-ea88827b39df'

        assert admin().create_team() == False
Example #21
0
 def test_create_team_invalid_teamname(self, db, input, pwd, vtn, vci):
     data1 = [['125518f2-5908-4cb5-8754-a20aaac8d55b', 'desc', 'Factory', 'open', '2020-05-10 18:31:52.130590'],
              ['ea384fc3-a083-425e-b80a-ea88827b39df', 'description', 'Warehouse', 'open',
               '2019-05-10 18:31:52.130590']]
     mocksql = mock.Mock()
     db.sql_connection.return_value = mocksql
     mocksql.cursor.return_value = mocksql
     mocksql.execute.return_value = mocksql
     mocksql.fetchall.return_value = data1
     input.side_effect = ['ea384fc3-a083-425e-b80a-ea88827b39df', '2',
                          'ghnj78', 'teamA']
     pwd.return_value = 'xcvb'.encode()
     assert admin().create_team() == True
Example #22
0
    def test_update_team_success_invalid_user_choice(self, db, input, vci, vri):
        data1 = [('ea384fc3-a083-425e-b80a-ea88827b39df',
                  '125518f2-5908-4cb5-8754-a20aaac8d55b', '2019-05-10 18:31:52.130590')]
        data2 = [('1915b58c-f7c3-4282-b997-76ef3bf75e71'),
                 ('6c35d84e-e198-47ae-8bf8-4131978d806e')]
        mocksql = mock.Mock()
        db.sql_connection.return_value = mocksql
        mocksql.cursor.return_value = mocksql
        mocksql.execute.return_value = mocksql
        mocksql.fetchall.side_effect = [data1, data2]
        input.side_effect = ['3161af3f-b810-46fd-8fca-7ac5e47966e5', '5', '3']

        assert admin().update_team() == False
Example #23
0
    def test_create_team_invalid_password(self, db, input, pwd, vtn):
        data1 = [['125518f2-5908-4cb5-8754-a20aaac8d55b', 'desc', 'Factory', 'open', '2020-05-10 18:31:52.130590'],
                 ['ea384fc3-a083-425e-b80a-ea88827b39df', 'description', 'Warehouse', 'open',
                  '2019-05-10 18:31:52.130590']]
        mocksql = mock.Mock()
        db.sql_connection.return_value = mocksql
        mocksql.cursor.return_value = mocksql
        mocksql.execute.return_value = mocksql
        mocksql.fetchall.return_value = data1
        input.side_effect = ['ea384fc3-a083-425e-b80a-ea88827b39df', '1', '5039220d-353d-4ce3-a189-48ec8c1a8566', '2',
                             'dummyteamname']
        pwd.side_effect = [None, 'xcvb'.encode()]

        assert admin().create_team() == True
Example #24
0
    def test_update_team_no_members(self, db, input, vci, vri):
        data1 = [('ea384fc3-a083-425e-b80a-ea88827b39df',
                  '125518f2-5908-4cb5-8754-a20aaac8d55b', '2019-05-10 18:31:52.130590')]
        data2 = [('1915b58c-f7c3-4282-b997-76ef3bf75e71'),
                 ('6c35d84e-e198-47ae-8bf8-4131978d806e')]
        data3 = [('335fb7a4-b6d9-48ac-9a67-b9578d758d00', 'C', 'Akash', '9897', 'False')]
        mocksql = mock.Mock()
        db.sql_connection.return_value = mocksql
        mocksql.cursor.return_value = mocksql
        mocksql.execute.return_value = mocksql
        mocksql.fetchall.side_effect = [data1, data2, None]
        input.side_effect = ['3161af3f-b810-46fd-8fca-7ac5e47966e5', '1']

        assert admin().update_team() == False
Example #25
0
    def test_select_choice_invalid_option(self, input):
        input.side_effect = ['11', '10']

        assert admin().select_choice() == True
Example #26
0
    def test_is_updated_success_invalid_roleid(self, input):
        input.side_effect = [None, 'f3da47ee-937a-4f2d-9728-1bf8aa4a5ed5', '3', '9999999999', '4']
        mocksql = mock.Mock()
        mocksql.execute.return_value = mocksql

        assert admin().is_updated(mocksql) == None
Example #27
0
 def test_final_judgement_sqlite_error(self, db):
     assert admin().final_judgement() == False
Example #28
0
    def test_select_choice9(self, input, cm):
        input.side_effect = ['9', '10']
        cm.return_value = True

        assert admin().select_choice() == True
Example #29
0
 def test_delete_team_sqlite_error(self, db):
     assert admin().delete_team() == False
Example #30
0
 def test_update_team_sqlite_error(self, db):
     assert admin().update_team() == False