def test_parse_v0_valueerror_bad_type(self): with self.assertRaises(ValueError): migrate_params({ "column": "A", "refine": json.dumps([{ "type": "selec", "column": "A", "content": { "value": "x" } }]), })
def test_parse_v0_valueerror_bad_change_no_content_key(self): with self.assertRaises(ValueError): migrate_params({ "column": "A", "refine": json.dumps([{ "type": "change", "column": "A", "contentx": { "fromVal": "x", "toVal": "y" }, }]), })
def _test_parse_v2(self, column: str, arr: Dict[str, Any], expected: RefineSpec) -> None: result = migrate_params({"column": column, "refine": arr}) self.assertEqual(result["column"], column) refine = result["refine"] self.assertEqual(refine["renames"], expected.renames) self.assertTrue("blackist" not in refine) self.assertEqual(len(refine.keys()), 1)
def _test_parse_v0(self, column: str, arr: List[Dict[str, Any]], expected: RefineSpec) -> None: """ Test that deprecated input is transformed into what the user expects. """ result = migrate_params({"column": column, "refine": json.dumps(arr)}) self.assertEqual(result["column"], column) refine = result["refine"] self.assertEqual(refine["renames"], expected.renames)
def test_parse_v1(self): result = migrate_params({ "column": "A", "refine": '{"renames": {"a": "b"}, "blacklist": []}' }) self.assertEqual(result, { "column": "A", "refine": { "renames": { "a": "b" } } })
def test_parse_v1_empty_refine(self): result = migrate_params({"column": "A", "refine": ""}) self.assertEqual(result, {"column": "A", "refine": {"renames": {}}})
def test_parse_v0_valueerror_not_dict(self): with self.assertRaises(ValueError): migrate_params({"column": "A", "refine": json.dumps("A")})