def testApplicationUpdated(self): """Tests that application is updated if it has existed.""" # seed organization application org_utils.seedApplication(self.org.key, self.survey_key, **TEST_APPLICATION_PROPERTIES) # set new answers to both questions properties = { FOO_ID: OTHER_TEST_FOO_ANSWER, BAR_ID: OTHER_TEST_BAR_ANSWER } application = org_logic.setApplicationResponse(self.org.key, self.survey_key, properties) # check that responses are updated properly self.assertEqual(application.foo, properties[FOO_ID]) self.assertEqual(application.bar, properties[BAR_ID]) # set answer to only one question properties = {FOO_ID: TEST_FOO_ANSWER} application = org_logic.setApplicationResponse(self.org.key, self.survey_key, properties) # check that the response for one question is updated and there is # no response for the other question self.assertEqual(application.foo, properties[FOO_ID]) self.assertNotIn(BAR_ID, application._properties.keys()) # set new answers to both questions again properties = { FOO_ID: OTHER_TEST_FOO_ANSWER, BAR_ID: OTHER_TEST_BAR_ANSWER } application = org_logic.setApplicationResponse(self.org.key, self.survey_key, properties) # check that responses are present for both questions self.assertEqual(application.foo, properties[FOO_ID]) self.assertEqual(application.bar, properties[BAR_ID])
def testApplicationUpdated(self): """Tests that application is updated if it has existed.""" # seed organization application org_utils.seedApplication( self.org.key, self.survey_key, **TEST_APPLICATION_PROPERTIES) # set new answers to both questions properties = { FOO_ID: OTHER_TEST_FOO_ANSWER, BAR_ID: OTHER_TEST_BAR_ANSWER } application = org_logic.setApplicationResponse( self.org.key, self.survey_key, properties) # check that responses are updated properly self.assertEqual(application.foo, properties[FOO_ID]) self.assertEqual(application.bar, properties[BAR_ID]) # set answer to only one question properties = {FOO_ID: TEST_FOO_ANSWER} application = org_logic.setApplicationResponse( self.org.key, self.survey_key, properties) # check that the response for one question is updated and there is # no response for the other question self.assertEqual(application.foo, properties[FOO_ID]) self.assertNotIn(BAR_ID, application._properties.keys()) # set new answers to both questions again properties = { FOO_ID: OTHER_TEST_FOO_ANSWER, BAR_ID: OTHER_TEST_BAR_ANSWER } application = org_logic.setApplicationResponse( self.org.key, self.survey_key, properties) # check that responses are present for both questions self.assertEqual(application.foo, properties[FOO_ID]) self.assertEqual(application.bar, properties[BAR_ID])
def setUp(self): """See unittest.TestCase.setUp for specification.""" sponsor = program_utils.seedSponsor() program = program_utils.seedProgram(sponsor_key=sponsor.key()) self.survey = program_utils.seedApplicationSurvey(program.key()) # seed some organizations with survey responses self.app_responses = set() for _ in range(TEST_ORGS_NUMBER): org = org_utils.seedOrganization(program.key()) self.app_responses.add( org_utils.seedApplication(org.key, self.survey.key()).key) # seed some organizations without survey responses for _ in range(TEST_ORGS_NUMBER): org_utils.seedOrganization(program.key()) other_program = program_utils.seedProgram(sponsor_key=sponsor.key()) other_survey = program_utils.seedApplicationSurvey(other_program.key()) # seed some organizations with survey responses for other survey for _ in range(TEST_ORGS_NUMBER): org = org_utils.seedOrganization(other_program.key()) org_utils.seedApplication(org.key, other_survey.key())