def test_l10n_badge(self): """Verify the L10n Badge is awarded properly.""" # Create the user and badge. year = date.today().year user = UserFactory() b = BadgeFactory( slug=WIKI_BADGES["l10n-badge"]["slug"].format(year=year), title=WIKI_BADGES["l10n-badge"]["title"].format(year=year), description=WIKI_BADGES["l10n-badge"]["description"].format( year=year), ) # Create 9 approved es revisions. doc = DocumentFactory(locale="es") ApprovedRevisionFactory.create_batch(settings.BADGE_LIMIT_L10N_KB - 1, creator=user, document=doc) # User should NOT have the badge yet assert not b.is_awarded_to(user) # Create 1 more approved es revision. RevisionFactory(creator=user, document=doc, is_approved=True) # User should have the badge now assert b.is_awarded_to(user)
def test_l10n_badge(self): """Verify the L10n Badge is awarded properly.""" # Create the user and badge. year = date.today().year u = UserFactory() b = BadgeFactory( slug=WIKI_BADGES['l10n-badge']['slug'].format(year=year), title=WIKI_BADGES['l10n-badge']['title'].format(year=year), description=WIKI_BADGES['l10n-badge']['description'].format( year=year)) # Create 9 approved es revisions. d = DocumentFactory(locale='es') ApprovedRevisionFactory.create_batch(settings.BADGE_LIMIT_L10N_KB - 1, creator=u, document=d) # User should NOT have the badge yet assert not b.is_awarded_to(u) # Create 1 more approved es revision. RevisionFactory(creator=u, document=d, is_approved=True) # User should have the badge now assert b.is_awarded_to(u)
def test_kb_badge(self): """Verify the KB Badge is awarded properly.""" # Create the user and badge. year = date.today().year u = UserFactory() b = BadgeFactory( slug=WIKI_BADGES["kb-badge"]["slug"].format(year=year), title=WIKI_BADGES["kb-badge"]["title"].format(year=year), description=WIKI_BADGES["kb-badge"]["description"].format( year=year), ) # Create 9 approved en-US revisions. d = DocumentFactory(locale=settings.WIKI_DEFAULT_LANGUAGE) ApprovedRevisionFactory.create_batch(settings.BADGE_LIMIT_L10N_KB - 1, creator=u, document=d) # User should NOT have the badge yet assert not b.is_awarded_to(u) # Create 1 more approved en-US revision. RevisionFactory(creator=u, document=d, is_approved=True) # User should have the badge now assert b.is_awarded_to(u)
def test_direct_recursion(self): """Make sure direct recursion is caught on the very first nesting.""" d = DocumentFactory(title="Boo") # Twice so the second revision sees content identical to itself: ApprovedRevisionFactory.create_batch( 2, document=d, content="Fine [[Include:Boo]] Fellows") eq_("<p>Fine %s Fellows\n</p>" % (RECURSION_MESSAGE % "Boo"), d.content_parsed)
def test_direct_recursion(self): """Make sure direct recursion is caught on the very first nesting.""" d = TemplateDocumentFactory(title=TEMPLATE_TITLE_PREFIX + 'Boo') # Twice so the second revision sees content identical to itself: ApprovedRevisionFactory.create_batch( 2, document=d, content='Fine [[{}Boo]] Fellows'.format(TEMPLATE_TITLE_PREFIX)) recursion_message = RECURSION_MESSAGE % (TEMPLATE_TITLE_PREFIX + 'Boo') expected = '<p>Fine %s Fellows\n</p>' % recursion_message eq_(expected, d.content_parsed)
def test_direct_recursion(self): """Make sure direct recursion is caught on the very first nesting.""" d = TemplateDocumentFactory(title=TEMPLATE_TITLE_PREFIX + "Boo") # Twice so the second revision sees content identical to itself: ApprovedRevisionFactory.create_batch( 2, document=d, content="Fine [[{}Boo]] Fellows".format(TEMPLATE_TITLE_PREFIX) ) recursion_message = RECURSION_MESSAGE % (TEMPLATE_TITLE_PREFIX + "Boo") expected = "<p>Fine %s Fellows\n</p>" % recursion_message eq_(expected, d.content_parsed)
def setUp(self): today = datetime.today() self.start_of_first_week = today - timedelta(days=today.weekday(), weeks=12) revisions = ApprovedRevisionFactory.create_batch(3, created=self.start_of_first_week) reviewer = UserFactory() ApprovedRevisionFactory(reviewer=reviewer, created=self.start_of_first_week) ApprovedRevisionFactory(creator=revisions[1].creator, reviewer=reviewer, created=self.start_of_first_week + timedelta(weeks=1, days=2)) ApprovedRevisionFactory(created=self.start_of_first_week + timedelta(weeks=1, days=1)) for r in revisions: lr = ApprovedRevisionFactory(created=self.start_of_first_week + timedelta(days=1), document__locale='es') ApprovedRevisionFactory(created=self.start_of_first_week + timedelta(weeks=2, days=1), creator=lr.creator, document__locale='es') answers = AnswerFactory.create_batch( 7, created=self.start_of_first_week + timedelta(weeks=1, days=2)) AnswerFactory(question=answers[2].question, creator=answers[2].question.creator, created=self.start_of_first_week + timedelta(weeks=1, days=2)) for a in answers[:2]: AnswerFactory(creator=a.creator, created=self.start_of_first_week + timedelta(weeks=2, days=5)) replies = ReplyFactory.create_batch(2, created=self.start_of_first_week) for r in replies: ReplyFactory(user=r.user, created=self.start_of_first_week + timedelta(weeks=2)) call_command('cohort_analysis')
def setUp(self): today = datetime.today() self.start_of_first_week = today - timedelta(days=today.weekday(), weeks=12) revisions = ApprovedRevisionFactory.create_batch(3, created=self.start_of_first_week) reviewer = UserFactory() ApprovedRevisionFactory(reviewer=reviewer, created=self.start_of_first_week) ApprovedRevisionFactory(creator=revisions[1].creator, reviewer=reviewer, created=self.start_of_first_week + timedelta(weeks=1, days=2)) ApprovedRevisionFactory(created=self.start_of_first_week + timedelta(weeks=1, days=1)) for r in revisions: lr = ApprovedRevisionFactory(created=self.start_of_first_week + timedelta(days=1), document__locale='es') ApprovedRevisionFactory(created=self.start_of_first_week + timedelta(weeks=2, days=1), creator=lr.creator, document__locale='es') answers = AnswerFactory.create_batch( 7, created=self.start_of_first_week + timedelta(weeks=1, days=2)) AnswerFactory(question=answers[2].question, creator=answers[2].question.creator, created=self.start_of_first_week + timedelta(weeks=1, days=2)) for a in answers[:2]: AnswerFactory(creator=a.creator, created=self.start_of_first_week + timedelta(weeks=2, days=5)) replies = ReplyFactory.create_batch(2, created=self.start_of_first_week) for r in replies: ReplyFactory(user=r.user, created=self.start_of_first_week + timedelta(weeks=2)) call_command('cohort_analysis')
def test_document_listing(self): """Verify /products/<product slug>/<topic slug> renders articles.""" # Create a topic and product. p = ProductFactory() t1 = TopicFactory(product=p) # Create 3 documents with the topic and product and one without. ApprovedRevisionFactory.create_batch(3, document__products=[p], document__topics=[t1]) ApprovedRevisionFactory() self.refresh() # GET the page and verify the content. url = reverse('products.documents', args=[p.slug, t1.slug]) r = self.client.get(url, follow=True) eq_(200, r.status_code) doc = pq(r.content) eq_(3, len(doc('#document-list > ul > li'))) eq_(p.slug, doc('#support-search input[name=product]').attr['value'])
def test_l10n_badge(self): """Verify the L10n Badge is awarded properly.""" # Create the user and badge. year = date.today().year u = UserFactory() b = BadgeFactory( slug=WIKI_BADGES['l10n-badge']['slug'].format(year=year), title=WIKI_BADGES['l10n-badge']['title'].format(year=year), description=WIKI_BADGES['l10n-badge']['description'].format(year=year)) # Create 9 approved es revisions. d = DocumentFactory(locale='es') ApprovedRevisionFactory.create_batch(9, creator=u, document=d) # User should NOT have the badge yet assert not b.is_awarded_to(u) # Create 1 more approved es revision. RevisionFactory(creator=u, document=d, is_approved=True) # User should have the badge now assert b.is_awarded_to(u)
def test_kb_badge(self): """Verify the KB Badge is awarded properly.""" # Create the user and badge. year = date.today().year u = UserFactory() b = BadgeFactory( slug=WIKI_BADGES['kb-badge']['slug'].format(year=year), title=WIKI_BADGES['kb-badge']['title'].format(year=year), description=WIKI_BADGES['kb-badge']['description'].format(year=year)) # Create 9 approved en-US revisions. d = DocumentFactory(locale=settings.WIKI_DEFAULT_LANGUAGE) ApprovedRevisionFactory.create_batch(settings.BADGE_LIMIT_L10N_KB - 1, creator=u, document=d) # User should NOT have the badge yet assert not b.is_awarded_to(u) # Create 1 more approved en-US revision. RevisionFactory(creator=u, document=d, is_approved=True) # User should have the badge now assert b.is_awarded_to(u)
def test_direct_recursion(self): """Make sure direct recursion is caught on the very first nesting.""" d = DocumentFactory(title='Boo') # Twice so the second revision sees content identical to itself: ApprovedRevisionFactory.create_batch(2, document=d, content='Fine [[Include:Boo]] Fellows') eq_('<p>Fine %s Fellows\n</p>' % (RECURSION_MESSAGE % 'Boo'), d.content_parsed)