def test_validate_missing_datapackage_resource_file(self): # GIVEN datapackage without resource file on disk invalid_dp = datapackage.DataPackage({ "name": "some-datapackage", "resources": [{ "name": "res-asd", "path": "./data/some_data.csv" }] }) # AND client client = Client(dp1_path) client.datapackage = invalid_dp # WHEN validate() is invoked try: result = client.validate() except Exception as e: result = e # THEN ResourceDoesNotExist should be raised assert isinstance(result, ResourceDoesNotExist) # AND it should say that resource does not exist assert "data/some_data.csv does not exist on disk" in str(result)
def test_validate_invalid_datapackage_schema(self): # GIVEN invalid datapackage (missing resource path) invalid_dp = datapackage.DataPackage( { "name": "some-datapackage", "resources": [{ "name": "res" }] }, default_base_path='.') # AND client client = Client(dp1_path) client.datapackage = invalid_dp # WHEN validate() is invoked try: result = client.validate() except Exception as e: result = e # THEN ValidationError should be raised assert isinstance(result, ValidationError) # AND it should say some cryptic message on invalid schema assert "not valid under any of the given schemas" in str(result)
def test_skip_validate_non_tabular_data_package(self): client = Client(dp2_path, datavalidate=True) result = client.validate() self.assertTrue(result)