Example #1
0
    def test_add_static_theme_from_lwt(self):
        author = user_factory()
        persona = addon_factory(type=amo.ADDON_PERSONA,
                                users=[author],
                                name='Firefox Theme')
        persona.update(created=self.create_date,
                       modified=self.modify_date,
                       last_updated=self.update_date)
        persona.persona.license = licenses.LICENSE_CC_BY_ND.id
        Tag.objects.create(tag_text='themey').save_tag(persona)
        License.objects.create(builtin=licenses.LICENSE_CC_BY_ND.builtin)
        rating_user = user_factory()
        rating = Rating.objects.create(addon=persona,
                                       version=persona.current_version,
                                       user=rating_user,
                                       rating=2,
                                       body=u'fooooo',
                                       user_responsible=rating_user)
        ThemeUpdateCount.objects.create(addon_id=persona.id,
                                        date=datetime(2018, 1, 1),
                                        count=123)
        ThemeUpdateCount.objects.create(addon_id=persona.id,
                                        date=datetime(2018, 2, 1),
                                        count=456)
        # Create a count for an addon that shouldn't be migrated too.
        ThemeUpdateCount.objects.create(addon_id=addon_factory().id,
                                        date=datetime(2018, 2, 1),
                                        count=45)

        static_theme = add_static_theme_from_lwt(persona)

        self._check_result(static_theme, [author], list(persona.tags.all()),
                           persona.all_categories,
                           licenses.LICENSE_CC_BY_ND.builtin, [rating])
Example #2
0
    def test_add_static_theme_from_lwt(self):
        author = user_factory()
        persona = addon_factory(
            type=amo.ADDON_PERSONA, users=[author], name='Firefox Theme')
        persona.update(
            created=self.create_date, modified=self.modify_date,
            last_updated=self.update_date)
        persona.persona.license = licenses.LICENSE_CC_BY_ND.id
        Tag.objects.create(tag_text='themey').save_tag(persona)
        License.objects.create(builtin=licenses.LICENSE_CC_BY_ND.builtin)
        rating_user = user_factory()
        rating = Rating.objects.create(
            addon=persona, version=persona.current_version, user=rating_user,
            rating=2, body=u'fooooo', user_responsible=rating_user)
        ThemeUpdateCount.objects.create(
            addon_id=persona.id, date=datetime(2018, 1, 1), count=123)
        ThemeUpdateCount.objects.create(
            addon_id=persona.id, date=datetime(2018, 2, 1), count=456)
        # Create a count for an addon that shouldn't be migrated too.
        ThemeUpdateCount.objects.create(
            addon_id=addon_factory().id, date=datetime(2018, 2, 1), count=45)
        # And add it to a collection
        collection = collection_factory()
        collection.add_addon(persona)
        collection.add_addon(addon_factory())

        static_theme = add_static_theme_from_lwt(persona)

        self._check_result(
            static_theme, [author], list(persona.tags.all()),
            persona.all_categories, licenses.LICENSE_CC_BY_ND.builtin,
            [rating], collection)
Example #3
0
    def test_add_static_theme_broken_lwt(self):
        """What if no author or license or category?"""
        persona = addon_factory(type=amo.ADDON_PERSONA)

        assert list(persona.authors.all()) == []  # no author
        persona.persona.license = None  # no license
        AddonCategory.objects.filter(addon=persona).delete()
        assert persona.all_categories == []  # no category
        License.objects.create(builtin=licenses.LICENSE_COPYRIGHT_AR.builtin)

        static_theme = add_static_theme_from_lwt(persona)

        default_author = UserProfile.objects.get(
            email=settings.MIGRATED_LWT_DEFAULT_OWNER_EMAIL)
        assert list(static_theme.authors.all()) == [default_author]
        assert static_theme.all_categories == [
            CATEGORIES[amo.FIREFOX.id][amo.ADDON_STATICTHEME]['other']
        ]
        assert list(static_theme.tags.all()) == []
        assert static_theme.current_version.license.builtin == (
            licenses.LICENSE_COPYRIGHT_AR.builtin)
        assert static_theme.status == amo.STATUS_PUBLIC
        current_file = static_theme.current_version.files.get()
        assert current_file.status == amo.STATUS_PUBLIC
        self.call_signing_mock.assert_called_with(current_file)
        assert current_file.cert_serial_num == 'abcdefg1234'
Example #4
0
    def test_add_static_theme_broken_lwt(self):
        """What if no author or license or category?"""
        persona = addon_factory(type=amo.ADDON_PERSONA)
        persona.update(created=self.create_date,
                       modified=self.modify_date,
                       last_updated=self.update_date)

        assert list(persona.authors.all()) == []  # no author
        persona.persona.license = None  # no license
        AddonCategory.objects.filter(addon=persona).delete()
        assert persona.all_categories == []  # no category
        License.objects.create(builtin=licenses.LICENSE_COPYRIGHT_AR.builtin)
        rating_user = user_factory()
        rating = Rating.objects.create(addon=persona,
                                       version=persona.current_version,
                                       user=rating_user,
                                       rating=2,
                                       body=u'fooooo',
                                       user_responsible=rating_user)
        rating.delete()  # delete the rating - should still be migrated.
        # Add 2 more Ratings for different addons that shouldn't be copied.
        Rating.objects.create(addon=addon_factory(),
                              user=rating_user,
                              rating=3,
                              body=u'tgd',
                              user_responsible=rating_user)
        Rating.objects.create(addon=addon_factory(),
                              user=rating_user,
                              rating=4,
                              body=u'tgffd',
                              user_responsible=rating_user)
        ThemeUpdateCount.objects.create(addon_id=persona.id,
                                        date=datetime(2018, 1, 1),
                                        count=123)
        ThemeUpdateCount.objects.create(addon_id=persona.id,
                                        date=datetime(2018, 2, 1),
                                        count=456)
        # Create a count for an addon that shouldn't be migrated too.
        ThemeUpdateCount.objects.create(addon_id=addon_factory().id,
                                        date=datetime(2018, 2, 1),
                                        count=45)

        static_theme = add_static_theme_from_lwt(persona)

        default_author = UserProfile.objects.get(
            email=settings.MIGRATED_LWT_DEFAULT_OWNER_EMAIL)
        desktop_default_category = (
            CATEGORIES[amo.FIREFOX.id][amo.ADDON_STATICTHEME]['other'])
        android_default_category = (
            CATEGORIES[amo.ANDROID.id][amo.ADDON_STATICTHEME]['other'])
        self._check_result(static_theme, [default_author], [],
                           [desktop_default_category],
                           licenses.LICENSE_COPYRIGHT_AR.builtin, [rating],
                           None)
        # Double check its the exact category we want.
        assert static_theme.all_categories == [
            desktop_default_category, android_default_category
        ]
Example #5
0
    def test_add_static_theme_broken_lwt(self):
        """What if no author or license or category?"""
        persona = addon_factory(type=amo.ADDON_PERSONA)
        persona.update(
            created=self.create_date, modified=self.modify_date,
            last_updated=self.update_date)

        assert list(persona.authors.all()) == []  # no author
        persona.persona.license = None  # no license
        AddonCategory.objects.filter(addon=persona).delete()
        assert persona.all_categories == []  # no category
        License.objects.create(builtin=licenses.LICENSE_COPYRIGHT_AR.builtin)
        rating_user = user_factory()
        rating = Rating.objects.create(
            addon=persona, version=persona.current_version, user=rating_user,
            rating=2, body=u'fooooo', user_responsible=rating_user)
        rating.delete()  # delete the rating - should still be migrated.
        # Add 2 more Ratings for different addons that shouldn't be copied.
        Rating.objects.create(
            addon=addon_factory(), user=rating_user,
            rating=3, body=u'tgd', user_responsible=rating_user)
        Rating.objects.create(
            addon=addon_factory(), user=rating_user,
            rating=4, body=u'tgffd', user_responsible=rating_user)
        ThemeUpdateCount.objects.create(
            addon_id=persona.id, date=datetime(2018, 1, 1), count=123)
        ThemeUpdateCount.objects.create(
            addon_id=persona.id, date=datetime(2018, 2, 1), count=456)
        # Create a count for an addon that shouldn't be migrated too.
        ThemeUpdateCount.objects.create(
            addon_id=addon_factory().id, date=datetime(2018, 2, 1), count=45)

        static_theme = add_static_theme_from_lwt(persona)

        default_author = UserProfile.objects.get(
            email=settings.MIGRATED_LWT_DEFAULT_OWNER_EMAIL)
        desktop_default_category = (
            CATEGORIES[amo.FIREFOX.id][amo.ADDON_STATICTHEME]['other'])
        android_default_category = (
            CATEGORIES[amo.ANDROID.id][amo.ADDON_STATICTHEME]['other'])
        self._check_result(
            static_theme, [default_author], [], [desktop_default_category],
            licenses.LICENSE_COPYRIGHT_AR.builtin, [rating], None)
        # Double check its the exact category we want.
        assert static_theme.all_categories == [
            desktop_default_category, android_default_category]
Example #6
0
    def test_add_static_theme_from_lwt(self):
        author = user_factory()
        persona = addon_factory(type=amo.ADDON_PERSONA, users=[author])
        persona.persona.license = licenses.LICENSE_CC_BY_ND.id
        Tag.objects.create(tag_text='themey').save_tag(persona)
        License.objects.create(builtin=licenses.LICENSE_CC_BY_ND.builtin)
        rating_user = user_factory()
        rating = Rating.objects.create(addon=persona,
                                       version=persona.current_version,
                                       user=rating_user,
                                       rating=2,
                                       body=u'fooooo',
                                       user_responsible=rating_user)

        static_theme = add_static_theme_from_lwt(persona)

        self._check_result(static_theme, [author], list(persona.tags.all()),
                           persona.all_categories,
                           licenses.LICENSE_CC_BY_ND.builtin, [rating])
    def test_add_static_theme_from_lwt(self, build_static_theme_xpi_mock):
        author = user_factory()
        build_static_theme_xpi_mock.side_effect = self._mock_xpi_side_effect
        persona = addon_factory(type=amo.ADDON_PERSONA, users=[author])
        persona.persona.license = licenses.LICENSE_CC_BY_ND.id
        Tag.objects.create(tag_text='themey').save_tag(persona)
        License.objects.create(builtin=licenses.LICENSE_CC_BY_ND.builtin)

        static_theme = add_static_theme_from_lwt(persona)

        assert list(static_theme.authors.all()) == [author]
        assert [cat.name for cat in static_theme.all_categories] == [
            cat.name for cat in persona.all_categories]
        assert list(static_theme.tags.all()) == list(persona.tags.all())
        assert static_theme.current_version.license.builtin == (
            licenses.LICENSE_CC_BY_ND.builtin)
        assert static_theme.status == amo.STATUS_PUBLIC
        assert static_theme.current_version.files.get().status == (
            amo.STATUS_PUBLIC)
Example #8
0
    def test_add_static_theme_from_lwt(self):
        author = user_factory()
        persona = addon_factory(type=amo.ADDON_PERSONA, users=[author])
        persona.persona.license = licenses.LICENSE_CC_BY_ND.id
        Tag.objects.create(tag_text='themey').save_tag(persona)
        License.objects.create(builtin=licenses.LICENSE_CC_BY_ND.builtin)

        static_theme = add_static_theme_from_lwt(persona)

        assert list(static_theme.authors.all()) == [author]
        assert [cat.name for cat in static_theme.all_categories
                ] == [cat.name for cat in persona.all_categories]
        assert list(static_theme.tags.all()) == list(persona.tags.all())
        assert static_theme.current_version.license.builtin == (
            licenses.LICENSE_CC_BY_ND.builtin)
        assert static_theme.status == amo.STATUS_PUBLIC
        current_file = static_theme.current_version.files.get()
        assert current_file.status == amo.STATUS_PUBLIC
        self.call_signing_mock.assert_called_with(current_file)
        assert current_file.cert_serial_num == 'abcdefg1234'
    def test_add_static_theme_broken_lwt(self, build_static_theme_xpi_mock):
        """What if no author or license or category?"""
        build_static_theme_xpi_mock.side_effect = self._mock_xpi_side_effect
        persona = addon_factory(type=amo.ADDON_PERSONA)

        assert list(persona.authors.all()) == []  # no author
        persona.persona.license = None  # no license
        AddonCategory.objects.filter(addon=persona).delete()
        assert persona.all_categories == []  # no category
        License.objects.create(builtin=licenses.LICENSE_COPYRIGHT_AR.builtin)

        static_theme = add_static_theme_from_lwt(persona)

        default_author = UserProfile.objects.get(
            email=settings.MIGRATED_LWT_DEFAULT_OWNER_EMAIL)
        assert list(static_theme.authors.all()) == [default_author]
        assert static_theme.all_categories == [
            CATEGORIES[amo.FIREFOX.id][amo.ADDON_STATICTHEME]['other']]
        assert list(static_theme.tags.all()) == []
        assert static_theme.current_version.license.builtin == (
            licenses.LICENSE_COPYRIGHT_AR.builtin)
        assert static_theme.status == amo.STATUS_PUBLIC
        assert static_theme.current_version.files.get().status == (
            amo.STATUS_PUBLIC)