17 lines
1.1 KiB
Python
17 lines
1.1 KiB
Python
import pathlib,importlib.util,unittest
|
|
spec=importlib.util.spec_from_file_location('repair',pathlib.Path(__file__).with_name('repair-closed-xp-boundary.py'));m=importlib.util.module_from_spec(spec);spec.loader.exec_module(m)
|
|
class XpBoundary(unittest.TestCase):
|
|
def setUp(self):self.row={'session_open':0,'experience_progress':0.9999995827674866,'experience_level':11,'total_experience':216}
|
|
def test_full_precision_boundary_keeps_total_xp(self):self.assertEqual(m.replacement(self.row),(12,0.0));self.assertEqual(self.row['total_experience'],216)
|
|
def test_active_session_never_repaired(self):
|
|
self.row['session_open']=1
|
|
with self.assertRaises(ValueError):m.replacement(self.row)
|
|
def test_inconsistent_total_not_modified(self):
|
|
self.row['total_experience']=215
|
|
with self.assertRaises(ValueError):m.replacement(self.row)
|
|
def test_normal_progress_not_modified(self):
|
|
self.row['experience_progress']=0.9
|
|
with self.assertRaises(ValueError):m.replacement(self.row)
|
|
def test_vanilla_level_curve_boundaries(self):
|
|
self.assertEqual([m.vanilla_total(n) for n in [0,12,16,17,31,32]],[0,216,352,394,1507,1628])
|
|
if __name__=='__main__':unittest.main()
|

Staff