Skip to content

Commit

Permalink
#523: update JSON validator test with new args
Browse files Browse the repository at this point in the history
  • Loading branch information
cwschilly committed Aug 2, 2024
1 parent 5c66bb6 commit dc43df8
Showing 1 changed file with 45 additions and 15 deletions.
60 changes: 45 additions & 15 deletions tests/unit/imported/test_JSON_data_files_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,93 +40,117 @@ def test_json_data_files_validator_file(self):
argparse.ArgumentParser.parse_args.return_value = argparse.Namespace(file_path=self.file_path,
dir_path=None,
file_prefix=None,
file_suffix=None)
file_suffix=None,
validate_comm_links=False,
debug=False)
JSONDataFilesValidator().main()

def test_json_data_files_validator_dir(self):
argparse.ArgumentParser.parse_args = Mock()
argparse.ArgumentParser.parse_args.return_value = argparse.Namespace(file_path=None,
dir_path=self.dir_path,
file_prefix=None,
file_suffix=None)
file_suffix=None,
validate_comm_links=False,
debug=False)
JSONDataFilesValidator().main()

def test_json_data_files_validator_dir_compressed(self):
argparse.ArgumentParser.parse_args = Mock()
argparse.ArgumentParser.parse_args.return_value = argparse.Namespace(file_path=None,
dir_path=self.dir_path_compressed,
file_prefix=None,
file_suffix=None)
file_suffix=None,
validate_comm_links=False,
debug=False)
JSONDataFilesValidator().main()

def test_json_data_files_validator_file_stats_001(self):
argparse.ArgumentParser.parse_args = Mock()
argparse.ArgumentParser.parse_args.return_value = argparse.Namespace(file_path=self.stats_file_001,
dir_path=None,
file_prefix=None,
file_suffix=None)
file_suffix=None,
validate_comm_links=False,
debug=False)
JSONDataFilesValidator().main()

def test_json_data_files_validator_file_stats_002(self):
argparse.ArgumentParser.parse_args = Mock()
argparse.ArgumentParser.parse_args.return_value = argparse.Namespace(file_path=self.stats_file_002,
dir_path=None,
file_prefix=None,
file_suffix=None)
file_suffix=None,
validate_comm_links=False,
debug=False)
JSONDataFilesValidator().main()

def test_json_data_files_validator_file_stats_003(self):
argparse.ArgumentParser.parse_args = Mock()
argparse.ArgumentParser.parse_args.return_value = argparse.Namespace(file_path=self.stats_file_003,
dir_path=None,
file_prefix=None,
file_suffix=None)
file_suffix=None,
validate_comm_links=False,
debug=False)
JSONDataFilesValidator().main()

def test_json_data_files_validator_file_stats_004(self):
argparse.ArgumentParser.parse_args = Mock()
argparse.ArgumentParser.parse_args.return_value = argparse.Namespace(file_path=self.stats_file_004,
dir_path=None,
file_prefix=None,
file_suffix=None)
file_suffix=None,
validate_comm_links=False,
debug=False)
JSONDataFilesValidator().main()

def test_json_data_files_validator_file_stats_no_schema_type(self):
argparse.ArgumentParser.parse_args = Mock()
argparse.ArgumentParser.parse_args.return_value = argparse.Namespace(
file_path=self.vt_lb_statistics_no_schema_type, dir_path=None, file_prefix=None, file_suffix=None)
file_path=self.vt_lb_statistics_no_schema_type, dir_path=None, file_prefix=None, file_suffix=None,
validate_comm_links=False,
debug=False)
JSONDataFilesValidator().main()

def test_json_data_files_validator_prefix(self):
argparse.ArgumentParser.parse_args = Mock()
argparse.ArgumentParser.parse_args.return_value = argparse.Namespace(file_path=None,
dir_path=self.dir_path,
file_prefix="data",
file_suffix=None)
file_suffix=None,
validate_comm_links=False,
debug=False)
JSONDataFilesValidator().main()

def test_json_data_files_validator_suffix(self):
argparse.ArgumentParser.parse_args = Mock()
argparse.ArgumentParser.parse_args.return_value = argparse.Namespace(file_path=None,
dir_path=self.dir_path,
file_prefix=None,
file_suffix="json")
file_suffix="json",
validate_comm_links=False,
debug=False)
JSONDataFilesValidator().main()

def test_json_data_files_validator_prefix_suffix(self):
argparse.ArgumentParser.parse_args = Mock()
argparse.ArgumentParser.parse_args.return_value = argparse.Namespace(file_path=None,
dir_path=self.dir_path,
file_prefix="data",
file_suffix="json")
file_suffix="json",
validate_comm_links=False,
debug=False)
JSONDataFilesValidator().main()

def test_json_data_files_validator_file_not_found(self):
argparse.ArgumentParser.parse_args = Mock()
argparse.ArgumentParser.parse_args.return_value = argparse.Namespace(file_path=self.wrong_file_path,
dir_path=None,
file_prefix=None,
file_suffix=None)
file_suffix=None,
validate_comm_links=False,
debug=False)
with self.assertRaises(FileNotFoundError) as err:
JSONDataFilesValidator().main()
self.assertEqual(err.exception.args[0], f"File: {self.wrong_file_path} NOT found")
Expand All @@ -136,7 +160,9 @@ def test_json_data_files_validator_dir_not_found(self):
argparse.ArgumentParser.parse_args.return_value = argparse.Namespace(file_path=None,
dir_path=self.wrong_dir_path,
file_prefix=None,
file_suffix=None)
file_suffix=None,
validate_comm_links=False,
debug=False)
with self.assertRaises(FileNotFoundError) as err:
JSONDataFilesValidator().main()
self.assertEqual(err.exception.args[0], f"Directory: {self.wrong_dir_path} does NOT exist")
Expand All @@ -146,7 +172,9 @@ def test_json_data_files_validator_no_args(self):
argparse.ArgumentParser.parse_args.return_value = argparse.Namespace(file_path=None,
dir_path=None,
file_prefix=None,
file_suffix=None)
file_suffix=None,
validate_comm_links=False,
debug=False)
with self.assertRaises(Exception) as err:
JSONDataFilesValidator().main()
self.assertEqual(err.exception.args[0], "FILE path or DIRECTORY path has to be given")
Expand All @@ -156,7 +184,9 @@ def test_json_data_files_validator_wrong_file_schema(self):
argparse.ArgumentParser.parse_args.return_value = argparse.Namespace(file_path=self.wrong_file_schema,
dir_path=None,
file_prefix=None,
file_suffix=None)
file_suffix=None,
validate_comm_links=False,
debug=False)
with self.assertRaises(SchemaError) as err:
JSONDataFilesValidator().main()
with open(os.path.join(self.data_dir, "JSON_data_file_validator_wrong", "schema_error.txt"), "rt") as se:
Expand Down

0 comments on commit dc43df8

Please sign in to comment.