def test_creating_user_caches_rel_count(self):
        org = Organization.create(name="Organization", captain_id="User_cap",
                                  program_id=self.ep_program.uid)
        user = User.create(email="*****@*****.**", owned_organizations=[org.uid])
        org.put()

        # Populate memcache with the org's original value of 0 users.
        cached = Organization.update_cached_properties(org.uid)

        # This should trigger a memcache update.
        user.put()
        cached = memcache.get(util.cached_properties_key(org.uid))
        self.assertEqual(cached['num_users'], 1)

        # Should see the same count on object.
        self.assertEqual(org.to_client_dict()['num_users'], 1)

        return (org, user)
    def test_creating_team_caches_rel_count(self):
        org = Organization.create(name="Organization", captain_id="User_cap",
                                  program_id=self.ep_program.uid)
        team = Team.create(
            name="Team Foo", captain_id='User_cap', organization_ids=[org.uid],
            program_id=self.ep_program.uid,
        )
        org.put()

        # Populate memcache with the org's original value of 0 teams.
        cached = Organization.update_cached_properties(org.uid)

        # This should trigger a memcache update.
        team.put()
        cached = memcache.get(util.cached_properties_key(org.uid))
        self.assertEqual(cached['num_teams'], 1)

        # Should see the same count on object.
        self.assertEqual(org.to_client_dict()['num_teams'], 1)

        return (org, team)