This commit is contained in:
Kevin Ngo 2013-04-26 13:14:05 -07:00
Родитель 44fc5dfb22
Коммит 6869f637d2
2 изменённых файлов: 10 добавлений и 9 удалений

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

@ -13,7 +13,7 @@ from access.models import GroupUser
from addons.models import Persona
import amo
import amo.tests
from amo.tests import addon_factory
from amo.tests import addon_factory, days_ago
from amo.urlresolvers import reverse
from devhub.models import ActivityLog
import mkt.constants.reviewers as rvw
@ -111,7 +111,7 @@ class ThemeReviewTestMixin(object):
# Manually expire a lock and see if it's reassigned.
expired_theme_lock = ThemeLock.objects.all()[0]
expired_theme_lock.expiry = datetime.datetime.now()
expired_theme_lock.expiry = self.days_ago(1)
expired_theme_lock.save()
_get_themes(mock.Mock(), reviewer, flagged=self.flagged)
eq_(ThemeLock.objects.filter(reviewer=reviewer).count(), 1)
@ -122,11 +122,10 @@ class ThemeReviewTestMixin(object):
reviewer = self.create_and_become_reviewer()
_get_themes(mock.Mock(), reviewer, flagged=self.flagged)
earlier = datetime.datetime.now() - datetime.timedelta(minutes=10)
ThemeLock.objects.filter(reviewer=reviewer).update(expiry=earlier)
ThemeLock.objects.filter(reviewer=reviewer).update(expiry=days_ago(1))
_get_themes(mock.Mock(), reviewer, flagged=self.flagged)
eq_(ThemeLock.objects.filter(reviewer=reviewer)[0].expiry > earlier,
True)
eq_(ThemeLock.objects.filter(reviewer=reviewer)[0].expiry >
days_ago(1), True)
@mock.patch('mkt.reviewers.tasks.send_mail_jinja')
def test_commit(self, send_mail_jinja_mock):
@ -141,9 +140,10 @@ class ThemeReviewTestMixin(object):
# Create locks.
reviewer = self.create_and_become_reviewer()
for index, theme in enumerate(themes):
ThemeLock.objects.create(theme=theme, reviewer=reviewer,
ThemeLock.objects.create(
theme=theme, reviewer=reviewer,
expiry=datetime.datetime.now() +
datetime.timedelta(minutes=rvw.THEME_LOCK_EXPIRY))
datetime.timedelta(minutes=rvw.THEME_LOCK_EXPIRY))
form_data['form-%s-theme' % index] = str(theme.id)
# moreinfo

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

@ -160,8 +160,9 @@ def _get_themes(request, reviewer, flagged=False):
theme_lock.reviewer = reviewer
theme_lock.expiry = expiry
theme_lock.save()
themes = [theme_lock.theme for theme_lock in expired_locks]
theme_locks = expired_locks
# New theme locks may have been created, grab all reviewer's themes again.
return [lock.theme for lock in theme_locks]