當前位置: 首頁>>代碼示例>>Python>>正文


Python TestScript.setUp方法代碼示例

本文整理匯總了Python中rapidsms.tests.scripted.TestScript.setUp方法的典型用法代碼示例。如果您正苦於以下問題:Python TestScript.setUp方法的具體用法?Python TestScript.setUp怎麽用?Python TestScript.setUp使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rapidsms.tests.scripted.TestScript的用法示例。


在下文中一共展示了TestScript.setUp方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: setUp

# 需要導入模塊: from rapidsms.tests.scripted import TestScript [as 別名]
# 或者: from rapidsms.tests.scripted.TestScript import setUp [as 別名]
    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'
開發者ID:ewheeler,項目名稱:rapidsms-community-apps,代碼行數:33,代碼來源:tests.py

示例2: setUp

# 需要導入模塊: from rapidsms.tests.scripted import TestScript [as 別名]
# 或者: from rapidsms.tests.scripted.TestScript import setUp [as 別名]
    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='lucy')
        self.supe, self.supe_profile = create_active_reporter_and_profile(backend, self.domain, phone_number="3093", username='supe')
        
        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()
開發者ID:commtrack,項目名稱:temp-aquatest,代碼行數:33,代碼來源:brac.py

示例3: setUp

# 需要導入模塊: from rapidsms.tests.scripted import TestScript [as 別名]
# 或者: from rapidsms.tests.scripted.TestScript import setUp [as 別名]
 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)
開發者ID:andile2012,項目名稱:logistics,代碼行數:10,代碼來源:registration.py

示例4: setUp

# 需要導入模塊: from rapidsms.tests.scripted import TestScript [as 別名]
# 或者: from rapidsms.tests.scripted.TestScript import setUp [as 別名]
 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))
開發者ID:ewheeler,項目名稱:rapidsms-growthmonitoring-app,代碼行數:11,代碼來源:tests.py

示例5: setUp

# 需要導入模塊: from rapidsms.tests.scripted import TestScript [as 別名]
# 或者: from rapidsms.tests.scripted.TestScript import setUp [as 別名]
 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)
開發者ID:mberg,項目名稱:mctc,代碼行數:12,代碼來源:tests.py

示例6: setUp

# 需要導入模塊: from rapidsms.tests.scripted import TestScript [as 別名]
# 或者: from rapidsms.tests.scripted.TestScript import setUp [as 別名]
 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)
開發者ID:andile2012,項目名稱:logistics,代碼行數:13,代碼來源:reminders.py

示例7: setUp

# 需要導入模塊: from rapidsms.tests.scripted import TestScript [as 別名]
# 或者: from rapidsms.tests.scripted.TestScript import setUp [as 別名]
    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()
開發者ID:agrzywinski,項目名稱:rapidsms-logistics,代碼行數:17,代碼來源:consumption.py

示例8: setUp

# 需要導入模塊: from rapidsms.tests.scripted import TestScript [as 別名]
# 或者: from rapidsms.tests.scripted.TestScript import setUp [as 別名]
    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)
開發者ID:andile2012,項目名稱:logistics,代碼行數:49,代碼來源:stockonhand.py

示例9: setUp

# 需要導入模塊: from rapidsms.tests.scripted import TestScript [as 別名]
# 或者: from rapidsms.tests.scripted.TestScript import setUp [as 別名]
    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,
        ]
開發者ID:jwishnie,項目名稱:rapidsms-tostan,代碼行數:42,代碼來源:tests.py

示例10: setUp

# 需要導入模塊: from rapidsms.tests.scripted import TestScript [as 別名]
# 或者: from rapidsms.tests.scripted.TestScript import setUp [as 別名]
    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
                        ]
開發者ID:GunioRobot,項目名稱:rapidsms-tostan,代碼行數:42,代碼來源:basic.py

示例11: setUp

# 需要導入模塊: from rapidsms.tests.scripted import TestScript [as 別名]
# 或者: from rapidsms.tests.scripted.TestScript import setUp [as 別名]
 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)
開發者ID:andile2012,項目名稱:logistics,代碼行數:25,代碼來源:stockedby.py

示例12: setUp

# 需要導入模塊: from rapidsms.tests.scripted import TestScript [as 別名]
# 或者: from rapidsms.tests.scripted.TestScript import setUp [as 別名]
 def setUp(self):
     TestScript.setUp(self)
     load_test_data()
     self.facility = SupplyPoint.objects.get(code='dedh')
     settings.LOGISTICS_STOCKED_BY = 'user'
開發者ID:andile2012,項目名稱:logistics,代碼行數:7,代碼來源:validator.py

示例13: setUp

# 需要導入模塊: from rapidsms.tests.scripted import TestScript [as 別名]
# 或者: from rapidsms.tests.scripted.TestScript import setUp [as 別名]
 def setUp(self):
     global callback_counter
     callback_counter = 0
     TestScript.setUp(self)
     EventSchedule.objects.all().delete()
開發者ID:thoughtworks,項目名稱:rapidsms,代碼行數:7,代碼來源:speedup.py

示例14: setUp

# 需要導入模塊: from rapidsms.tests.scripted import TestScript [as 別名]
# 或者: from rapidsms.tests.scripted.TestScript import setUp [as 別名]
 def setUp(self):
     TestScript.setUp(self)
開發者ID:GunioRobot,項目名稱:rapidsms-tostan,代碼行數:4,代碼來源:tests.py

示例15: setUp

# 需要導入模塊: from rapidsms.tests.scripted import TestScript [as 別名]
# 或者: from rapidsms.tests.scripted.TestScript import setUp [as 別名]
 def setUp(self):
     TestScript.setUp(self)
     load_test_data()
開發者ID:andile2012,項目名稱:logistics,代碼行數:5,代碼來源:requisition_status.py


注:本文中的rapidsms.tests.scripted.TestScript.setUp方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。