本文整理匯總了Python中rapidsms.tests.scripted.TestScript類的典型用法代碼示例。如果您正苦於以下問題:Python TestScript類的具體用法?Python TestScript怎麽用?Python TestScript使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了TestScript類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: setUp
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()
示例2: setUp
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'
示例3: setUp
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)
示例4: tearDown
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)
示例5: setUp
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))
示例6: setUp
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)
示例7: setUp
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)
示例8: setUp
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()
示例9: setUp
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)
示例10: setUp
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
]
示例11: setUp
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,
]
示例12: setUp
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)
示例13: setUp
def setUp(self):
TestScript.setUp(self)
load_test_data()
self.facility = SupplyPoint.objects.get(code='dedh')
settings.LOGISTICS_STOCKED_BY = 'user'
示例14: setUp
def setUp(self):
global callback_counter
callback_counter = 0
TestScript.setUp(self)
EventSchedule.objects.all().delete()
示例15: setUp
def setUp(self):
TestScript.setUp(self)
DeliveryGroup.objects.all().delete()