Example #1
0
    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])
Example #2
0
    def testApplicationCreated(self):
        """Tests that application is created when it does not exist."""
        application = org_logic.setApplicationResponse(
            self.org.key, self.survey_key, TEST_APPLICATION_PROPERTIES)

        # check that application is persisted
        self.assertIsNotNone(application.key.get())

        # check that responses are stored in the entity
        self.assertEqual(application.foo, TEST_APPLICATION_PROPERTIES[FOO_ID])
        self.assertEqual(application.bar, TEST_APPLICATION_PROPERTIES[BAR_ID])
Example #3
0
  def testApplicationCreated(self):
    """Tests that application is created when it does not exist."""
    application = org_logic.setApplicationResponse(
        self.org.key, self.survey_key, TEST_APPLICATION_PROPERTIES)

    # check that application is persisted
    self.assertIsNotNone(application.key.get())

    # check that responses are stored in the entity
    self.assertEqual(application.foo, TEST_APPLICATION_PROPERTIES[FOO_ID])
    self.assertEqual(application.bar, TEST_APPLICATION_PROPERTIES[BAR_ID])
Example #4
0
def setApplicationResponse(org_key, survey_key, properties):
  """Sets the specified properties for application of
  the specified organization.

  Args:
    org_key: Organization key.
    properties: A dict mapping organization application questions to
      corresponding responses.

  Returns:
    survey_model.SurveyResponse entity associated the application.
  """
  return org_logic.setApplicationResponse(org_key, survey_key, properties)
Example #5
0
  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])
Example #6
0
def setApplicationResponse(org_key, survey_key, properties):
    """Sets the specified properties for application of
  the specified organization.

  Args:
    org_key: Organization key.
    properties: A dict mapping organization application questions to
      corresponding responses.

  Returns:
    survey_model.SurveyResponse entity associated the application.
  """
    return org_logic.setApplicationResponse(org_key, survey_key, properties)