Ejemplo n.º 1
0
 def test_params_filename_to_thrift(self):
     path = self.basedir / "x.bin"
     self.assertEqual(
         types.Params({
             "A": path
         }).to_thrift(),
         {"A": ttypes.ParamValue(filename_value="x.bin")},
     )
Ejemplo n.º 2
0
 def test_params_filename_from_thrift_happy_path(self):
     with tempfile.NamedTemporaryFile(dir=self.basedir) as tf:
         path = Path(tf.name)
         path.write_bytes(b"")
         self.assertEqual(
             types.Params.from_thrift(
                 {"A": ttypes.ParamValue(filename_value=path.name)}, self.basedir
             ),
             types.Params({"A": path}),
         )
Ejemplo n.º 3
0
 def test_params_filename_from_thrift_file_not_found_is_error(self):
     with self.assertRaisesRegexp(ValueError, "file must exist"):
         types.Params.from_thrift(
             {"A": ttypes.ParamValue(filename_value="does_not_exist")}, self.basedir
         )
Ejemplo n.º 4
0
 def test_params_to_thrift(self):
     self.assertEqual(
         types.Params(
             {
                 "str": "s",
                 "int": 2,
                 "float": 1.2,
                 "null": None,
                 "bool": False,
                 "column": types.Column(
                     "A", types.ColumnType.Number(format="{:,.2f}")
                 ),
                 "listofmaps": [{"A": "a", "B": "b"}, {"C": "c", "D": "d"}],
                 "tab": "TODO tabs",
             }
         ).to_thrift(),
         {
             "str": ttypes.ParamValue(string_value="s"),
             "int": ttypes.ParamValue(integer_value=2),
             "float": ttypes.ParamValue(float_value=1.2),
             "null": ttypes.ParamValue(),
             "bool": ttypes.ParamValue(boolean_value=False),
             "column": ttypes.ParamValue(
                 column_value=ttypes.Column(
                     "A",
                     ttypes.ColumnType(
                         number_type=ttypes.ColumnTypeNumber(format="{:,.2f}")
                     ),
                 )
             ),
             "listofmaps": ttypes.ParamValue(
                 list_value=[
                     ttypes.ParamValue(
                         map_value={
                             "A": ttypes.ParamValue(string_value="a"),
                             "B": ttypes.ParamValue(string_value="b"),
                         }
                     ),
                     ttypes.ParamValue(
                         map_value={
                             "C": ttypes.ParamValue(string_value="c"),
                             "D": ttypes.ParamValue(string_value="d"),
                         }
                     ),
                 ]
             ),
             "tab": ttypes.ParamValue(string_value="TODO tabs"),
         },
     )