def test__filter_participant_by_campaign_id(self): # Arrange other_campaign = create_campaign(name="OtherCampaign") create_participation(other_campaign, player=self.player) participant_queryset = Participation.manager.all() # Act response_queryset = ParticipationFilter().filter_campaigns(participant_queryset, str(other_campaign.id)) # Assert self.assertEqual(response_queryset.count(), 1)
def test__filter_participant_by_country_code(self): # Arrange create_participation(self.campaign, country_code="US", player=self.player) create_participation(self.campaign, country_code="BR", player=create_device_user()) participant_queryset = Participation.manager.all() # Act response_queryset = ParticipationFilter().filter_location_country_codes(participant_queryset, "US") # Assert self.assertEqual(participant_queryset.count(), 2) self.assertEqual(response_queryset.count(), 1)
def test__filter_player_by_last_date_played_using_end_date__two_players_dates_after_end_date__0( self): # Arrange game = create_game() campaign = create_campaign() last_time_played_after_end_date_1 = datetime(2016, 10, 25, 14, 46, 58, 28310, tzinfo=utc) last_time_played_after_end_date_2 = datetime(2016, 11, 25, 14, 46, 58, 28310, tzinfo=utc) end_date_period_consult = datetime(2016, 5, 25, 14, 46, 58, 28310, tzinfo=utc) player_1 = create_device_user( game=game, last_date_played=last_time_played_after_end_date_1) player_2 = create_device_user( game=game, last_date_played=last_time_played_after_end_date_2) create_participation(campaign=campaign, player=player_1) create_participation(campaign=campaign, player=player_2) device_user_queryset = Participation.manager.all() # Act response_query_set = ParticipationFilter().filter_end_date( device_user_queryset, str(end_date_period_consult)) # Assert self.assertEqual(response_query_set.count(), 0)