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)
     # Pull out an individual practice and CCG to use in our tests
     cls.practice = cls.practices[0]
     cls.ccg = cls.ccgs[0]
    def setUp(self):
        self.api_prefix = '/api/1.0'
        factory = DataFactory()
        self.months = factory.create_months_array(start_date='2018-02-01')
        self.ccgs = [factory.create_ccg() for _ in range(2)]
        self.practices = []
        for ccg in self.ccgs:
            for _ in range(2):
                self.practices.append(factory.create_practice(ccg=ccg))
        self.presentations = factory.create_presentations(
            2, vmpp_per_presentation=2)
        factory.create_tariff_and_ncso_costings_for_presentations(
            presentations=self.presentations, months=self.months)

        # Create prescribing for each of the practices we've created
        for practice in self.practices:
            factory.create_prescribing_for_practice(
                practice,
                presentations=self.presentations,
                months=self.months
            )
        # Create and populate the materialized view table we need
        factory.populate_materialised_views()

        # Refresh vw__medians_for_tariff materialized view
        with connection.cursor() as cursor:
            cursor.execute("REFRESH MATERIALIZED VIEW vw__medians_for_tariff")
        super(TestAPISpendingViewsGhostGenerics, self).setUp()
예제 #3
0
    def setUpTestData(self):
        self.api_prefix = "/api/1.0"
        factory = DataFactory()
        self.months = factory.create_months_array(start_date="2018-02-01")
        self.ccgs = [factory.create_ccg() for _ in range(2)]
        self.practices = []
        for ccg in self.ccgs:
            for _ in range(2):
                self.practices.append(factory.create_practice(ccg=ccg, setting=4))
        self.presentations = factory.create_presentations(2, vmpp_per_presentation=2)
        factory.create_tariff_and_ncso_costings_for_presentations(
            presentations=self.presentations, months=self.months
        )

        # Create prescribing for each of the practices we've created
        for practice in self.practices:
            factory.create_prescribing_for_practice(
                practice, presentations=self.presentations, months=self.months
            )
 def setUpClass(cls):
     super(TestSpendingViews, cls).setUpClass()
     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 high level orgs
     cls.regional_team = factory.create_regional_team()
     cls.stp = factory.create_stp()
     # 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(stp=cls.stp, regional_team=cls.regional_team)
         for _ in range(2)
     ]
     # Create a PCN (one will do)
     cls.pcn = factory.create_pcn()
     # Populate those CCGs with practices
     cls.practices = []
     for ccg in cls.ccgs:
         for _ in range(2):
             cls.practices.append(
                 factory.create_practice(ccg=ccg, pcn=cls.pcn))
     # Create some presentations
     cls.presentations = factory.create_presentations(
         6, vmpp_per_presentation=2)
     # 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)
     # Pull out an individual practice and CCG to use in our tests
     cls.practice = cls.practices[0]
     cls.ccg = cls.ccgs[0]