class StockReportDomainTest(TestCase): def _get_name_for_domain(self): return ''.join( random.choice(string.ascii_lowercase) for _ in range(DOMAIN_MAX_LENGTH)) def setUp(self): self.domain = self._get_name_for_domain() self.form = XFormInstance(domain=self.domain) self.form.save() self.new_stock_report = NewStockReport( self.form, datetime.now(), REPORT_TYPE_BALANCE, [], ) def tearDown(self): self.form.delete() StockReport.objects.all().delete() def test_stock_report(self): self.new_stock_report.create_models() filtered_stock_report = StockReport.objects.filter(domain=self.domain) self.assertEquals(filtered_stock_report.count(), 1) stock_report = filtered_stock_report.get() self.assertEquals(stock_report.form_id, self.form._id) self.assertEquals(stock_report.domain, self.domain)
class StockReportDomainTest(TestCase): def _get_name_for_domain(self): return ''.join( random.choice(string.ascii_lowercase) for _ in range(DOMAIN_MAX_LENGTH) ) def setUp(self): self.domain = self._get_name_for_domain() self.form = XFormInstance(domain=self.domain) self.form.save() self.new_stock_report = NewStockReport( self.form, datetime.now(), REPORT_TYPE_BALANCE, [], ) def tearDown(self): self.form.delete() StockReport.objects.all().delete() def test_stock_report(self): self.new_stock_report.create_models() filtered_stock_report = StockReport.objects.filter(domain=self.domain) self.assertEquals(filtered_stock_report.count(), 1) stock_report = filtered_stock_report.get() self.assertEquals(stock_report.form_id, self.form._id) self.assertEquals(stock_report.domain, self.domain)
def setUp(self): self.domain = self._get_name_for_domain() self.form = XFormInstance(domain=self.domain) self.form.save() self.new_stock_report = NewStockReport( self.form, datetime.now(), REPORT_TYPE_BALANCE, [], )
def unpack_commtrack(xform, config): xml = xform.get_xml_element() def commtrack_nodes(node): for child in node: if child.tag.startswith('{%s}' % COMMTRACK_REPORT_XMLNS): yield child else: for e in commtrack_nodes(child): yield e for elem in commtrack_nodes(xml): yield NewStockReport.from_xml(xform, config, elem)