def test_combine_envelope_contents(self): # Make some pages. p1 = Page() p1.save() p2 = Page() p2.save() p3 = Page() p3.save() p4 = Page() p4.save() # Make a box for them. b = Box() b.save() # Put them in the box. box.add_content( (p1, p2, p3, p4) ) # Make two envelopes and put pages in them. e1 = Envelope() e1.add_content( (p1, p2) ) e2 = Envelope() e2.add_content( (p3, p4) ) # Combine envelope contents. e2.send_contents_to_envelope(e1) self.assertEqual(len(e2.contents.all()), 0, "Some content is still left in sending envelope.") self.assertEqual(len(e1.contents.all()), 4, "Content in receiving envelope is not correct.") for page in [p1, p2, p3, p4]: self.assertTrue(page in e1.get_content(), "Page not found in receiving envelope.")
def test_envelope_contents(self): e = Envelope() e.save() self.assertEqual(len(e.contents), 0, "Envelope should start out empty.") p1 = Page() p1.title = 'Test Page 1' e.add_content(p1) p2 = Page() p2.title = 'Test Page 2' e.add_content(p2) self.assertTrue(e.contains_content(p1), "Page 1 not found in envelope.") self.assertTrue(e.contains_content(p2), "Page 2 not found in envelope.") e.remove_content(p1) self.assertFalse(e.contains_content(p1), "Page 1 not removed from envelope.") e.remove_content(p2) self.assertFalse(e.contains_content(p2), "Page 2 not removed from envelope.") self.assertEqual(len(e.contents), 0, "Envelope should now be empty.")