def test_all_locator_methods_described(self): schemas = cea.schemas.schemas(plugins=[]) config = cea.config.Configuration() locator = cea.inputlocator.InputLocator(config.scenario) for method in extract_locator_methods(locator): self.assertIn(method, schemas.keys())
def test_each_column_has_type(self): schemas = cea.schemas.schemas(plugins=[]) valid_types = { "string", "int", "boolean", "float", "date", "Point", "Polygon", "LineString" } for lm in schemas.keys(): if lm in SKIP_LMS: # these can't be documented properly due to the file format continue schema = schemas[lm]["schema"] if schemas[lm]["file_type"] in {"xls", "xlsx"}: for ws in schema.keys(): ws_schema = schema[ws]["columns"] for col in ws_schema.keys(): self.assertIn( "type", ws_schema[col], "Missing type definition for {lm}/{ws}/{col}". format(lm=lm, ws=ws, col=col)) col_type = ws_schema[col]["type"] self.assertIn( col_type, valid_types, "Invalid type definition for {lm}/{ws}/{col}: {type}" .format(lm=lm, ws=ws, col=col, type=col_type)) elif schemas[lm]["file_type"] in {"shp", "dbf", "csv"}: for col in schema["columns"].keys(): self.assertIn( "type", schema["columns"][col], "Missing type definition for {lm}/{col}".format( lm=lm, col=col)) col_type = schema["columns"][col]["type"] self.assertIn( col_type, valid_types, "Invalid type definition for {lm}/{col}: {type}". format(lm=lm, col=col, type=col_type))
def test_all_schema_columns_documented(self): schemas = cea.schemas.schemas(plugins=[]) for lm in schemas.keys(): if lm in SKIP_LMS: # these can't be documented properly due to the file format continue schema = schemas[lm]["schema"] if schemas[lm]["file_type"] in {"xls", "xlsx"}: for ws in schema.keys(): ws_schema = schema[ws]["columns"] for col in ws_schema.keys(): self.assertNotEqual( ws_schema[col]["description"].strip(), "TODO", "Missing description for {lm}/{ws}/{col}/description" .format(lm=lm, ws=ws, col=col)) self.assertNotEqual( ws_schema[col]["unit"].strip(), "TODO", "Missing description for {lm}/{ws}/{col}/unit". format(lm=lm, ws=ws, col=col)) self.assertNotEqual( ws_schema[col]["values"].strip(), "TODO", "Missing description for {lm}/{ws}/{col}/description" .format(lm=lm, ws=ws, col=col)) elif schemas[lm]["file_type"] in {"shp", "dbf", "csv"}: for col in schema["columns"].keys(): try: self.assertNotEqual( schema["columns"][col]["description"].strip(), "TODO", "Missing description for {lm}/{col}/description". format(lm=lm, col=col)) self.assertNotEqual( schema["columns"][col]["unit"].strip(), "TODO", "Missing description for {lm}/{col}/description". format(lm=lm, col=col)) self.assertNotEqual( schema["columns"][col]["values"].strip(), "TODO", "Missing description for {lm}/{col}/description". format(lm=lm, col=col)) except BaseException as e: self.fail( "Problem with lm={lm}, col={col}, message: {m}". format(lm=lm, col=col, m=e))