class CalculationTestCase(TestCase): """ Tests calculation using example from the official PDF release of the scales. """ def setUp(self): self.dh = UDHscale(total_length="6000", max_difficulty=3.5, avg_difficulty=1.5, avg_slope=16) self.xc = UXCscale(total_length="42000", max_difficulty=1.5, avg_difficulty=0.5, total_ascent=590, max_slope_uh=8) def test_dh_results(self): """checks if calculated dh results are as expected.""" dh_result = self.dh.get_score() self.assertEqual(dh_result['total_length']['value'], self.dh.total_length) self.assertEqual(dh_result['total_length']['result'], 9) self.assertEqual(dh_result['avg_slope']['value'], self.dh.avg_slope) self.assertEqual(dh_result['avg_slope']['result'], 4.4) self.assertEqual( dh_result['max_difficulty']['value'], self.dh.max_difficulty) self.assertEqual(dh_result['max_difficulty']['result'], 8) self.assertEqual( dh_result['avg_difficulty']['value'], self.dh.avg_difficulty) self.assertEqual(dh_result['avg_difficulty']['result'], 4) self.assertEqual( dh_result['total_score'], 25, "Got an unexpected result for the DH track") def test_xc_results(self): '''checks if calculated XC results are as expected.''' xc_result = self.xc.get_score() self.assertEqual(xc_result['total_length']['value'], float(self.xc.total_length)) self.assertEqual(xc_result['total_length']['result'], 15) self.assertEqual(xc_result['total_ascent']['value'], self.xc.total_ascent) self.assertEqual(xc_result['total_ascent']['result'], 4.4) self.assertEqual(xc_result['max_slope_uh']['value'], self.xc.max_slope_uh) self.assertEqual(xc_result['max_slope_uh']['result'], 0.8) self.assertEqual( xc_result['max_difficulty']['value'], self.xc.max_difficulty) self.assertEqual(xc_result['max_difficulty']['result'], 2) self.assertEqual( xc_result['avg_difficulty']['value'], self.xc.avg_difficulty) self.assertEqual(xc_result['avg_difficulty']['result'], 1.5) self.assertEqual( xc_result['total_score'], 24, "Got an unexpected result for the XC track")
def setUp(self): self.dh = UDHscale(total_length="6000", max_difficulty=3.5, avg_difficulty=1.5, avg_slope=16) self.xc = UXCscale(total_length="42000", max_difficulty=1.5, avg_difficulty=0.5, total_ascent=590, max_slope_uh=8)