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)
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)
def testForProgramWithNoDefinedSchools(self): """Tests for program that has no predefined schools.""" school_map = school_logic.getMappedByCountries(self.program) self.assertDictEqual(school_map, {})