def test_load_serialized_pb_as_proto(): expected = cpb.FtpSource() expected.address = "abcd" with TemporaryDirectory() as tmp_dir: path = Path(tmp_dir).joinpath("ftp.pb") with open(path, 'wb') as tmp_file: tmp_file.write(expected.SerializeToString()) actual = proto_util.load_serialized_pb_as_proto( path=path, proto_obj=cpb.FtpSource() ) assert actual == expected
def test_load_text_as_proto(): expected = cpb.FtpSource() expected.address = "abcd" with TemporaryDirectory() as tmp_dir: path = Path(tmp_dir).joinpath("ftp.config") with open(path, 'w') as tmp_file: tmp_file.write(""" address: "abcd" """) actual = proto_util.load_text_as_proto( path=path, proto_obj=cpb.FtpSource() ) assert actual == expected
def test_set_field_unnested(): expected = cpb.FtpSource() expected.address = "new_addr_val" actual = cpb.FtpSource() proto_util.set_field(actual, "address", "new_addr_val") assert actual == expected
def test_parse_proto_fields_ftp_source(): expected = set(["address", "workdir"]) actual = set(proto_util.get_full_field_names(cpb.FtpSource())) assert actual == expected