def test_creating_user_caches_rel_count(self): team = Team.create(name="Team", captain_id="User_cap", program_id=self.program.uid) user = User.create(email="*****@*****.**", owned_teams=[team.uid]) team.put() # Populate memcache with the team's original value of 0 users. cached = Team.update_cached_properties(team.uid) # This should trigger a memcache update. user.put() cached = memcache.get(util.cached_properties_key(team.uid)) self.assertEqual(cached['num_users'], 1) # Should see the same count on object. self.assertEqual(team.to_client_dict()['num_users'], 1) return (team, user)
def test_creating_classroom_caches_rel_count(self): team = Team.create(name="Team", captain_id="User_cap", program_id=self.program.uid) classroom = Classroom.create( name="Class Foo", code='trout viper', team_id=team.uid, contact_id='User_contact', ) team.put() # Populate memcache with the team's original value of 0 classrooms. cached = Team.update_cached_properties(team.uid) # This should trigger a memcache update. classroom.put() cached = memcache.get(util.cached_properties_key(team.uid)) self.assertEqual(cached['num_classrooms'], 1) # Should see the same count on object. self.assertEqual(team.to_client_dict()['num_classrooms'], 1) return (team, classroom)