How to use _load_case method in stestr

Best Python code snippet using stestr_python

test_homevisits.py

Source:test_homevisits.py Github

copy

Full Screen

...15 'bp1_due': '2013-01-22', 'bp1_done': '2013-01-22', 'bp1_days_overdue': '0',16 'bp2_due': '2013-03-22', 'bp2_done': '2013-03-22', 'bp2_days_overdue': '0',17 'bp3_due': '2013-06-22', 'bp3_done': '2013-06-22', 'bp3_days_overdue': '0',18 }19 case = self._load_case('test_bihar_bp.json', dates)20 indicator.calculate(case)21 bp2 = indicator.bp222 [total] = bp2['total']23 self.assertEqual(date(2013, 3, 22), total['date'])24 self.assertEqual(1, total['value'])25 [numerator] = bp2['numerator']26 self.assertEqual(date(2013, 3, 22), numerator['date'])27 self.assertEqual(1, numerator['value'])28 bp3 = indicator.bp329 self.assertEqual(1, len(bp3['total']))30 [total] = bp3['total']31 self.assertEqual(date(2013, 6, 22), total['date'])32 self.assertEqual(1, total['value'])33 [numerator] = bp3['numerator']34 self.assertEqual(date(2013, 6, 22), numerator['date'])35 self.assertEqual(1, numerator['value'])36 self.assertIndicatorsEmpty(indicator)37 def testBPAllInFirstTri(self):38 indicator = CareBiharFluff()39 dates = {40 'bp1_due': '2013-01-21', 'bp1_done': '2013-01-21', 'bp1_days_overdue': '0',41 'bp2_due': '2013-01-22', 'bp2_done': '2013-01-22', 'bp2_days_overdue': '0',42 'bp3_due': '2013-01-23', 'bp3_done': '2013-01-23', 'bp3_days_overdue': '0',43 }44 case = self._load_case('test_bihar_bp.json', dates)45 indicator.calculate(case)46 self.assertIndicatorsEmpty(indicator, vals=('bp2', 'bp3', 'pnc', 'ebf', 'cf'))47 def testBPAllInSecondTri(self):48 indicator = CareBiharFluff()49 dates = {50 'bp1_due': '2013-03-21', 'bp1_done': '2013-03-21', 'bp1_days_overdue': '0',51 'bp2_due': '2013-03-22', 'bp2_done': '2013-03-22', 'bp2_days_overdue': '0',52 'bp3_due': '2013-03-23', 'bp3_done': '2013-03-23', 'bp3_days_overdue': '0',53 }54 case = self._load_case('test_bihar_bp.json', dates)55 indicator.calculate(case)56 bp2 = indicator.bp257 self.assertEqual(3, len(bp2['total']))58 [v1, v2, v3] = bp2['total']59 self.assertEqual(date(2013, 3, 21), v1['date'])60 self.assertEqual(date(2013, 3, 22), v2['date'])61 self.assertEqual(date(2013, 3, 23), v3['date'])62 for res in bp2['total']:63 self.assertEqual(1, res['value'])64 self.assertEqual(3, len(bp2['numerator']))65 [v1, v2, v3] = bp2['numerator']66 self.assertEqual(date(2013, 3, 21), v1['date'])67 self.assertEqual(date(2013, 3, 22), v2['date'])68 self.assertEqual(date(2013, 3, 23), v3['date'])69 for res in bp2['total']:70 self.assertEqual(1, res['value'])71 self.assertIndicatorsEmpty(indicator, vals=('bp3', 'pnc', 'ebf', 'cf'))72 def testBPAllInThirdTri(self):73 indicator = CareBiharFluff()74 dates = {75 'bp1_due': '2013-06-21', 'bp1_done': '2013-06-21', 'bp1_days_overdue': '0',76 'bp2_due': '2013-06-22', 'bp2_done': '2013-06-22', 'bp2_days_overdue': '0',77 'bp3_due': '2013-06-23', 'bp3_done': '2013-06-23', 'bp3_days_overdue': '0',78 }79 case = self._load_case('test_bihar_bp.json', dates)80 indicator.calculate(case)81 bp3 = indicator.bp382 self.assertEqual(3, len(bp3['total']))83 [v1, v2, v3] = bp3['total']84 self.assertEqual(date(2013, 6, 21), v1['date'])85 self.assertEqual(date(2013, 6, 22), v2['date'])86 self.assertEqual(date(2013, 6, 23), v3['date'])87 for res in bp3['total']:88 self.assertEqual(1, res['value'])89 self.assertEqual(3, len(bp3['numerator']))90 [v1, v2, v3] = bp3['numerator']91 self.assertEqual(date(2013, 6, 21), v1['date'])92 self.assertEqual(date(2013, 6, 22), v2['date'])93 self.assertEqual(date(2013, 6, 23), v3['date'])94 for res in bp3['total']:95 self.assertEqual(1, res['value'])96 self.assertIndicatorsEmpty(indicator, vals=('bp2', 'pnc', 'ebf', 'cf'))97 def testVisitBounds(self):98 # test dates around the +/- 10 day window and make sure they are/aren't counted99 out_of_bounds = ['2013-03-11', '2013-04-04']100 for oob in out_of_bounds:101 indicator = CareBiharFluff()102 dates = {103 'bp1_due': '2013-01-22', 'bp1_done': '2013-01-22', 'bp1_days_overdue': '0',104 'bp2_due': '2013-03-22', 'bp2_done': oob, 'bp2_days_overdue': '0',105 'bp3_due': '2013-06-22', 'bp3_done': '2013-06-22', 'bp3_days_overdue': '0',106 }107 case = self._load_case('test_bihar_bp.json', dates)108 indicator.calculate(case)109 bp2 = indicator.bp2110 [total] = bp2['total']111 self.assertEqual(date(2013, 3, 22), total['date'])112 self.assertEqual(1, total['value'])113 self.assertEqual(0, len(bp2['numerator']))114 in_bounds = ['2013-03-13', '2013-04-01']115 for ib in in_bounds:116 indicator = CareBiharFluff()117 dates = {118 'bp1_due': '2013-01-22', 'bp1_done': '2013-01-22', 'bp1_days_overdue': '0',119 'bp2_due': '2013-03-22', 'bp2_done': ib, 'bp2_days_overdue': '0',120 'bp3_due': '2013-06-22', 'bp3_done': '2013-06-22', 'bp3_days_overdue': '0',121 }122 case = self._load_case('test_bihar_bp.json', dates)123 indicator.calculate(case)124 bp2 = indicator.bp2125 [total] = bp2['total']126 self.assertEqual(date(2013, 3, 22), total['date'])127 self.assertEqual(1, total['value'])128 [numerator] = bp2['numerator']129 self.assertEqual(date(2013, 3, 22), numerator['date'])130 self.assertEqual(1, numerator['value'])131 def assertIndicatorsEmpty(self, indicator, vals=None):132 vals = vals or ('pnc', 'ebf', 'cf')133 for attr in vals:134 results = getattr(indicator, attr)135 self.assertEqual(0, len(results['total']))136 self.assertEqual(0, len(results['numerator']))137 def _load_case(self, filename, format_dict=None):138 format_dict = format_dict or {}139 fullpath = os.path.join(os.path.dirname(__file__), 'data', 'cases', filename)140 with open(fullpath, 'r') as f:141 raw = f.read()142 formatted = raw % format_dict...

Full Screen

Full Screen

test_language.py

Source:test_language.py Github

copy

Full Screen

...16 "no support for language with code 'zz'"):17 _load_stopwords(lang='zz')18class TestLoadCase(unittest.TestCase):19 def test_load_case_en_hi(self):20 self.assertEqual(_load_case(lang='en'), 'exists')21 self.assertEqual(_load_case(lang='hi'), 'notdefined')22 def test_load_case_invalid_code(self):23 with self.assertRaisesRegex(ValueError, "invalid language code 'zzz'"):24 _load_case(lang='zzz')25 with self.assertRaisesRegex(ValueError, "invalid language code 'z'"):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run stestr automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful