Have the static theme dates match the original persona create/modify dates (#8588)

This commit is contained in:
Andrew Williamson 2018-06-21 12:26:04 +01:00 коммит произвёл GitHub
Родитель f3a5ea9a6e
Коммит 41e74f143b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 11 добавлений и 0 удалений

Просмотреть файл

@ -593,6 +593,10 @@ def add_static_theme_from_lwt(lwt):
status=amo.STATUS_PUBLIC)
addon_updates['status'] = amo.STATUS_PUBLIC
# set the modified and creation dates to match the original.
addon_updates['created'] = lwt.created
addon_updates['modified'] = lwt.modified
addon.update(**addon_updates)
return addon

Просмотреть файл

@ -2,6 +2,7 @@ import mock
import os
import pytest
import tempfile
from datetime import datetime
from django.conf import settings
from django.test.utils import override_settings
@ -119,6 +120,8 @@ def test_migrate_lwts_to_static_themes(add_static_theme_from_lwt_mock):
@override_switch('allow-static-theme-uploads', active=True)
@override_settings(ENABLE_ADDON_SIGNING=True)
class TestAddStaticThemeFromLwt(TestCase):
create_date = datetime(2000, 1, 1, 1, 1, 1)
modify_date = datetime(2009, 9, 9, 9, 9, 9)
def setUp(self):
super(TestAddStaticThemeFromLwt, self).setUp()
@ -160,10 +163,13 @@ class TestAddStaticThemeFromLwt(TestCase):
assert static_theme in arguments
self.call_signing_mock.assert_called_with(current_file)
assert current_file.cert_serial_num == 'abcdefg1234'
assert static_theme.created == self.create_date
assert static_theme.modified == self.modify_date
def test_add_static_theme_from_lwt(self):
author = user_factory()
persona = addon_factory(type=amo.ADDON_PERSONA, users=[author])
persona.update(created=self.create_date, modified=self.modify_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)
@ -182,6 +188,7 @@ class TestAddStaticThemeFromLwt(TestCase):
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)
assert list(persona.authors.all()) == [] # no author
persona.persona.license = None # no license