Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CI test failures in feature/capgen, address pylint warnings #412

Merged
80 changes: 40 additions & 40 deletions test/unit_tests/test_metadata_table.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ def test_bad_type_name(self):

#Exercise
with self.assertRaises(Exception) as context:
tables = parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)
parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)
climbfuji marked this conversation as resolved.
Show resolved Hide resolved

#Verify
#print("The exception is", context.exception)
Expand All @@ -98,8 +98,8 @@ def test_double_header(self):
filename = os.path.join(SAMPLE_FILES_DIR, "double_header.meta")

with self.assertRaises(Exception) as context:
tables = parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)
parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)

#print("The exception is", context.exception)
self.assertTrue('table already contains \'test_host\'' in str(context.exception))
Expand All @@ -110,8 +110,8 @@ def test_bad_dimension(self):
filename = os.path.join(SAMPLE_FILES_DIR, "test_bad_dimension.meta")

with self.assertRaises(Exception) as context:
tables = parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)
parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)

#print("The exception is", context.exception)
self.assertTrue('Invalid \'dimensions\' property value, \'' in str(context.exception))
Expand All @@ -123,8 +123,8 @@ def test_duplicate_variable(self):
"test_duplicate_variable.meta")

with self.assertRaises(Exception) as context:
tables = parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)
parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)

#print("The exception is", context.exception)
self.assertTrue('Invalid (duplicate) standard name in temp_calc_adjust_run, defined at ' in str(context.exception))
Expand All @@ -135,8 +135,8 @@ def test_invalid_intent(self):
filename = os.path.join(SAMPLE_FILES_DIR, "test_invalid_intent.meta")

with self.assertRaises(Exception) as context:
tables = parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)
parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)

#print("The exception is", context.exception)
self.assertTrue('Invalid \'intent\' property value, \'banana\', at ' in str(context.exception))
Expand All @@ -147,8 +147,8 @@ def test_missing_intent(self):
filename = os.path.join(SAMPLE_FILES_DIR, "test_missing_intent.meta")

with self.assertRaises(Exception) as context:
tables = parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)
parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)

#print("The exception is", context.exception)
emsg = "Required property, 'intent', missing, at "
Expand All @@ -160,8 +160,8 @@ def test_missing_units(self):
filename = os.path.join(SAMPLE_FILES_DIR, "test_missing_units.meta")

with self.assertRaises(Exception) as context:
tables = parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)
parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)

#print("The exception is", context.exception)
emsg = "Required property, 'units', missing, at"
Expand All @@ -174,8 +174,8 @@ def test_missing_table_type(self):
"test_missing_table_type.meta")

with self.assertRaises(Exception) as context:
tables = parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)
parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)

#print("The exception is", context.exception)
emsg = "Invalid section type, 'None'"
Expand All @@ -187,8 +187,8 @@ def test_bad_table_type(self):
filename = os.path.join(SAMPLE_FILES_DIR, "test_bad_table_type.meta")

with self.assertRaises(Exception) as context:
tables = parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)
parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)

#print("The exception is", context.exception)
emsg = "Section type, 'host', does not match table type, 'scheme'"
Expand All @@ -201,8 +201,8 @@ def test_missing_table_name(self):
"test_missing_table_name.meta")

with self.assertRaises(Exception) as context:
tables = parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)
parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)

#print("The exception is", context.exception)
emsg = "Section name, 'None', does not match table title, 'test_missing_table_name'"
Expand All @@ -214,8 +214,8 @@ def test_bad_table_key(self):
filename = os.path.join(SAMPLE_FILES_DIR, "test_bad_table_key.meta")

with self.assertRaises(Exception) as context:
tables = parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)
parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)

#print("The exception is", context.exception)
emsg = "Invalid metadata table start property, 'something', at "
Expand All @@ -227,8 +227,8 @@ def test_bad_line_split(self):
filename = os.path.join(SAMPLE_FILES_DIR, "test_bad_line_split.meta")

with self.assertRaises(Exception) as context:
tables = parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)
parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)

#print("The exception is", context.exception)
emsg = "Invalid variable property syntax, \'\', at "
Expand All @@ -240,8 +240,8 @@ def test_unknown_ddt_type(self):
filename = os.path.join(SAMPLE_FILES_DIR, "test_unknown_ddt_type.meta")

with self.assertRaises(Exception) as context:
tables = parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)
parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)

#print("The exception is", context.exception)
emsg = "Unknown DDT type, banana, at "
Expand All @@ -253,8 +253,8 @@ def test_bad_var_property_name(self):
filename = os.path.join(SAMPLE_FILES_DIR, "test_bad_var_property_name.meta")

with self.assertRaises(Exception) as context:
tables = parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)
parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)

#print("The exception is", context.exception)
emsg = "Invalid variable property name, 'none', at "
Expand Down Expand Up @@ -312,8 +312,8 @@ def test_bad_1st_ccpp_arg_table(self):
"test_bad_1st_arg_table_header.meta")

with self.assertRaises(Exception) as context:
tables = parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)
parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)

#print("The exception is", context.exception)
emsg = "Invalid variable property syntax, '[ccpp-farg-table]', at "
Expand All @@ -326,8 +326,8 @@ def test_bad_2nd_ccpp_arg_table(self):
"test_bad_2nd_arg_table_header.meta")

with self.assertRaises(Exception) as context:
tables = parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)
parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)

#print("The exception is", context.exception)
emsg = "Invalid variable property syntax, '[ccpp-farg-table]', at "
Expand All @@ -341,8 +341,8 @@ def test_mismatch_section_table_title(self):
"test_mismatch_section_table_title.meta")

with self.assertRaises(Exception) as context:
tables = parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)
parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)

#print("The exception is", context.exception)
emsg = "Section name, 'test_host', does not match table title, 'banana', at "
Expand All @@ -355,8 +355,8 @@ def test_double_table_properties(self):
"double_table_properties.meta")

with self.assertRaises(Exception) as context:
tables = parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)
parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)

#print("The exception is", context.exception)
emsg = "Duplicate metadata table, test_host, at "
Expand All @@ -369,8 +369,8 @@ def test_missing_table_properties(self):
"missing_table_properties.meta")

with self.assertRaises(Exception) as context:
tables = parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)
parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)

#print("The exception is", context.exception)
emsg = "Invalid CCPP metadata line, '[ccpp-arg-table]', at "
Expand Down Expand Up @@ -407,8 +407,8 @@ def test_invalid_table_properties_type(self):
"test_invalid_table_properties_type.meta")

with self.assertRaises(Exception) as context:
tables = parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)
parse_metadata_file(filename, known_ddts,
self._DUMMY_RUN_ENV)

#print("The exception is", context.exception)
emsg = "Invalid metadata table type, 'banana', at "
Expand Down
10 changes: 7 additions & 3 deletions tests/test_metadata_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
import os
import sys

#sys.path.append(os.path.join(os.path.split(__file__)[0], '../scripts/parse_tools'))
from parse_checkers import registered_fortran_ddt_names
from metadata_table import MetadataTable, parse_metadata_file, Var
#from metadata_table import MetadataHeader
from framework_env import CCPPFrameworkEnv

example_table = """
[ccpp-table-properties]
Expand All @@ -32,8 +31,13 @@ def test_MetadataTable_parse_table(tmpdir):
with open(path, "w") as f:
f.write(example_table)

dummy_run_env = CCPPFrameworkEnv(None, ndict={'host_files':'',
'scheme_files':'',
'suites':''})


metadata_headers = parse_metadata_file(path, known_ddts=registered_fortran_ddt_names(),
logger=logging.getLogger(__name__))
run_env=dummy_run_env)

# check metadata header
assert len(metadata_headers) == 1
Expand Down