Example #1
0
    def create_named_addon_with_author(self, name, author=None):
        """Create a generic addon and a user.

        The user will be created if a user is not given.

        """

        if author is None:
            author = user_factory()
        try:
            user = UserProfile.objects.create(username=author,
                                              email=f'{author}@email.com')
            user.update(id=settings.TASK_USER_ID)
        except Exception:  # django.db.utils.IntegrityError
            # If the user is already made, use that same user,
            # if not use created user
            addon = addon_factory(
                status=amo.STATUS_APPROVED,
                users=[UserProfile.objects.get(username=author)],
                name=u'{}'.format(name),
                slug=u'{}'.format(name),
                recommended=True,
                version_kw={'nomination': days_ago(6)})
            addon.save()
        else:
            author.update(id=settings.TASK_USER_ID)
            addon = addon_factory(
                status=amo.STATUS_APPROVED,
                users=[UserProfile.objects.get(username=author.username)],
                name=u'{}'.format(name),
                slug=u'{}'.format(name),
                recommended=True,
                version_kw={'nomination': days_ago(6)})
            addon.save()
        return addon
Example #2
0
 def setUp(self):
     user_factory(
         id=settings.TASK_USER_ID, username='******',
         email='*****@*****.**')
     self.addons = [
         addon_factory(average_daily_users=666, users=[user_factory()]),
         addon_factory(average_daily_users=999, users=[user_factory()]),
     ]
     self.versions = [
         version_factory(
             addon=self.addons[0], file_kw={
                 'status': amo.STATUS_AWAITING_REVIEW,
                 'is_webextension': True}),
         version_factory(
             addon=self.addons[1], file_kw={
                 'status': amo.STATUS_AWAITING_REVIEW,
                 'is_webextension': True}),
     ]
     self.files = [
         self.versions[0].all_files[0],
         self.versions[1].all_files[0],
     ]
     self.versions[0].update(nomination=days_ago(1))
     FileValidation.objects.create(
         file=self.versions[0].all_files[0], validation=u'{}')
     FileValidation.objects.create(
         file=self.versions[1].all_files[0], validation=u'{}')
     super(TestAutoApproveCommandTransactions, self).setUp()
Example #3
0
    def create_featured_theme(self):
        """Creates a custom theme named 'Ui-Test Theme'.

        This theme will be a featured theme and will belong to the uitest user.

        It has one author.

        """
        addon = addon_factory(
            status=amo.STATUS_APPROVED,
            type=ADDON_STATICTHEME,
            average_daily_users=4242,
            users=[self.user],
            average_rating=5,
            description='My UI Theme description',
            file_kw={'is_webextension': True},
            guid=generate_addon_guid(),
            homepage='https://www.example.org/',
            name='Ui-Test Theme',
            slug='ui-test',
            summary='My UI theme summary',
            support_email='*****@*****.**',
            support_url='https://support.example.org/support/ui-theme-addon/',
            tags=[
                'some_tag', 'another_tag', 'ui-testing', 'selenium', 'python'
            ],
            total_ratings=777,
            weekly_downloads=123456,
            developer_comments='This is a testing theme, used within pytest.',
            version_kw={'nomination': days_ago(6)},
            promoted=RECOMMENDED,
        )
        addon.save()
        generate_collection(addon, app=FIREFOX)
        print('Created Theme {0} for testing successfully'.format(addon.name))
Example #4
0
    def create_featured_addon_with_version_for_install(self):
        """Creates a custom addon named 'Ui-Addon'.

        This addon will be a featured addon and will have a featured collecton
        attatched to it. It will belong to the user uitest.

        It has 1 preview, 5 reviews, and 2 authors. The second author is named
        'ui-tester2'. It has a version number.

        """
        try:
            addon = Addon.objects.get(guid='@webextension-guid')
        except Addon.DoesNotExist:
            addon = addon_factory(
                file_kw=False,
                average_daily_users=5000,
                users=[self.user],
                average_rating=5,
                description='My Addon description',
                guid='@webextension-guid',
                name='Ui-Addon-Install',
                slug='ui-test-install',
                summary='My Addon summary',
                tags=['some_tag', 'another_tag', 'ui-testing', 'selenium', 'python'],
                weekly_downloads=9999999,
                developer_comments='This is a testing addon.',
                version_kw={'nomination': days_ago(6)},
                promoted=RECOMMENDED,
            )
            addon.save()
            generate_collection(addon, app=FIREFOX)
            print(f'Created addon {addon.name} for testing successfully')
        return addon
 def setUp(self):
     user_factory(id=settings.TASK_USER_ID,
                  username='******',
                  email='*****@*****.**')
     self.addons = [
         addon_factory(average_daily_users=666, users=[user_factory()]),
         addon_factory(average_daily_users=999, users=[user_factory()]),
     ]
     self.versions = [
         version_factory(addon=self.addons[0],
                         file_kw={
                             'status': amo.STATUS_AWAITING_REVIEW,
                             'is_webextension': True
                         }),
         version_factory(addon=self.addons[1],
                         file_kw={
                             'status': amo.STATUS_AWAITING_REVIEW,
                             'is_webextension': True
                         }),
     ]
     self.files = [
         self.versions[0].all_files[0],
         self.versions[1].all_files[0],
     ]
     self.versions[0].update(nomination=days_ago(1))
     FileValidation.objects.create(file=self.versions[0].all_files[0],
                                   validation=u'{}')
     FileValidation.objects.create(file=self.versions[1].all_files[0],
                                   validation=u'{}')
     super(TestAutoApproveCommandTransactions, self).setUp()
Example #6
0
 def create_generic_featured_themes(self):
     for _ in range(10):
         addon = addon_factory(status=amo.STATUS_APPROVED,
                               type=ADDON_STATICTHEME,
                               recommended=True,
                               version_kw={'nomination': days_ago(6)})
         generate_version(addon=addon)
         addon.update_version()
Example #7
0
 def create_generic_featured_themes(self):
     for _ in range(10):
         addon = addon_factory(status=amo.STATUS_APPROVED,
                               type=ADDON_PERSONA,
                               version_kw={
                                   'recommendation_approved': True,
                                   'nomination': days_ago(6)
                               })
         generate_version(addon=addon)
         addon.update_version()
         DiscoveryItem.objects.create(recommendable=True, addon=addon)
Example #8
0
    def create_featured_addon_with_version(self):
        """Creates a custom addon named 'Ui-Addon'.

        This addon will be a featured addon and will have a featured collecton
        attatched to it. It will belong to the user uitest.

        It has 1 preview, 5 reviews, and 2 authors. The second author is named
        'ui-tester2'. It has a version number.

        """
        default_icons = [x[0] for x in icons() if x[0].startswith('icon/')]
        addon = addon_factory(status=amo.STATUS_APPROVED,
                              type=ADDON_EXTENSION,
                              average_daily_users=5000,
                              users=[self.user],
                              average_rating=5,
                              description=u'My Addon description',
                              file_kw={'is_webextension': True},
                              guid=generate_addon_guid(),
                              icon_type=random.choice(default_icons),
                              name=u'Ui-Addon',
                              public_stats=True,
                              slug='ui-test-2',
                              summary=u'My Addon summary',
                              tags=[
                                  'some_tag', 'another_tag', 'ui-testing',
                                  'selenium', 'python'
                              ],
                              total_ratings=500,
                              weekly_downloads=9999999,
                              developer_comments='This is a testing addon.',
                              version_kw={
                                  'recommendation_approved': True,
                                  'nomination': days_ago(6)
                              })
        Preview.objects.create(addon=addon, position=1)
        Rating.objects.create(addon=addon, rating=5, user=user_factory())
        Rating.objects.create(addon=addon, rating=5, user=user_factory())
        Rating.objects.create(addon=addon, rating=5, user=user_factory())
        Rating.objects.create(addon=addon, rating=5, user=user_factory())
        Rating.objects.create(addon=addon, rating=5, user=user_factory())
        Rating.objects.create(addon=addon, rating=5, user=user_factory())
        Rating.objects.create(addon=addon, rating=5, user=user_factory())
        Rating.objects.create(addon=addon, rating=5, user=user_factory())
        AddonUser.objects.create(user=user_factory(username='******'),
                                 addon=addon,
                                 listed=True)
        addon.save()
        DiscoveryItem.objects.create(recommendable=True, addon=addon)
        generate_collection(addon, app=FIREFOX)
        print('Created addon {0} for testing successfully'.format(addon.name))
Example #9
0
    def create_generic_featured_addons(self):
        """Creates 10 addons.

        Creates exactly 10 random addons with users that are also randomly
        generated.

        """
        for _ in range(10):
            addon = addon_factory(status=amo.STATUS_APPROVED,
                                  version_kw={
                                      'recommendation_approved': True,
                                      'nomination': days_ago(6)
                                  })
            AddonUser.objects.create(user=user_factory(), addon=addon)
            DiscoveryItem.objects.create(recommendable=True, addon=addon)
Example #10
0
    def create_featured_themes(self):
        """Creates exactly 6 themes that will be not featured.

        These belong to the user uitest.

        It will also create 6 themes that are featured with random authors.

        """
        for _ in range(6):
            addon = addon_factory(recommended=True,
                                  status=amo.STATUS_APPROVED,
                                  type=ADDON_STATICTHEME,
                                  file_kw={'is_webextension': True},
                                  version_kw={'nomination': days_ago(6)})
            generate_collection(addon, type=amo.COLLECTION_RECOMMENDED)
Example #11
0
    def create_featured_themes(self):
        """Creates exactly 6 themes that will be not featured.

        These belong to the user uitest.

        It will also create 6 themes that are featured with random authors.

        """
        for _ in range(6):
            addon = addon_factory(
                status=amo.STATUS_APPROVED,
                type=ADDON_STATICTHEME,
                version_kw={'nomination': days_ago(6)},
                promoted=RECOMMENDED,
            )
            generate_collection(addon)
Example #12
0
    def create_featured_android_addon(self):
        """Creates a custom addon named 'Ui-Addon-Android'.

        This addon will be a featured addon and will have a featured collecton
        attatched to it. It will belong to the user uitest.

        It has 1 preview, 2 reviews, and 1 authors.

        It is an Android addon.

        """
        addon = addon_factory(
            status=amo.STATUS_APPROVED,
            type=ADDON_EXTENSION,
            average_daily_users=5656,
            users=[self.user],
            average_rating=5,
            description='My Addon description about ANDROID',
            file_kw={'is_webextension': True},
            guid=generate_addon_guid(),
            name='Ui-Addon-Android',
            slug='ui-test-addon-android',
            summary='My Addon summary for Android',
            tags=[
                'some_tag',
                'another_tag',
                'ui-testing',
                'selenium',
                'python',
                'android',
            ],
            total_ratings=500,
            weekly_downloads=9999999,
            developer_comments='This is a testing addon for Android.',
            version_kw={'nomination': days_ago(6)},
            promoted=RECOMMENDED,
        )
        Preview.objects.create(addon=addon, position=1)
        Rating.objects.create(addon=addon, rating=5, user=user_factory())
        Rating.objects.create(addon=addon, rating=5, user=user_factory())
        AddonUser.objects.create(user=user_factory(username='******'),
                                 addon=addon,
                                 listed=True)
        addon.save()
        generate_collection(addon, app=FIREFOX)
        print('Created addon {0} for testing successfully'.format(addon.name))
Example #13
0
    def create_generic_featured_addons(self):
        """Creates 10 addons.

        Creates exactly 10 random addons with users that are also randomly
        generated.

        """
        for _ in range(10):
            addon = addon_factory(status=amo.STATUS_APPROVED,
                                  recommended=True,
                                  version_kw={'nomination': days_ago(6)})
            AddonUser.objects.create(user=user_factory(), addon=addon)

            PrimaryHero.objects.create(disco_addon=addon.discoveryitem,
                                       enabled=True)
            SecondaryHero.objects.create(enabled=True,
                                         headline="This is a headline",
                                         description="Hero Description")
Example #14
0
    def create_featured_themes(self):
        """Creates exactly 6 themes that will be not featured.

        These belong to the user uitest.

        It will also create 6 themes that are featured with random authors.

        """
        for _ in range(6):
            addon = addon_factory(status=amo.STATUS_APPROVED,
                                  type=ADDON_PERSONA,
                                  file_kw={'is_webextension': True},
                                  version_kw={
                                      'recommendation_approved': True,
                                      'nomination': days_ago(6)
                                  })
            DiscoveryItem.objects.create(recommendable=True, addon=addon)
            generate_collection(addon, type=amo.COLLECTION_RECOMMENDED)
Example #15
0
    def create_featured_addon_with_version(self):
        """Creates a custom addon named 'Ui-Addon'.

        This addon will be a featured addon and will have a featured collecton
        attatched to it. It will belong to the user uitest.

        It has 1 preview, 5 reviews, and 2 authors. The second author is named
        'ui-tester2'. It has a version number.

        """
        addon = addon_factory(
            status=amo.STATUS_APPROVED,
            type=ADDON_EXTENSION,
            average_daily_users=5000,
            users=[self.user],
            average_rating=5,
            description='My Addon description',
            guid=generate_addon_guid(),
            name='Ui-Addon',
            slug='ui-test-2',
            summary='My Addon summary',
            tags=['some_tag', 'another_tag', 'ui-testing', 'selenium', 'python'],
            total_ratings=500,
            weekly_downloads=9999999,
            developer_comments='This is a testing addon.',
            version_kw={'nomination': days_ago(6)},
            promoted=RECOMMENDED,
        )
        Preview.objects.create(addon=addon, position=1)
        Rating.objects.create(addon=addon, rating=5, user=user_factory())
        Rating.objects.create(addon=addon, rating=5, user=user_factory())
        Rating.objects.create(addon=addon, rating=5, user=user_factory())
        Rating.objects.create(addon=addon, rating=5, user=user_factory())
        Rating.objects.create(addon=addon, rating=5, user=user_factory())
        Rating.objects.create(addon=addon, rating=5, user=user_factory())
        Rating.objects.create(addon=addon, rating=5, user=user_factory())
        Rating.objects.create(addon=addon, rating=5, user=user_factory())
        AddonUser.objects.create(
            user=user_factory(username='******'), addon=addon, listed=True
        )
        addon.save()
        generate_collection(addon, app=FIREFOX)
        print(f'Created addon {addon.name} for testing successfully')
Example #16
0
    def create_featured_addon_with_version_for_install(self):
        """Creates a custom addon named 'Ui-Addon'.

        This addon will be a featured addon and will have a featured collecton
        attatched to it. It will belong to the user uitest.

        It has 1 preview, 5 reviews, and 2 authors. The second author is named
        'ui-tester2'. It has a version number.

        """
        default_icons = [x[0] for x in icons() if x[0].startswith('icon/')]
        try:
            addon = Addon.objects.get(guid='@webextension-guid')
        except Addon.DoesNotExist:
            addon = addon_factory(
                file_kw=False,
                average_daily_users=5000,
                users=[self.user],
                average_rating=5,
                description=u'My Addon description',
                guid='@webextension-guid',
                icon_type=random.choice(default_icons),
                name=u'Ui-Addon-Install',
                public_stats=True,
                slug='ui-test-install',
                summary=u'My Addon summary',
                tags=[
                    'some_tag', 'another_tag', 'ui-testing', 'selenium',
                    'python'
                ],
                weekly_downloads=9999999,
                developer_comments='This is a testing addon.',
                version_kw={
                    'recommendation_approved': True,
                    'nomination': days_ago(6)
                },
            )
            addon.save()
            generate_collection(addon, app=FIREFOX)
            DiscoveryItem.objects.create(recommendable=True, addon=addon)
            print('Created addon {0} for testing successfully'.format(
                addon.name))
        return addon
Example #17
0
    def create_generic_featured_addons(self):
        """Creates 10 addons.

        Creates exactly 10 random addons with users that are also randomly
        generated.

        """
        for _ in range(10):
            addon = addon_factory(
                status=amo.STATUS_APPROVED,
                version_kw={'nomination': days_ago(6)},
                promoted=RECOMMENDED,
            )
            AddonUser.objects.create(user=user_factory(), addon=addon)

            PrimaryHero.objects.create(promoted_addon=addon.promotedaddon, enabled=True)
            SecondaryHero.objects.create(
                enabled=True,
                headline='This is a headline',
                description='Hero Description',
            )
Example #18
0
    def create_generic_featured_addons(self):
        """Creates 10 addons.

        Creates exactly 10 random addons with users that are also randomly
        generated.

        """
        for _ in range(10):
            addon = addon_factory(status=amo.STATUS_APPROVED,
                                  version_kw={
                                      'recommendation_approved': True,
                                      'nomination': days_ago(6)
                                  })
            AddonUser.objects.create(user=user_factory(), addon=addon)
            item = DiscoveryItem.objects.create(addon=addon,
                                                recommendable=True)

            PrimaryHero.objects.create(disco_addon=item)
            SecondaryHero.objects.create(enabled=True,
                                         headline="This is a headline",
                                         description="Hero Description")
            item.addon.current_version.update(recommendation_approved=True)
            item.primaryhero.update(enabled=True)