def test_valid_spec(self): f = open("files/spec_valid.json", "r") spec = fwtSpec.FwtSpec(f) f.close() assert len(spec.offsets) == 10 assert len(spec.column_names) == 10 assert spec.include_header != "", True assert spec.encoding_format_fwt != "", True assert spec.encoding_format_del != "", True
def __init__(self, fwt_spec_file_name=None): if fwt_spec_file_name is None: path_fwt_spec_path = Path( __file__).parent.parent / "config/spec.json" fwt_spec_file_name = str(path_fwt_spec_path) logging.info("Fwt with default spec file.") f = open(fwt_spec_file_name, "r") spec = fwtSpec.FwtSpec(f) self.spec = spec
def test_invalid_spec_data(self): f = open("files/spec_invalid1.json", "r") fwtSpec.FwtSpec(f) f.close() pytest.raises(KeyError)
def test_invalid_spec(self): fwtSpec.FwtSpec("xyz") pytest.raises(AttributeError)
def test_invalid_file_type(self): f = open("files/spec_invalid4.txt", "r") fwtSpec.FwtSpec(f) f.close() pytest.raises(ValueError)
def test_invalid_json_content(self): f = open("files/spec_invalid3.json", "r") fwtSpec.FwtSpec(f) f.close() pytest.raises(ValueError)