def test_no_scenarios_raises_valueerror(self): f = ContentFile('<data>' '<ProcessDate><Date>20170403</Date></ProcessDate>' '<Scenarios></Scenarios>' '</data>') with self.assertRaises(ValueError): CoverSheet(f)
def test_date(self): f = ContentFile('<data>' '<ProcessDate><Date>20170403</Date></ProcessDate>' '<Scenarios>' '<Scenario>' '<ScenarioNo>0</ScenarioNo>' '<AdjustedRates>3.25</AdjustedRates>' '<AdjustedPoints>1.75</AdjustedPoints>' '</Scenario>' '</Scenarios>' '</data>') self.assertEqual(CoverSheet(f).date, date(2017, 4, 3))
def test_empty_scenario(self): f = ContentFile('<data>' '<ProcessDate><Date>20170403</Date></ProcessDate>' '<Scenarios>' '<Scenario>' '<ScenarioNo>0</ScenarioNo>' '<AdjustedRates/>' '<AdjustedPoints/>' '</Scenario>' '</Scenarios>' '</data>') sheet = CoverSheet(f) self.assertEqual(len(sheet.expected_scenario_results), 1) self.assertEqual(sheet.expected_scenario_results[0], (None, None))
def test_scenarios(self): f = ContentFile('<data>' '<ProcessDate><Date>20170403</Date></ProcessDate>' '<Scenarios>' '<Scenario>' '<ScenarioNo>0</ScenarioNo>' '<AdjustedRates>3.25</AdjustedRates>' '<AdjustedPoints>1.75</AdjustedPoints>' '</Scenario>' '<Scenario>' '<ScenarioNo>1</ScenarioNo>' '<AdjustedRates>1.90</AdjustedRates>' '<AdjustedPoints>3.75</AdjustedPoints>' '</Scenario>' '</Scenarios>' '</data>') sheet = CoverSheet(f) self.assertEqual(len(sheet.expected_scenario_results), 2) self.assertEqual(sheet.expected_scenario_results[0], ('3.25', '1.75')) self.assertEqual(sheet.expected_scenario_results[1], ('1.90', '3.75'))
def test_scenarios(self): f = ContentFile("<data>" "<ProcessDate><Date>20170403</Date></ProcessDate>" "<Scenarios>" "<Scenario>" "<ScenarioNo>0</ScenarioNo>" "<AdjustedRates>3.25</AdjustedRates>" "<AdjustedPoints>1.75</AdjustedPoints>" "</Scenario>" "<Scenario>" "<ScenarioNo>1</ScenarioNo>" "<AdjustedRates>1.90</AdjustedRates>" "<AdjustedPoints>3.75</AdjustedPoints>" "</Scenario>" "</Scenarios>" "</data>") sheet = CoverSheet(f) self.assertEqual(len(sheet.expected_scenario_results), 2) self.assertEqual(sheet.expected_scenario_results[0], ("3.25", "1.75")) self.assertEqual(sheet.expected_scenario_results[1], ("1.90", "3.75"))
def test_invalid_date_raises_valueerror(self): f = ContentFile('<data>' '<ProcessDate><Date>foo</Date></ProcessDate>' '</data>') with self.assertRaises(ValueError): CoverSheet(f)
def test_missing_date_raises_valueerror(self): f = ContentFile('<data></data>') with self.assertRaises(ValueError): CoverSheet(f)
def test_invalid_xml_file_raises_parseerror(self): f = ContentFile('foo') with self.assertRaises(ParseError): CoverSheet(f)
def test_null_file_raises_typeerror(self): with self.assertRaises(TypeError): CoverSheet(None)
def test_missing_scenarios_raises_valueerror(self): f = ContentFile("<data>" "<ProcessDate><Date>20170403</Date></ProcessDate>" "</data>") with self.assertRaises(ValueError): CoverSheet(f)