Example #1
0
 def test__filter_closed_campaign__the_boolean_false__all_closed_campaigns(
         self):
     # Arrange
     campaign_queryset = Campaign.manager.all()
     # Act
     response_queryset = CampaignFilter().filter_opened(
         campaign_queryset, False)
     # Assert
     self.assertEqual(response_queryset.count(), 1)
Example #2
0
 def test__filter_campaign_by_name__the_campaigns_ids__campaign_with_id_number_one(
         self):
     # Arrange
     campaign_queryset = Campaign.manager.all()
     # Act
     response_queryset = CampaignFilter().filter_campaigns(
         campaign_queryset, "1")
     # Assert
     self.assertEqual(response_queryset.count(), 1)
Example #3
0
 def test__filter_campaign_by_name__the_string_fak__campaigns_filtered_by_name_fak(
         self):
     # Arrange
     campaign_queryset = Campaign.manager.all()
     # Act
     response_queryset = CampaignFilter().filter_all(
         campaign_queryset, "Fak")
     # Assert
     self.assertEqual(response_queryset.count(), 1)
Example #4
0
 def test__filter_campaign_by_country_code_to_mobile__the_Mayotte_country_code__all_campaigns_in_Mayotte(
         self):
     # Arrange
     self.campaign.regions = Region.manager.filter(name="Mayotte")
     banner_queryset = Campaign.manager.all()
     # Act
     response_queryset = CampaignFilter().filter_country_code(
         banner_queryset, "YT")
     # Assert
     self.assertEqual(response_queryset.count(), 1)
Example #5
0
 def test__filter_campaign_by_game_name__the_string_zenny__aal_campaigns_with_zenny_game(
         self):
     # Arrange
     create_forms(self.campaign, create_game())
     campaign_queryset = Campaign.manager.all()
     # Act
     response_queryset = CampaignFilter().filter_all(
         campaign_queryset, "zenny")
     # Assert
     self.assertEqual(response_queryset.count(), 1)
Example #6
0
    def test__filter_campaign_by_status__the_param_disable__all_disable_campaigns(
            self):
        # Arrange
        create_campaign(name="To Start Campaign",
                        begin_date="2050-02-16 17:53")
        create_campaign(name="Finished campaign", end_date="2016-02-16 17:54")

        campaign_queryset = Campaign.manager.all()
        # Act
        response_queryset = CampaignFilter().filter_status(
            campaign_queryset, "paused")
        # Assert
        self.assertEqual(response_queryset.count(), 1)
Example #7
0
    def test__filter_campaign_by_nonexisting_param__the_wrong_param___all_campaigns(
            self):
        # Arrange
        create_campaign(name="To Start Campaign",
                        begin_date="2050-02-16 17:53")
        create_campaign(name="Finished campaign", end_date="2016-02-16 17:54")

        campaign_queryset = Campaign.manager.all()
        # Act
        response_queryset = CampaignFilter().filter_status(
            campaign_queryset, "nonexitent_param")
        # Assert
        self.assertEqual(response_queryset.count(), campaign_queryset.count())
Example #8
0
    def test__filter_campaigns_by_games__the_games_ids__all_campaigns_with_games_zenny_and_blaster_boy(
            self):
        # Arrange
        zenny = create_game("Zenny Worldz")
        blaster_boy = create_game("Blaster Boy")
        create_forms(create_campaign(name="ZennyCampaign"), zenny)
        create_forms(create_campaign(name="OtherZennyCampaign"), zenny)
        create_forms(create_campaign(name="BlasterBoyCampaign"), blaster_boy)

        campaign_queryset = Campaign.manager.all()
        # Act
        response_queryset = CampaignFilter().filter_games(
            campaign_queryset, "1,2")
        # Assert
        self.assertEqual(response_queryset.count(), 3)
Example #9
0
    def test__filter_campaigns_by_regions__the_country_codes__all_campaigns_in_Germany_and_Argentina(
            self):
        # Arrange
        brazil_campaign = create_campaign(name="Brazil Campaign")
        germany_campaign = create_campaign(name="Germany Campaign")
        argentina_campaign = create_campaign(name="Argentina Campaign")

        brazil_campaign.regions = [Region.manager.get(name="Brazil")]
        germany_campaign.regions = [Region.manager.get(name="Germany")]
        argentina_campaign.regions = [Region.manager.get(name="Argentina")]

        campaign_queryset = Campaign.manager.all()
        # Act
        response_queryset = CampaignFilter().filter_regions(
            campaign_queryset, "BR,AR")
        # Assert
        self.assertEqual(response_queryset.count(), 2)
Example #10
0
    def get(self, request, service_id=None):
        try:
            get_object_or_404(Game.manager.all(), game_service_id=service_id)
        except Http404:
            raise GameDoesNotExist()

        environment_info = Header.get_environment_info(request)
        location_serializer = EnvironmentInfoSerializer(data=environment_info)
        location_serializer.is_valid(raise_exception=True)
        location = location_serializer.data

        data = request.data.copy()
        data[Field.FORMS__GAME__GAME_SERVICE_ID] = service_id
        data[Field.OPENED] = True
        data[Field.COUNTRY_CODE] = location[Field.LOCATION_COUNTRY_CODE]

        filterset = CampaignFilter(data, queryset=Campaign.manager.all())
        serializer = OpenedCampaignMobileSerializer(filterset, many=True)

        return ResponseUtils.ok(serializer.data)