diff options
author | Justin Cook <justin.cook@linaro.org> | 2020-10-23 15:22:18 -0500 |
---|---|---|
committer | Justin Cook <justin.cook@linaro.org> | 2020-10-23 15:22:18 -0500 |
commit | e121d931ede8c444f08bb005f85266a5bb83b2c1 (patch) | |
tree | 8f07ecce716ecf9027ea6652eb8eb8d32a4100b5 | |
parent | 7252a7b67505c7b26421b90885b97824d425c435 (diff) |
Fix a file extension check error message
-rw-r--r-- | squad_client/commands/submit.py | 2 | ||||
-rw-r--r-- | tests/submit_results/sample_results.txt | 5 | ||||
-rw-r--r-- | tests/test_submit.py | 6 |
3 files changed, 12 insertions, 1 deletions
diff --git a/squad_client/commands/submit.py b/squad_client/commands/submit.py index fbfe064..d43d24a 100644 --- a/squad_client/commands/submit.py +++ b/squad_client/commands/submit.py @@ -75,7 +75,7 @@ class SubmitCommand(SquadClientCommand): _, ext = os.path.splitext(file_path) if ext not in ['.json', '.yml', '.yaml']: - logger.error('File "%s" is neither JSON nor YAML') + logger.error('File "%s" does not have a JSON or YAML file extension' % file_path) return None parser = json.load if ext == '.json' else yaml.safe_load diff --git a/tests/submit_results/sample_results.txt b/tests/submit_results/sample_results.txt new file mode 100644 index 0000000..b4894e3 --- /dev/null +++ b/tests/submit_results/sample_results.txt @@ -0,0 +1,5 @@ +--- +yaml-test-1: pass +yaml-test-2: + log: yaml-test-2 log + result: fail diff --git a/tests/test_submit.py b/tests/test_submit.py index 77753a4..7539ced 100644 --- a/tests/test_submit.py +++ b/tests/test_submit.py @@ -163,6 +163,12 @@ class SubmitCommandTest(unittest.TestCase): self.assertFalse(proc.ok) self.assertIn('Failed parsing file', proc.err) + def test_submit_results_bad_extension(self): + p = "tests/submit_results/sample_results.txt" + proc = self.manage_submit(results=p) + self.assertFalse(proc.ok) + self.assertIn('File "%s" does not have a JSON or YAML file extension' % p, proc.err) + def test_submit_single_metric(self): proc = self.manage_submit(metrics='tests/submit_results/sample_metrics.json') self.assertTrue(proc.ok) |