Example #1
0
    def setUp(self):
        self._clear_data()
        
        TestScript.setUp(self, default_lang='sw')
        self.domain = Domain.objects.get_or_create(name='mockdomain')[0]
        chws = ReporterGroup(title="mocksupes")
        chws.save()
        chvs = ReporterGroup(title="mocksubs")
        chvs.save()
        org = Organization(name="mockorg", domain=self.domain)
        org.members = chvs
        org.supervisors = chws
        org.save()
        
        backend = PersistantBackend.objects.get_or_create(slug=self.backend.slug)[0]
        self.sub, self.sub_profile = create_active_reporter_and_profile(backend, self.domain, phone_number="306", username='******')
        self.supe, self.supe_profile = create_active_reporter_and_profile(backend, self.domain, phone_number="3093", username='******')
        
        self.sub.groups.add(chvs)
        self.supe.groups.add(chws)

        path = os.path.dirname(__file__)
        self.formdefmodel = create_xsd_and_populate("data/brac_chp.xsd", 
                                                    domain=self.domain, 
                                                    path=path)
        self.submit = populate("data/brac_chp_1.xml", domain=self.domain,
                               path=path)
        self.submit.submit_time = datetime.now() - timedelta(days=3)
        self.submit.save()
        
        self.router.start()
    def setUp(self):
        TestScript.setUp(self)
            
        # make some nodes and graphs
        # imagine this is users and groups for clarity
        self.m_nodes = [_contact(n) for n in self.m_names]
        self.w_nodes = [_contact(n) for n in self.w_names]
        self.girl_nodes = [_contact(n) for n in self.girl_names]
        self.boy_nodes = [_contact(n) for n in self.boy_names]
        self.m_group = _group('men',*self.m_nodes)
        self.w_group = _group('women',*self.w_nodes)
        self.g_group = _group('girls',*self.girl_nodes)
        self.g_group.add_to_parent(self.w_group)
        self.b_group = _group('boys',*self.boy_nodes)
        self.b_group.add_to_parent(self.m_group)

        self.people_group = _group('people', self.m_group, self.w_group)

        self.all_groups = [
                        self.people_group,
                        self.b_group,
                        self.g_group,
                        self.m_group,
                        self.w_group
                        ]
        
        self.router=MockRouter()
        self.backend=MockBackend(self.router)
        self.uid0='4156661212'
        self.uid1='6175551212'
        self.uid2='6195551212'
Example #3
0
 def setUp(self):
     TestScript.setUp(self)
     location = Location.objects.get(code='de')
     facilitytype = SupplyPointType.objects.get(code='hc')
     facility, created = SupplyPoint.objects.get_or_create(
         code='dedh',
         name='Dangme East District Hospital',
         location=location,
         active=True,
         type=facilitytype,
         supplied_by=None)
     mc = Product.objects.get(sms_code='mc')
     lf = Product.objects.get(sms_code='lf')
     mg = Product.objects.get(sms_code='mg')
     ng = Product.objects.get(sms_code='ng')
     ProductStock(is_active=True,
                  product=mc,
                  supply_point=facility,
                  monthly_consumption=5).save()
     ProductStock(is_active=True,
                  product=lf,
                  supply_point=facility,
                  monthly_consumption=5).save()
     ProductStock(is_active=True,
                  product=mg,
                  supply_point=facility,
                  monthly_consumption=5).save()
     ProductStock(is_active=False,
                  product=ng,
                  supply_point=facility,
                  monthly_consumption=5).save()
     contact = register_user(self, "888", "testuser", "dedh")
     contact.commodities.add(mc)
     contact.commodities.add(lf)
 def tearDown(self):
     Location.objects.all().delete()
     SupplyPoint.objects.all().delete()
     Product.objects.all().delete()
     ProductStock.objects.all().delete()
     StockTransaction.objects.all().delete()
     ProductReport.objects.all().delete()
     TestScript.tearDown(self)
Example #5
0
 def setUp(self):
     TestScript.setUp(self)
     location = Location.objects.get(code='de')
     facilitytype = SupplyPointType.objects.get(code='hc')
     rms = SupplyPoint.objects.get(code='garms')
     SupplyPoint.objects.get_or_create(code='dedh', name='Dangme East District Hospital',
                                    location=location, active=True,
                                    type=facilitytype, supplied_by=rms)
 def tearDown(self):
     Location.objects.all().delete()
     SupplyPoint.objects.all().delete()
     Product.objects.all().delete()
     ProductStock.objects.all().delete()
     StockTransaction.objects.all().delete()
     ProductReport.objects.all().delete()
     TestScript.tearDown(self)
Example #7
0
 def setUp(self):
     TestScript.setUp(self)
     location = Location.objects.get(code='de')
     facilitytype = SupplyPointType.objects.get(code='hc')
     rms = Facility.objects.get(code='garms')
     Facility.objects.get_or_create(code='dedh', name='Dangme East District Hospital',
                                    location=location, active=True,
                                    type=facilitytype, supplied_by=rms)
 def setUp(self):
     TestScript.setUp(self)
     survey = Survey.objects.create(location='test', begin_date=date.today()-timedelta(7), end_date=date.today()+timedelta(7))
     # this is the birthdate used in the tests
     birthdate = date(2008,2,10)
     td = date.today() - birthdate
     # calculate how many months ago so we know what to expect in the
     # confirmation message, since we cannot hard-code the expected reply
     self.months_ago = str(int(td.days/30.4375))
Example #9
0
 def setUp(self):
     # since the database is not nuked, there's no point in reloading these every time
     # this also messes up 13 and 14 which change the db
     # plus the unit tests are waaaay faster
     global loaded
     if not loaded:
         # borrowed from django/test/testcases.py
         call_command('loaddata', *self.fixtures, **{'verbosity': 0})
         loaded = True
     TestScript.setUp(self)
Example #10
0
File: tests.py Project: mberg/mctc
 def setUp (self):
     # since the database is not nuked, there's no point in reloading these every time
     # this also messes up 13 and 14 which change the db
     # plus the unit tests are waaaay faster
     global loaded
     if not loaded:
         # borrowed from django/test/testcases.py
         call_command('loaddata', *self.fixtures, **{'verbosity': 0})            
         loaded = True
     TestScript.setUp(self)
Example #11
0
 def setUp(self):
     settings.LOGISTICS_STOCKED_BY = 'user'
     TestScript.setUp(self)
     load_test_data()
     self.facility = SupplyPoint.objects.get(code='dedh')
     prod_type = ProductType.objects.all()[0]
     self.commodity, created = Product.objects.get_or_create(
       sms_code='ab', name='Drug A', type=prod_type, units='cycle')
     self.commodity2, created = Product.objects.get_or_create(
       sms_code='cd', name='Drug B', type=prod_type, units='cycle')
     self.contact = register_user(self, '8282', 'tester', self.facility.code, self.facility.name)
    def setUp(self):
        TestScript.setUp(self)

        load_test_data()
        
        settings.LOGISTICS_CONSUMPTION["MINIMUM_DAYS"] = 10
        settings.LOGISTICS_CONSUMPTION["MINIMUM_TRANSACTIONS"] = 2
        settings.LOGISTICS_CONSUMPTION["LOOKBACK_DAYS"] = None
        settings.LOGISTICS_CONSUMPTION["INCLUDE_END_STOCKOUTS"] = False
        
        self.pr = Product.objects.all()[0]
        self.sp = Facility.objects.all()[0]
        self.ps = ProductStock.objects.get(supply_point=self.sp, product=self.pr)
        self.ps.use_auto_consumption = True
        self.ps.save()
    def setUp(self):
        TestScript.setUp(self)

        load_test_data()

        settings.LOGISTICS_CONSUMPTION["MINIMUM_DAYS"] = 10
        settings.LOGISTICS_CONSUMPTION["MINIMUM_TRANSACTIONS"] = 2
        settings.LOGISTICS_CONSUMPTION["LOOKBACK_DAYS"] = None
        settings.LOGISTICS_CONSUMPTION["INCLUDE_END_STOCKOUTS"] = False

        self.pr = Product.objects.all()[0]
        self.sp = Facility.objects.all()[0]
        self.ps = ProductStock.objects.get(supply_point=self.sp,
                                           product=self.pr)
        self.ps.use_auto_consumption = True
        self.ps.save()
Example #14
0
    def setUp(self):
        settings.LOGISTICS_STOCKED_BY = 'user'
        TestScript.setUp(self)
        location = Location.objects.get(code='de')
        facilitytype = SupplyPointType.objects.get(code='hc')
        self.rms = SupplyPoint.objects.get(code='garms')
        facility, created = SupplyPoint.objects.get_or_create(code='dedh',
                                                           name='Dangme East District Hospital',
                                                           location=location, active=True,
                                                           type=facilitytype, supplied_by=self.rms)
        assert facility.supplied_by == self.rms
        mc = Product.objects.get(sms_code='mc')
        self.lf = Product.objects.get(sms_code='lf')
        ProductStock(product=mc, supply_point=facility,
                     monthly_consumption=8).save()
        ProductStock(product=self.lf, supply_point=facility,
                     monthly_consumption=5).save()
        facility = SupplyPoint(code='tf', name='Test Facility',
                       location=location, active=True,
                       type=facilitytype, supplied_by=self.rms)
        facility.save()
        mc = Product.objects.get(sms_code='mc')
        mg = Product.objects.get(sms_code='mg')
        self.mc_stock = ProductStock(is_active=True, supply_point=facility,
                                    product=mc, monthly_consumption=10)
        self.mc_stock.save()
        self.lf_stock = ProductStock(is_active=True, supply_point=facility,
                                    product=self.lf, monthly_consumption=10)
        self.lf_stock.save()
        self.mg_stock = ProductStock(is_active=False, supply_point=facility,
                                     product=mg, monthly_consumption=10)
        self.mg_stock.save()

        ng = Product.objects.get(sms_code='ng')
        self.ng_stock = ProductStock(is_active=True, supply_point=facility,
                                    product=ng, monthly_consumption=None)
        self.ng_stock.save()
        
        self.contact = Contact(name='test user')
        self.contact.save()
        self.connection = Connection(backend=Backend.objects.all()[0],
                                     identity="888",
                                     contact=self.contact)
        self.connection.save()
        self.contact.supply_point = facility
        self.contact.save()
        self.contact.commodities.add(ng)
Example #15
0
    def setUp(self):
        TestScript.setUp(self)

        # make some nodes and graphs
        # imagine this is users and groups for clarity
        self.m_nodes = [_user(n) for n in self.m_names]
        self.w_nodes = [_user(n) for n in self.w_names]
        self.girl_nodes = [_user(n) for n in self.girl_names]
        self.boy_nodes = [_user(n) for n in self.boy_names]
        self.m_group = _group("men", *self.m_nodes)
        self.w_group = _group("women", *self.w_nodes)
        self.g_group = _group("girls", *self.girl_nodes)
        self.g_group.add_to_parent(self.w_group)
        self.b_group = _group("boys", *self.boy_nodes)
        self.b_group.add_to_parent(self.m_group)

        self.people_group = _group("people", self.m_group, self.w_group)

        # set up Cyclic(A(B(*A,woman),man))
        self.cyc_a = _group("a", self.m_nodes[0])
        self.cyc_b = _group("b", self.cyc_a, self.w_nodes[0])
        self.cyc_a.add_children(self.cyc_b)
        self.cyclic_group = _group("cyclic", self.cyc_a)

        # simple tree
        self.leaf1 = _user("leaf1")
        self.leaf2 = _user("leaf2")
        self.simple_tree = _group("tree", _group("L1", _group("L2", self.leaf1, _group("L3", self.leaf2))))

        self.all_groups = [
            self.simple_tree,
            self.cyclic_group,
            self.cyc_a,
            self.cyc_b,
            self.people_group,
            self.b_group,
            self.g_group,
            self.m_group,
            self.w_group,
        ]
Example #16
0
    def setUp(self):
        TestScript.setUp(self)
            
        # make some nodes and graphs
        # imagine this is users and groups for clarity
        self.m_nodes = [user(n) for n in self.m_names]
        self.w_nodes = [user(n) for n in self.w_names]
        self.girl_nodes = [user(n) for n in self.girl_names]
        self.boy_nodes = [user(n) for n in self.boy_names]
        self.m_group = group('men',*self.m_nodes)
        self.w_group = group('women',*self.w_nodes)
        self.g_group = group('girls',*self.girl_nodes)
        self.g_group.add_to_parent(self.w_group)
        self.b_group = group('boys',*self.boy_nodes)
        self.b_group.add_to_parent(self.m_group)

        self.people_group = group('people', self.m_group, self.w_group)

        # set up Cyclic(A(B(*A,woman),man))
        self.cyc_a=group('a',self.m_nodes[0])
        self.cyc_b=group('b',self.cyc_a,self.w_nodes[0])
        self.cyc_a.add_children(self.cyc_b)
        self.cyclic_group=group('cyclic',self.cyc_a)
               
        # simple tree 
        self.leaf1=user('leaf1')
        self.leaf2=user('leaf2')
        self.simple_tree=group('tree', group('L1',group('L2',self.leaf1, group('L3',self.leaf2))))
        
        self.all_groups = [
                        self.simple_tree,
                        self.cyclic_group,
                        self.cyc_a,
                        self.cyc_b,
                        self.people_group,
                        self.b_group,
                        self.g_group,
                        self.m_group,
                        self.w_group
                        ]
Example #17
0
 def setUp(self):
     TestScript.setUp(self)
     location = Location.objects.get(code='de')
     facilitytype = SupplyPointType.objects.get(code='hc')
     facility, created = SupplyPoint.objects.get_or_create(code='dedh',
                                     name='Dangme East District Hospital',
                                     location=location, active=True,
                                     type=facilitytype, supplied_by=None)
     mc = Product.objects.get(sms_code='mc')
     lf = Product.objects.get(sms_code='lf')
     mg = Product.objects.get(sms_code='mg')
     ng = Product.objects.get(sms_code='ng')
     ProductStock(is_active=True, product=mc, supply_point=facility,
                  monthly_consumption=5).save()
     ProductStock(is_active=True, product=lf, supply_point=facility,
                  monthly_consumption=5).save()
     ProductStock(is_active=True, product=mg, supply_point=facility,
                  monthly_consumption=5).save()
     ProductStock(is_active=False, product=ng, supply_point=facility,
                  monthly_consumption=5).save()
     contact = register_user(self, "888", "testuser", "dedh")
     contact.commodities.add(mc)
     contact.commodities.add(lf)
Example #18
0
 def setUp(self):
     TestScript.setUp(self)
     DeliveryGroup.objects.all().delete()
Example #19
0
 def tearDown(self):
     TestScript.tearDown(self)
     self.mc_stock.delete()
     self.mg_stock.delete()
     self.lf_stock.delete()
Example #20
0
    def setUp(self):
        settings.LOGISTICS_STOCKED_BY = 'user'
        TestScript.setUp(self)
        location = Location.objects.get(code='de')
        facilitytype = SupplyPointType.objects.get(code='hc')
        self.rms = SupplyPoint.objects.get(code='garms')
        facility, created = SupplyPoint.objects.get_or_create(
            code='dedh',
            name='Dangme East District Hospital',
            location=location,
            active=True,
            type=facilitytype,
            supplied_by=self.rms)
        assert facility.supplied_by == self.rms
        mc = Product.objects.get(sms_code='mc')
        self.lf = Product.objects.get(sms_code='lf')
        ProductStock(product=mc, supply_point=facility,
                     monthly_consumption=8).save()
        ProductStock(product=self.lf,
                     supply_point=facility,
                     monthly_consumption=5).save()
        facility = SupplyPoint(code='tf',
                               name='Test Facility',
                               location=location,
                               active=True,
                               type=facilitytype,
                               supplied_by=self.rms)
        facility.save()
        mc = Product.objects.get(sms_code='mc')
        mg = Product.objects.get(sms_code='mg')
        self.mc_stock = ProductStock(is_active=True,
                                     supply_point=facility,
                                     product=mc,
                                     monthly_consumption=10)
        self.mc_stock.save()
        self.lf_stock = ProductStock(is_active=True,
                                     supply_point=facility,
                                     product=self.lf,
                                     monthly_consumption=10)
        self.lf_stock.save()
        self.mg_stock = ProductStock(is_active=False,
                                     supply_point=facility,
                                     product=mg,
                                     monthly_consumption=10)
        self.mg_stock.save()

        ng = Product.objects.get(sms_code='ng')
        self.ng_stock = ProductStock(is_active=True,
                                     supply_point=facility,
                                     product=ng,
                                     monthly_consumption=None)
        self.ng_stock.save()

        self.contact = Contact(name='test user')
        self.contact.save()
        self.connection = Connection(backend=Backend.objects.all()[0],
                                     identity="888",
                                     contact=self.contact)
        self.connection.save()
        self.contact.supply_point = facility
        self.contact.save()
        self.contact.commodities.add(ng)
Example #21
0
 def setUp(self):
     TestScript.setUp(self)
     ville = Village(name='nonexistant1')
     ville.save()
     ville = Village(name='nonexistant2')
     ville.save()
Example #22
0
 def setUp(self):
     TestScript.setUp(self)
Example #23
0
 def tearDown(self):
     ProductStock.objects.all().delete()
     TestScript.tearDown(self)
Example #24
0
 def setUp(self):
     TestScript.setUp(self)
     ServiceDeliveryPoint.objects.all().delete()
Example #25
0
 def setUp(self):
     TestScript.setUp(self)
     load_test_data()
     settings.LOGISTICS_STOCKED_BY = "user"
Example #26
0
 def setUp(self):
     TestScript.setUp(self)
     load_test_data()
     self.facility = SupplyPoint.objects.get(code='dedh')
     settings.LOGISTICS_STOCKED_BY = 'user'
Example #27
0
 def setUp(self):
     TestScript.setUp(self)
     EventSchedule.objects.all().delete()
Example #28
0
 def setUp(self):
     global callback_counter
     callback_counter = 0
     TestScript.setUp(self)
     EventSchedule.objects.all().delete()
 def setUp(self):
     TestScript.setUp(self)
     load_test_data()
Example #30
0
 def setUp(self):
     TestScript.setUp(self)
     load_test_data()
     settings.LOGISTICS_STOCKED_BY = 'user'
Example #31
0
 def setUp(self):
     global callback_counter
     callback_counter = 0
     TestScript.setUp(self)
     EventSchedule.objects.all().delete()
Example #32
0
 def setUp(self):
     TestScript.setUp(self)
     EventSchedule.objects.all().delete()
Example #33
0
 def setUp(self):
     TestScript.setUp(self)
     DeliveryGroup.objects.all().delete()
 def setUp(self):
     TestScript.setUp(self)
     load_test_data()
Example #35
0
 def tearDown(self):
     ProductStock.objects.all().delete()
     TestScript.tearDown(self)
Example #36
0
 def tearDown(self):
     TestScript.tearDown(self)
     self.mc_stock.delete()
     self.mg_stock.delete()
     self.lf_stock.delete()
Example #37
0
 def setUp(self):
     TestScript.setUp(self)
     ServiceDeliveryPoint.objects.all().delete()
Example #38
0
 def setUp(self):
     TestScript.setUp(self)
Example #39
0
 def setUp(self):
     TestScript.setUp(self)
     load_test_data()
     self.facility = SupplyPoint.objects.get(code='dedh')
     settings.LOGISTICS_STOCKED_BY = 'user'