Example #1
0
    def testSubsequentBatches(self):
        """Tests that a next batch is returned when cached data is not valid."""
        orgs = org_logic.getAcceptedOrganizations(self.program.key())
        new_orgs = org_logic.getAcceptedOrganizations(self.program.key())

        # check that orgs returned by the second call are different
        self.assertNotEqual(set(org.key for org in orgs),
                            set(org.key for org in new_orgs))
Example #2
0
  def testSubsequentBatches(self):
    """Tests that a next batch is returned when cached data is not valid."""
    orgs = org_logic.getAcceptedOrganizations(self.program.key())
    new_orgs = org_logic.getAcceptedOrganizations(self.program.key())

    # check that orgs returned by the second call are different
    self.assertNotEqual(
        set(org.key for org in orgs), set(org.key for org in new_orgs))
Example #3
0
 def testAcceptedOrgsAreReturned(self):
     """Tests that function returns organization entities."""
     orgs = org_logic.getAcceptedOrganizations(self.program.key(),
                                               limit=TEST_ORGS_NUMBER)
     self.assertEqual(len(orgs), TEST_ORGS_NUMBER)
     self.assertSetEqual(set(org.status for org in orgs),
                         set([org_model.Status.ACCEPTED]))
Example #4
0
 def testAcceptedOrgsAreReturned(self):
   """Tests that function returns organization entities."""
   orgs = org_logic.getAcceptedOrganizations(
       self.program.key(), limit=TEST_ORGS_NUMBER)
   self.assertEqual(len(orgs), TEST_ORGS_NUMBER)
   self.assertSetEqual(
       set(org.status for org in orgs), set([org_model.Status.ACCEPTED]))
Example #5
0
    def testOrgsAreCached(self):
        """Tests that organizations are cached."""
        # get organizations for the first time
        stats = memcache.get_stats()
        orgs = org_logic.getAcceptedOrganizations(self.program.key())

        # check that orgs were not present in cache
        self.assertEqual(stats['hits'], memcache.get_stats()['hits'])
        self.assertEqual(stats['misses'] + 1, memcache.get_stats()['misses'])
        stats = memcache.get_stats()

        # get organizations for the second time
        new_orgs = org_logic.getAcceptedOrganizations(self.program.key())

        # check that orgs were present in cache
        self.assertSetEqual(set(org.key for org in orgs),
                            set(org.key for org in new_orgs))
        self.assertEqual(stats['hits'] + 1, memcache.get_stats()['hits'])
        self.assertEqual(stats['misses'], memcache.get_stats()['misses'])
Example #6
0
  def testOrgsAreCached(self):
    """Tests that organizations are cached."""
    # get organizations for the first time
    stats = memcache.get_stats()
    orgs = org_logic.getAcceptedOrganizations(self.program.key())

    # check that orgs were not present in cache
    self.assertEqual(stats['hits'], memcache.get_stats()['hits'])
    self.assertEqual(stats['misses'] + 1, memcache.get_stats()['misses'])
    stats = memcache.get_stats()

    # get organizations for the second time
    new_orgs = org_logic.getAcceptedOrganizations(self.program.key())

    # check that orgs were present in cache
    self.assertSetEqual(
        set(org.key for org in orgs), set(org.key for org in new_orgs))
    self.assertEqual(stats['hits'] + 1, memcache.get_stats()['hits'])
    self.assertEqual(stats['misses'], memcache.get_stats()['misses'])