Exemple #1
0
    def test_update_user_attribute_success_case_exists_record_contain_callerservicename_and_data_body_contain_callerservicename(
            self):
        # perpare data test
        data_update = DataPmUserAttribute.DATA_UPDATE_SIMPLE
        data_body = {
            "userName": data_update['UserName'],
            "companyName": data_update['CompanyName'],
            "departmentName": data_update['DepartmentName'],
            "countryCode": data_update['CountryCode'],
            "companyFlg": data_update['CompanyFlg'],
            "callerServiceName": "opswitch"
        }
        mock_pm_userAttribute.create(data_insert)
        event_mock = event_create.get_event_object(
            trace_id=data_insert['UserID'], body=json.dumps(data_body))

        # Call function test
        response = user.update_user_attributes_handler(event_mock, {})

        # Check data
        status_code = response['statusCode']
        response_body = json.loads(response['body'])

        self.assertEqual(status_code, HTTPStatus.OK.value)
        self.assertEqual(response_body['id'], data_insert['UserID'])
        self.assertEqual(response_body['userName'], data_body['userName'])
        self.assertEqual(response_body['companyName'],
                         data_body['companyName'])
        self.assertEqual(response_body['depertmentName'],
                         data_body['departmentName'])
        self.assertEqual(response_body['countryCode'],
                         data_body['countryCode'])
        self.assertEqual(response_body['companyFlg'], data_body['companyFlg'])
        self.assertEqual(response_body['callerServiceName'],
                         data_insert['CallerServiceName'])
Exemple #2
0
    def test_get_user_success_case_not_caller_service_name(self):
        # perpare data test
        data_insert = DataPmUserAttribute.DATA_NOT_CALLERSERVICENAME
        mock_pm_userAttribute.create(data_insert)
        event_mock = event_create.get_event_object(
            trace_id=data_insert['UserID'])

        # Call function test
        result = user.get_user_attributes_handler(event_mock, {})

        # Check data
        status_code = result['statusCode']
        response_body = json.loads(result['body'])

        self.assertEqual(status_code, HTTPStatus.OK.value)
        self.assertEqual(response_body['id'], data_insert['UserID'])
        self.assertEqual(response_body['userName'], data_insert['UserName'])
        self.assertEqual(response_body['mailStatus'],
                         data_insert['MailStatus'])
        self.assertEqual(response_body['companyName'],
                         data_insert['CompanyName'])
        self.assertEqual(response_body['depertmentName'],
                         data_insert['DepartmentName'])
        self.assertEqual(response_body['companyFlg'],
                         data_insert['CompanyFlg'])
        self.assertEqual(response_body['countryCode'],
                         data_insert['CountryCode'])

        self.assertFalse("callerServiceName" in response_body.keys())
Exemple #3
0
    def test_get_user_attributes_success(self):
        # perpare data test
        mock_pm_userAttribute.create(data_insert)

        # Call function test
        result = user.get_user_attributes_handler(event_mock, {})

        # Check data
        status_code = result['statusCode']
        response_body = json.loads(result['body'])

        self.assertEqual(status_code, HTTPStatus.OK.value)
        self.assertEqual(response_body['id'], data_insert['UserID'])
        self.assertEqual(response_body['userName'], data_insert['UserName'])
        self.assertEqual(response_body['mailStatus'],
                         data_insert['MailStatus'])
        self.assertEqual(response_body['companyName'],
                         data_insert['CompanyName'])
        self.assertEqual(response_body['depertmentName'],
                         data_insert['DepartmentName'])
        self.assertEqual(response_body['companyFlg'],
                         data_insert['CompanyFlg'])
        self.assertEqual(response_body['countryCode'],
                         data_insert['CountryCode'])
        self.assertEqual(response_body['callerServiceName'],
                         data_insert['CallerServiceName'])
    def test_update(self):
        # prepare data
        data_insert = DataPmUserAttribute.DATA_SIMPLE
        mock_pm_userAttribute.create(data_insert)

        data_update_simple = DataPmUserAttribute.DATA_UPDATE_SIMPLE
        data_update = {
            "UserName": {
                "Value": data_update_simple['UserName']
            },
            "CompanyName": {
                "Value": data_update_simple['CompanyName']
            },
            "DepartmentName": {
                "Value": data_update_simple['DepartmentName']
            },
            "CompanyFlg": {
                "Value": data_update_simple['CompanyFlg']
            },
            "CountryCode": {
                "Value": data_update_simple['CountryCode']
            },
            "MailStatus": {
                "Value": data_update_simple['MailStatus']
            }
        }

        # call function test
        pm_userAttribute.update(data_insert['UserID'], data_update)

        # check data
        result = mock_pm_userAttribute.query_key(data_insert['UserID'])
        self.assertEqual(result['UserName'], data_update_simple['UserName'])
        self.assertEqual(result['CompanyName'],
                         data_update_simple['CompanyName'])
        self.assertEqual(result['DepartmentName'],
                         data_update_simple['DepartmentName'])
        self.assertEqual(result['CompanyFlg'],
                         data_update_simple['CompanyFlg'])
        self.assertEqual(result['CountryCode'],
                         data_update_simple['CountryCode'])
    def test_query_key(self):
        # prepare data
        data_insert = DataPmUserAttribute.DATA_SIMPLE
        mock_pm_userAttribute.create(data_insert)

        # call function test
        result = pm_userAttribute.query_key(data_insert['UserID'])

        # check data
        self.assertEqual(result['UserID'], data_insert['UserID'])
        self.assertEqual(result['UserName'], data_insert['UserName'])
        self.assertEqual(result['MailStatus'], data_insert['MailStatus'])
        self.assertEqual(result['CompanyName'], data_insert['CompanyName'])
        self.assertEqual(result['DepartmentName'],
                         data_insert['DepartmentName'])
        self.assertEqual(result['CompanyFlg'], data_insert['CompanyFlg'])
        self.assertEqual(result['CountryCode'], data_insert['CountryCode'])
        self.assertEqual(result['CallerServiceName'],
                         data_insert['CallerServiceName'])
        self.assertEqual(result['CreatedAt'], data_insert['CreatedAt'])
        self.assertEqual(result['UpdatedAt'], data_insert['UpdatedAt'])