示例#1
0
  def testMemcacheUsage(self, mock_func):
    """Tests that memcache is used to help to get predefined schools."""
    self.program.schools = 'mock key'

    # check that schools are not found in cache by the first call
    school_logic.getMappedByCountries(self.program)

    stats = memcache.get_stats()
    self.assertEqual(stats['misses'], 1)
    self.assertEqual(stats['hits'], 0)

    # check that schools are found in cache by the second call
    school_logic.getMappedByCountries(self.program)

    stats = memcache.get_stats()
    self.assertEqual(stats['misses'], 1)
    self.assertEqual(stats['hits'], 1)
示例#2
0
 def testForProgramWithDefinedSchools(self, mock_func):
   """Tests for program that has predefined schools."""
   self.program.schools = 'mock key'
   school_map = school_logic.getMappedByCountries(self.program)
   self.assertDictEqual(school_map, EXPECTED_SCHOOL_MAP)
示例#3
0
 def testForProgramWithNoDefinedSchools(self):
   """Tests for program that has no predefined schools."""
   school_map = school_logic.getMappedByCountries(self.program)
   self.assertDictEqual(school_map, {})