コード例 #1
0
 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"
                 }
             }]),
         })
コード例 #2
0
 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"
                 },
             }]),
         })
コード例 #3
0
 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)
コード例 #4
0
 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)
コード例 #5
0
 def test_parse_v1(self):
     result = migrate_params({
         "column":
         "A",
         "refine":
         '{"renames": {"a": "b"}, "blacklist": []}'
     })
     self.assertEqual(result, {
         "column": "A",
         "refine": {
             "renames": {
                 "a": "b"
             }
         }
     })
コード例 #6
0
 def test_parse_v1_empty_refine(self):
     result = migrate_params({"column": "A", "refine": ""})
     self.assertEqual(result, {"column": "A", "refine": {"renames": {}}})
コード例 #7
0
 def test_parse_v0_valueerror_not_dict(self):
     with self.assertRaises(ValueError):
         migrate_params({"column": "A", "refine": json.dumps("A")})