예제 #1
0
 def test_sr_06_check_project_task_exists_fail(self):
     rd = copy.deepcopy(TEST_RESPONSE_DICT)
     rd["project_task_id"] = ARBITRARY_UUID
     survey_response = ep.SurveyResponse(response_dict=rd)
     with self.assertRaises(utils.ObjectDoesNotExistError) as context:
         survey_response.check_project_task_exists()
     err = context.exception
     err_msg = err.args[0]
     self.assertEqual(
         f"Project tasks id {ARBITRARY_UUID} not found in Thiscovery database",
         err_msg,
     )
예제 #2
0
 def test_sr_02_init_fail_invalid_uuid(self):
     for required_uuid_param in [
             "project_task_id",
             "anon_project_specific_user_id",
             "anon_user_task_id",
     ]:
         rd = copy.deepcopy(TEST_RESPONSE_DICT)
         rd[required_uuid_param] = "this-is-not-a-valid-uuid"
         with self.assertRaises(utils.DetailedValueError) as context:
             ep.SurveyResponse(response_dict=rd)
         err = context.exception
         err_msg = err.args[0]
         self.assertEqual("invalid uuid", err_msg)
예제 #3
0
 def test_sr_04_init_fail_required_attribute_is_an_empty_string(self):
     for required_param in list(TEST_RESPONSE_DICT.keys()):
         rd = copy.deepcopy(TEST_RESPONSE_DICT)
         rd[required_param] = ""
         with self.assertRaises(utils.DetailedValueError) as context:
             ep.SurveyResponse(response_dict=rd)
         err = context.exception
         err_msg = err.args[0]
         self.assertIn(
             err_msg,
             [
                 f"Required parameter {required_param} not present in body of call",
                 "invalid uuid",
             ],
         )
예제 #4
0
 def test_sr_03_init_fail_missing_required_attribute(self):
     for required_param in list(TEST_RESPONSE_DICT.keys()):
         rd = copy.deepcopy(TEST_RESPONSE_DICT)
         self.logger.debug(
             f"Working on required_param {required_param}",
             extra={"response_dict": rd},
         )
         del rd[required_param]
         with self.assertRaises(utils.DetailedValueError) as context:
             ep.SurveyResponse(response_dict=rd)
         err = context.exception
         err_msg = err.args[0]
         self.assertIn(
             err_msg,
             [
                 f"Required parameter {required_param} not present in body of call",
                 "invalid uuid",
             ],
         )
예제 #5
0
 def test_sr_01_init_ok(self):
     rd = copy.deepcopy(TEST_RESPONSE_DICT)
     survey_response = ep.SurveyResponse(response_dict=rd)
     self.assertIsInstance(survey_response, ep.SurveyResponse)
예제 #6
0
 def test_sr_07_put_item_ok(self):
     rd = copy.deepcopy(TEST_RESPONSE_DICT)
     survey_response = ep.SurveyResponse(response_dict=rd)
     ddb_response = survey_response.put_item()
     self.assertEqual(HTTPStatus.OK,
                      ddb_response["ResponseMetadata"]["HTTPStatusCode"])
예제 #7
0
 def test_sr_05_check_project_task_exists_ok(self):
     rd = copy.deepcopy(TEST_RESPONSE_DICT)
     survey_response = ep.SurveyResponse(response_dict=rd)
     self.assertTrue(survey_response.check_project_task_exists())