Esempio n. 1
0
 def test_republish_entry_twice(self):
     "An entry cannot be re-published twice by the same user"
     entryobj = models.Entry.objects.all()[0]
     repubobj = logic.republish_entry(self.get_user(), entryobj)
     repubobj2 = logic.republish_entry(self.get_user(), entryobj)
     self.assertEqual(repubobj.id, repubobj2.id)
     self.assertEqual(1, models.RePublishedEntry.objects.all().count())
Esempio n. 2
0
 def test_republished_entry_attributes(self):
     "A re-published entry contains identical copies of the original entry's content"
     for entryobj in models.Entry.objects.all():
         logic.republish_entry(self.get_user(), entryobj)
         repubobj = models.RePublishedEntry.objects.get(
             user=self.get_user(), original_guid=entryobj.guid)
         self.assertTrue(isinstance(repubobj, models.RePublishedEntry))
         # ensure the copied fields remain identical
         for ofield, nfield in models.RePublishedEntry.mappings.iteritems():
             self.assertEqual(getattr(entryobj, ofield),
                              getattr(repubobj, nfield))
Esempio n. 3
0
def quick_republish_entry(request, eid, slug):
    "A user can quickly republish an entry and fill in any optional fields later."
    # NOTE: user doesn't have to be subscribed to the feed the entry
    # came from in order to republish it
    entryobj = get_object_or_404(models.Entry, pk=eid)
    repubobj = logic.republish_entry(request.user, entryobj)
    logic.mark_entry_read(request.user, entryobj)
    if request.is_ajax():
        return json_response("success")
    return named_redirect('reader', entryobj.id)
Esempio n. 4
0
 def test_client_republish_feed(self):
     "Any user can access a feed of their generated entries"
     userobj = self.get_user()
     entryobj = logic.user_entry_list(self.get_user())[0]
     repubobj = logic.republish_entry(userobj, entryobj)
     c = Client()
     resp = c.get(
         reverse('republished-atom-feed',
                 kwargs={
                     'uid': userobj.id,
                     'username': userobj.username
                 }))
     self.assertTrue(resp.status_code, 200)
     self.assertEqual(len(feedparser.parse(resp.content).entries), 1)
Esempio n. 5
0
 def test_republish_entry_twice_different_users(self):
     "An entry can be re-published twice by different users"
     entryobj = models.Entry.objects.all()[0]
     repubobj = logic.republish_entry(self.get_user(), entryobj)
     repubobj2 = logic.republish_entry(self.get_admin(), entryobj)
     self.assertNotEqual(repubobj.id, repubobj2.id)
Esempio n. 6
0
 def test_republish_entry(self):
     "An entry can be re-published."
     repubobj = logic.republish_entry(self.get_user(),
                                      models.Entry.objects.all()[0])
     self.assertTrue(isinstance(repubobj, models.RePublishedEntry))