'If `should_update` is True, assert that the team and team
membership have had their `last_activity_at` updated. Otherwise,
assert that it was not updated.'

@contextmanager
def assert_last_activity_updated(self, should_update):

    team_last_activity = self.team.last_activity_at
    team_membership_last_activity = self.team_membership.last_activity_at
    (yield)
    team = CourseTeam.objects.get(id=self.team.id)
    team_membership = CourseTeamMembership.objects.get(id=self.team_membership.id)
    if should_update:
        self.assertGreater(team.last_activity_at, team_last_activity)
        self.assertGreater(team_membership.last_activity_at, team_membership_last_activity)
        now = datetime.utcnow().replace(tzinfo=pytz.utc)
        self.assertGreater(now, team.last_activity_at)
        self.assertGreater(now, team_membership.last_activity_at)
        self.assert_event_emitted('edx.team.activity_updated', team_id=team.team_id)
    else:
        self.assertEqual(team.last_activity_at, team_last_activity)
        self.assertEqual(team_membership.last_activity_at, team_membership_last_activity)
        self.assert_no_events_were_emitted()
