Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_draft_and_deleted(self):
self.failUnlessEqual(set([self.flat_page1, self.flat_page2]), set(FlatPage.objects.draft_and_deleted()))
self.flat_page1.publish()
self.failUnlessEqual(set([self.flat_page1, self.flat_page2]), set(FlatPage.objects.draft_and_deleted()))
self.failUnlessEqual(set([self.flat_page1, self.flat_page2]), set(FlatPage.objects.draft()))
self.flat_page1.delete()
self.failUnlessEqual(set([self.flat_page1, self.flat_page2]), set(FlatPage.objects.draft_and_deleted()))
self.failUnlessEqual([self.flat_page2], list(FlatPage.objects.draft()))
def test_draft_and_deleted(self):
self.failUnlessEqual(set([self.flat_page1, self.flat_page2]), set(FlatPage.objects.draft_and_deleted()))
self.flat_page1.publish()
self.failUnlessEqual(set([self.flat_page1, self.flat_page2]), set(FlatPage.objects.draft_and_deleted()))
self.failUnlessEqual(set([self.flat_page1, self.flat_page2]), set(FlatPage.objects.draft()))
self.flat_page1.delete()
self.failUnlessEqual(set([self.flat_page1, self.flat_page2]), set(FlatPage.objects.draft_and_deleted()))
self.failUnlessEqual([self.flat_page2], list(FlatPage.objects.draft()))
def test_publish(self):
self.failUnlessEqual([], list(FlatPage.objects.published()))
FlatPage.objects.draft().publish()
flat_page1 = FlatPage.objects.get(id=self.flat_page1.id)
flat_page2 = FlatPage.objects.get(id=self.flat_page2.id)
self.failUnlessEqual(set([flat_page1.public, flat_page2.public]), set(FlatPage.objects.published()))
def test_delete(self):
# delete is overriden, so it marks the public instances
self.flat_page1.publish()
public1 = self.flat_page1.public
FlatPage.objects.draft().delete()
self.failUnlessEqual([], list(FlatPage.objects.draft()))
self.failUnlessEqual([self.flat_page1], list(FlatPage.objects.deleted()))
self.failUnlessEqual([public1], list(FlatPage.objects.published()))
self.failUnlessEqual([self.flat_page1], list(FlatPage.objects.draft_and_deleted()))
def test_delete(self):
# delete is overriden, so it marks the public instances
self.flat_page1.publish()
public1 = self.flat_page1.public
FlatPage.objects.draft().delete()
self.failUnlessEqual([], list(FlatPage.objects.draft()))
self.failUnlessEqual([self.flat_page1], list(FlatPage.objects.deleted()))
self.failUnlessEqual([public1], list(FlatPage.objects.published()))
self.failUnlessEqual([self.flat_page1], list(FlatPage.objects.draft_and_deleted()))
def test_draft(self):
# draft should stay the same pretty much always
self.failUnlessEqual([self.flat_page1, self.flat_page2], list(FlatPage.objects.draft()))
self.flat_page1.publish()
self.failUnlessEqual([self.flat_page1, self.flat_page2], list(FlatPage.objects.draft()))
self.flat_page2.publish()
self.failUnlessEqual([self.flat_page1, self.flat_page2], list(FlatPage.objects.draft()))
self.flat_page2.delete()
self.failUnlessEqual([self.flat_page1], list(FlatPage.objects.draft()))
def test_delete_selected(self):
class dummy_request(object):
POST = {}
META = {}
class user(object):
@classmethod
def has_perm(cls, *arg):
return True
@classmethod
def get_and_delete_messages(cls):
return []
response = delete_selected(self.page_admin, dummy_request, FlatPage.objects.draft())
self.failUnless(response is not None)