def setUpTestData(cls):
     factory = DataFactory()
     cls.months = factory.create_months_array(start_date='2018-02-01',
                                              num_months=6)
     # Our NCSO and tariff data extends further than our prescribing data by
     # a couple of months
     cls.prescribing_months = cls.months[:-2]
     # Create some CCGs (we need more than one so we can test aggregation
     # across CCGs at the All England level)
     cls.ccgs = [factory.create_ccg() for _ in range(2)]
     # Populate those CCGs with practices
     cls.practices = []
     for ccg in cls.ccgs:
         for _ in range(2):
             cls.practices.append(factory.create_practice(ccg=ccg))
     # Create some presentations
     cls.presentations = factory.create_presentations(6)
     # Create drug tariff and price concessions costs for these presentations
     factory.create_tariff_and_ncso_costings_for_presentations(
         cls.presentations, months=cls.months)
     # Create prescribing for each of the practices we've created
     for practice in cls.practices:
         factory.create_prescribing_for_practice(
             practice,
             presentations=cls.presentations,
             months=cls.prescribing_months)
     # Create and populate the materialized view table we need
     factory.populate_materialised_views()
     # Pull out an individual practice and CCG to use in our tests
     cls.practice = cls.practices[0]
     cls.ccg = cls.ccgs[0]
     # Create user to own a bookmark
     cls.user = factory.create_user()
Beispiel #2
0
    def test_all_england_alert_signup_form(self):
        factory = DataFactory()
        user = factory.create_user()
        url = "/all-england/concessions/".format(self.practice.code)

        # Check form is displayed when user not loged in.
        response = self.client.get(url)
        self.assertContains(response, "Get email updates")

        # Now log user in.
        self.client.force_login(user)

        # Check form is displayed when user has no bookmarks.
        response = self.client.get(url)
        self.assertContains(response, "Get email updates")

        # Create bookmarks for practice and CCG, and check that form is still
        # displayed.
        factory.create_ncso_concessions_bookmark(self.practice, user)
        factory.create_ncso_concessions_bookmark(self.ccg, user)
        response = self.client.get(url)
        self.assertContains(response, "Get email updates")

        # Create bookmark for All England, and check that form is not displayed.
        factory.create_ncso_concessions_bookmark(None, user)
        response = self.client.get(url)
        self.assertNotContains(response, "Get email updates")
        self.assertContains(response, "already signed up")
    def test_alert_signup_form(self):
        factory = DataFactory()
        user = factory.create_user()
        url = '/practice/{}/concessions/'.format(self.practice.code)

        # Check form is displayed when user not loged in.
        response = self.client.get(url)
        self.assertContains(response, 'Get email updates')

        # Now log user in.
        self.client.force_login(user)

        # Check form is displayed when user has no bookmarks.
        response = self.client.get(url)
        self.assertContains(response, 'Get email updates')

        # Create bookmarks for CCG and All England, and check that form is
        # still displayed.
        factory.create_ncso_concessions_bookmark(self.ccg, user)
        factory.create_ncso_concessions_bookmark(None, user)
        response = self.client.get(url)
        self.assertContains(response, 'Get email updates')

        # Create bookmark for practice, and check that form is not displayed.
        factory.create_ncso_concessions_bookmark(self.practice, user)
        response = self.client.get(url)
        self.assertNotContains(response, 'Get email updates')
        self.assertContains(response, 'already signed up')
    def test_alert_signup(self):
        factory = DataFactory()
        factory.create_user(email="*****@*****.**")
        factory.create_ncso_concessions_bookmark(None)

        self.assertEqual(NCSOConcessionBookmark.objects.count(), 1)

        url = "/practice/{}/concessions/".format(self.practice.code)
        data = {"email": "*****@*****.**", "practice": self.practice.code}
        response = self.client.post(url, data, follow=True)
        self.assertContains(response,
                            "alerts about NCSO concessions for Practice 5")

        self.assertEqual(NCSOConcessionBookmark.objects.count(), 2)
        bookmark = NCSOConcessionBookmark.objects.last()
        self.assertEqual(bookmark.practice, self.practice)
        self.assertEqual(bookmark.user.email, "*****@*****.**")
    def test_all_england_alert_signup(self):
        factory = DataFactory()
        factory.create_user(email="*****@*****.**")
        factory.create_ncso_concessions_bookmark(self.practice)

        self.assertEqual(NCSOConcessionBookmark.objects.count(), 1)

        url = "/all-england/concessions/"
        data = {"email": "*****@*****.**"}
        response = self.client.post(url, data, follow=True)
        self.assertContains(
            response, "alerts about NCSO concessions for the NHS in England")

        self.assertEqual(NCSOConcessionBookmark.objects.count(), 2)
        bookmark = NCSOConcessionBookmark.objects.order_by("id").last()
        self.assertEqual(bookmark.practice, None)
        self.assertEqual(bookmark.pct, None)
        self.assertEqual(bookmark.user.email, "*****@*****.**")
Beispiel #6
0
    def test_all_england_alert_signup(self):
        factory = DataFactory()
        factory.create_user(email="*****@*****.**")
        factory.create_ncso_concessions_bookmark(self.practice)

        self.assertEqual(NCSOConcessionBookmark.objects.count(), 1)

        url = "/all-england/concessions/"
        data = {"email": "*****@*****.**", "newsletters": ["alerts"]}
        response = self.client.post(url, data, follow=True)
        self.assertContains(
            response, "Check your email and click the confirmation link")

        self.assertEqual(NCSOConcessionBookmark.objects.count(), 2)
        bookmark = NCSOConcessionBookmark.objects.order_by("id").last()
        self.assertEqual(bookmark.practice, None)
        self.assertEqual(bookmark.pct, None)
        self.assertEqual(bookmark.user.email, "*****@*****.**")
        self.assertEqual(bookmark.approved, True)
    def test_all_england_alert_signup(self):
        factory = DataFactory()
        user = factory.create_user(email='*****@*****.**')
        factory.create_ncso_concessions_bookmark(self.practice)

        self.assertEqual(NCSOConcessionBookmark.objects.count(), 1)

        url = '/all-england/concessions/'
        data = {
            'email': '*****@*****.**',
            'newsletters': ['alerts'],
        }
        response = self.client.post(url, data, follow=True)
        self.assertContains(
            response, "Check your email and click the confirmation link")

        self.assertEqual(NCSOConcessionBookmark.objects.count(), 2)
        bookmark = NCSOConcessionBookmark.objects.order_by('id').last()
        self.assertEqual(bookmark.practice, None)
        self.assertEqual(bookmark.pct, None)
        self.assertEqual(bookmark.user.email, '*****@*****.**')
        self.assertEqual(bookmark.approved, True)