예제 #1
0
 def test_no_scenarios_raises_valueerror(self):
     f = ContentFile('<data>'
                     '<ProcessDate><Date>20170403</Date></ProcessDate>'
                     '<Scenarios></Scenarios>'
                     '</data>')
     with self.assertRaises(ValueError):
         CoverSheet(f)
예제 #2
0
 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))
예제 #3
0
 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))
예제 #4
0
 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'))
예제 #5
0
 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"))
예제 #6
0
 def test_invalid_date_raises_valueerror(self):
     f = ContentFile('<data>'
                     '<ProcessDate><Date>foo</Date></ProcessDate>'
                     '</data>')
     with self.assertRaises(ValueError):
         CoverSheet(f)
예제 #7
0
 def test_missing_date_raises_valueerror(self):
     f = ContentFile('<data></data>')
     with self.assertRaises(ValueError):
         CoverSheet(f)
예제 #8
0
 def test_invalid_xml_file_raises_parseerror(self):
     f = ContentFile('foo')
     with self.assertRaises(ParseError):
         CoverSheet(f)
예제 #9
0
 def test_null_file_raises_typeerror(self):
     with self.assertRaises(TypeError):
         CoverSheet(None)
예제 #10
0
 def test_missing_scenarios_raises_valueerror(self):
     f = ContentFile("<data>"
                     "<ProcessDate><Date>20170403</Date></ProcessDate>"
                     "</data>")
     with self.assertRaises(ValueError):
         CoverSheet(f)