def test_creates_pdf_bundle_if_no_match(self, get_unread_apps): matching_apps = factories.make_apps_for_sf() not_matching_apps = factories.make_apps_for_sf() prebuilt = factories.PrebuiltPDFBundleFactory() prebuilt.applications.add(*matching_apps) all_apps = matching_apps + not_matching_apps get_unread_apps.return_value = factories.apps_queryset(all_apps) result = PDFService.update_pdf_bundle_for_san_francisco() self.assertNotEqual(result, prebuilt) self.assertEqual(set(all_apps), set(result.applications.all()))
def test_creates_pdf_bundle_if_no_match(self, get_unread_apps): matching_apps = factories.make_apps_for_sf() not_matching_apps = factories.make_apps_for_sf() prebuilt = factories.PrebuiltPDFBundleFactory() prebuilt.applications.add(*matching_apps) all_apps = matching_apps + not_matching_apps get_unread_apps.return_value = factories.apps_queryset(all_apps) result = PDFService.update_pdf_bundle_for_san_francisco() self.assertNotEqual(result, prebuilt) self.assertEqual(set(all_apps), set(result.applications.all()))
def test_creates_pdf_bundle_if_no_prebuilts(self, get_unread_apps): apps = factories.make_apps_for_sf() get_unread_apps.return_value = factories.apps_queryset(apps) prebuilt_count = models.PrebuiltPDFBundle.objects.count() self.assertEqual(0, prebuilt_count) PDFService.update_pdf_bundle_for_san_francisco() prebuilt_count = models.PrebuiltPDFBundle.objects.count() self.assertEqual(1, prebuilt_count)
def test_if_unread_set_has_a_match(self, create_bundle, get_unread_apps): apps = factories.make_apps_for_sf() prebuilt = factories.PrebuiltPDFBundleFactory() prebuilt.applications.add(*apps) get_unread_apps.return_value = factories.apps_queryset(apps) result = PDFService.update_pdf_bundle_for_san_francisco() self.assertEqual(result, prebuilt) create_bundle.assert_not_called()
def test_creates_pdf_bundle_if_no_prebuilts(self, get_unread_apps): apps = factories.make_apps_for_sf() get_unread_apps.return_value = factories.apps_queryset(apps) prebuilt_count = models.PrebuiltPDFBundle.objects.count() self.assertEqual(0, prebuilt_count) PDFService.update_pdf_bundle_for_san_francisco() prebuilt_count = models.PrebuiltPDFBundle.objects.count() self.assertEqual(1, prebuilt_count)
def test_if_unread_set_has_a_match(self, create_bundle, get_unread_apps): apps = factories.make_apps_for_sf() prebuilt = factories.PrebuiltPDFBundleFactory() prebuilt.applications.add(*apps) get_unread_apps.return_value = factories.apps_queryset(apps) result = PDFService.update_pdf_bundle_for_san_francisco() self.assertEqual(result, prebuilt) create_bundle.assert_not_called()