def test_themes_less_than_initial(self): """ Number of themes in the pool is less than amount we want to check out. """ addon_factory(type=amo.ADDON_PERSONA, status=self.status) reviewer = self.create_and_become_reviewer() assert len(_get_themes(mock.Mock(), reviewer)) == 1 assert len(_get_themes(mock.Mock(), reviewer)) == 1
def test_expiry_update(self): """Test expiry is updated when reviewer reloads his queue.""" self.theme_factory() reviewer = self.create_and_become_reviewer() self.get_themes(reviewer) ThemeLock.objects.filter(reviewer=reviewer).update(expiry=days_ago(1)) _get_themes(mock.Mock(), reviewer, flagged=self.flagged) self.get_themes(reviewer) assert ThemeLock.objects.filter( reviewer=reviewer)[0].expiry > days_ago(1)
def test_release_locks(self): for x in range(2): addon_factory(type=amo.ADDON_PERSONA, status=self.status) other_reviewer = self.create_and_become_reviewer() _get_themes(mock.Mock(), other_reviewer) # Check reviewer's theme lock released. reviewer = self.create_and_become_reviewer() _get_themes(mock.Mock(), reviewer) assert ThemeLock.objects.filter(reviewer=reviewer).count() == 1 self.client.get(reverse('editors.themes.release_locks')) assert ThemeLock.objects.filter(reviewer=reviewer).count() == 0 # Check other reviewer's theme lock intact. assert ThemeLock.objects.filter(reviewer=other_reviewer).count() == 1
def test_queue_cannot_review_own_theme(self): with self.settings(ALLOW_SELF_REVIEWS=False): reviewer = self.create_and_become_reviewer() for x in range(rvw.THEME_INITIAL_LOCKS + 1): addon = self.theme_factory() addon.addonuser_set.create(user=reviewer) assert _get_themes(amo.tests.req_factory_factory('', reviewer), reviewer) == [] assert ThemeLock.objects.filter(reviewer=reviewer).count() == 0
def test_queue_cannot_review_own_theme(self): with self.settings(ALLOW_SELF_REVIEWS=False): reviewer = self.create_and_become_reviewer() for x in range(rvw.THEME_INITIAL_LOCKS + 1): addon = self.theme_factory() addon.addonuser_set.create(user=reviewer) assert _get_themes( amo.tests.req_factory_factory('', reviewer), reviewer) == [] assert ThemeLock.objects.filter(reviewer=reviewer).count() == 0
def get_themes(self, reviewer): return _get_themes(mock.Mock(), reviewer, flagged=self.flagged, rereview=self.rereview)