Beispiel #1
0
 def test_show_projects(self, mock_db, mock_table):
     gpm = GPM()
     gpm.gpm_id = 'sample'
     gpm.show_projects()
     mock_db().get_gpm_projects_details.assert_called_once_with('sample')
     mock_db().get_gpm_projects_details().fetchall.assert_called_once()
     mock_table.assert_called_once()
Beispiel #2
0
def main():
    """
    this method is used to call main menu for login
    """
    conn = ConnectDb()
    try:
        os.system('clear')
        # select role for login
        print("login as:\n")
        menu = Menu()
        roles = [x.name for x in Role]
        roles.extend([str(BackButton.EXIT.name)])
        role = menu.draw_menu(roles)
        role_id = Role[role].value
        input()

        # get user name and password for login
        user_name = input("enter user name: ")
        password = getpass()

        # check user authentication
        result = conn.get_user_with_role(user_name, role_id)
        flag = True
        if result is not None:
            os.system('clear')
            actual_pass = decrypt_pass(result[1])
            if str(actual_pass.decode("utf-8")) == password:
                flag = False
                if role_id == int(Role.BDO.value):
                    bdo = BDO()
                    bdo.bdo_id = result[0]
                    bdo.bdo_features()
                elif role_id == int(Role.GPM.value):
                    gpm = GPM()
                    gpm.gpm_id = result[0]
                    gpm.gpm_features()
                elif role_id == int(Role.Member.value):
                    member = Member()
                    member.member_id = result[0]
                    member.member_features()
        if result is None or flag:
            print(Color.F_Red + 'wrong credentials' + Base.END)
            input()
            main()

    except Exception as e:
        print(e)
        sys.exit()
    finally:
        conn.close_conn()
Beispiel #3
0
 def show_members(self):
     """
     this method is used to print members and gpm of current bdo.
     """
     print("members List:\n")
     gpm_list = self.conn.get_user_names(self.bdo_id)
     if len(gpm_list) == 0:
         print(Color.F_Green +
               "you don't have any GPM  and members under you" + Base.END)
         return
     for gpm_detail in gpm_list:
         print('GPM name ' + gpm_detail[0])
         gpm = GPM()
         gpm.gpm_id = gpm_detail[1]
         gpm.show_members()
Beispiel #4
0
    def test_delete_project_members_similar_request(self, mock_db, mock_print):
        mock_db().get_created_by_id.return_value = ['bdo_id']
        mock_db().get_approvals_list.return_value = [[
            'WAGE|member1|member_id|project_id|project1'
        ]]
        gpm = GPM()
        gpm.project_id = 'project_id'
        gpm.gpm_id = 'gpm_id'
        gpm.member_id = 'member_id'

        gpm.delete_project_request()

        mock_db().get_created_by_id.assert_called_once()
        mock_db().get_approvals_list.assert_called_once()
        mock_print.assert_called_once()
Beispiel #5
0
    def test_delete_project_members_request(self, mock_db, mock_print):
        mock_db().get_created_by_id.return_value = ['bdo_id']
        mock_db().get_approvals_list.return_value = [[
            'WAGE|member1|cc29a75e-8bf8-48e0-85f5-6990f4cc87e8|4b602623-'
            '8d64-4fdf-8e9f-18b7b3f4389b|project1'
        ]]
        mock_db().get_user_name.return_value = ['name']
        mock_db().get_project_name.return_value = ['project_name']
        gpm = GPM()
        gpm.project_id = 'project_id'
        gpm.gpm_id = 'gpm_id'
        gpm.member_id = 'member_id'

        gpm.delete_project_request()

        mock_db().get_created_by_id.assert_called_once()
        mock_db().get_approvals_list.assert_called_once()
        mock_db().get_user_name.assert_called_once_with('member_id')
        mock_db().get_project_name.assert_called_once_with('project_id')
        mock_db().register_complain.assert_called_once()
        mock_db().commit_data.assert_called_once()
        mock_print.assert_called_once()