コード例 #1
0
    def testOrgPropertiesUpdated(self):
        """Tests that organization properties are updated properly."""
        org_properties = {'name': 'Other Program Name'}
        org_logic.updateOrganization(self.org, org_properties)

        # check that properties are updated
        org = ndb.Key(org_model.Organization._get_kind(), '%s/%s' %
                      (self.program.key().name(), TEST_ORG_ID)).get()
        self.assertEqual(org.name, 'Other Program Name')
コード例 #2
0
  def testOrgPropertiesUpdated(self):
    """Tests that organization properties are updated properly."""
    org_properties = {'name': 'Other Program Name'}
    org_logic.updateOrganization(self.org, org_properties)

    # check that properties are updated
    org = ndb.Key(
        org_model.Organization._get_kind(),
        '%s/%s' % (self.program.key().name(), TEST_ORG_ID)).get()
    self.assertEqual(org.name, 'Other Program Name')
コード例 #3
0
def updateOrganizationTxn(org_key, org_properties):
  """Updates the specified organization based on the specified properties.

  This function simply calls organization logic's function to do actual job
  but ensures that the entire operation is executed within a transaction.

  Args:
    org: Organization entity.
    org_properties: A dict containing properties to be updated.
  """
  org = org_key.get()
  org_logic.updateOrganization(org, org_properties)
コード例 #4
0
ファイル: org_app.py プロジェクト: rhyolight/nupic.son
def updateOrganizationTxn(org_key, org_properties):
    """Updates the specified organization based on the specified properties.

  This function simply calls organization logic's function to do actual job
  but ensures that the entire operation is executed within a transaction.

  Args:
    org: Organization entity.
    org_properties: A dict containing properties to be updated.
  """
    org = org_key.get()
    org_logic.updateOrganization(org, org_properties)
コード例 #5
0
    def testProgramInOrgProperties(self):
        """Tests that program cannot be updated."""
        org_properties = {'program': ndb.Key.from_old_key(self.program.key())}
        org_logic.updateOrganization(self.org, org_properties)

        # check that program has not changed
        org = ndb.Key(org_model.Organization._get_kind(), '%s/%s' %
                      (self.program.key().name(), TEST_ORG_ID)).get()
        self.assertEqual(org.program, ndb.Key.from_old_key(self.program.key()))

        org_properties = {'program': ndb.Key('Program', 'other_program')}
        with self.assertRaises(ValueError):
            org_logic.updateOrganization(self.org, org_properties)
コード例 #6
0
    def testOrgIdInOrgProperties(self):
        """Tests that org id cannot be updated."""
        org_properties = {'org_id': TEST_ORG_ID}
        org_logic.updateOrganization(self.org, org_properties)

        # check that identifier has not changed
        org = ndb.Key(org_model.Organization._get_kind(), '%s/%s' %
                      (self.program.key().name(), TEST_ORG_ID)).get()
        self.assertEqual(org.org_id, TEST_ORG_ID)

        org_properties = {'org_id': 'different_org_id'}
        with self.assertRaises(ValueError):
            org_logic.updateOrganization(self.org, org_properties)
コード例 #7
0
  def testProgramInOrgProperties(self):
    """Tests that program cannot be updated."""
    org_properties = {'program': ndb.Key.from_old_key(self.program.key())}
    org_logic.updateOrganization(self.org, org_properties)

    # check that program has not changed
    org = ndb.Key(
        org_model.Organization._get_kind(),
        '%s/%s' % (self.program.key().name(), TEST_ORG_ID)).get()
    self.assertEqual(org.program, ndb.Key.from_old_key(self.program.key()))

    org_properties = {'program': ndb.Key('Program', 'other_program')}
    with self.assertRaises(ValueError):
      org_logic.updateOrganization(self.org, org_properties)
コード例 #8
0
  def testOrgIdInOrgProperties(self):
    """Tests that org id cannot be updated."""
    org_properties = {'org_id': TEST_ORG_ID}
    org_logic.updateOrganization(self.org, org_properties)

    # check that identifier has not changed
    org = ndb.Key(
        org_model.Organization._get_kind(),
        '%s/%s' % (self.program.key().name(), TEST_ORG_ID)).get()
    self.assertEqual(org.org_id, TEST_ORG_ID)

    org_properties = {'org_id': 'different_org_id'}
    with self.assertRaises(ValueError):
      org_logic.updateOrganization(self.org, org_properties)