From 8530353023bdf4e78529736307ce2a773cbd3d21 Mon Sep 17 00:00:00 2001 From: Joel Vasallo Date: Oct 26 2016 18:34:39 +0000 Subject: Added tests for get_metadata - Fixed Typo --- diff --git a/hub/kojihub.py b/hub/kojihub.py index 6cd2505..159ee0a 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -4912,7 +4912,7 @@ class CG_Importer(object): self.raw_metadata = json.dumps(metadata, indent=2) except Exception: logger.exception("Cannot encode supplied metadata") - raise koji.GenericError("Invalid metada, cannot encode: %r" % metadata) + raise koji.GenericError("Invalid metadata, cannot encode: %r" % metadata) return metadata if metadata is None: #default to looking for uploaded file diff --git a/tests/test_hub/test_cg_importer.py b/tests/test_hub/test_cg_importer.py index 004d2b7..9b6a4a6 100644 --- a/tests/test_hub/test_cg_importer.py +++ b/tests/test_hub/test_cg_importer.py @@ -2,6 +2,7 @@ import unittest import mock import kojihub +from koji import GenericError class TestCGImporter(unittest.TestCase): @@ -9,3 +10,15 @@ class TestCGImporter(unittest.TestCase): # TODO -- this doesn't make sense. A query with no arguments should # probably raise an exception saying "this doesn't make sense." kojihub.CG_Importer() # No exception! + + def test_get_metadata_is_instance(self): + mock_input_val = {'something': 'good val'} + x = kojihub.CG_Importer() + x.get_metadata(mock_input_val, '') + assert x.raw_metadata + assert isinstance(x.raw_metadata, str) + + def test_get_metadata_is_not_instance(self): + x = kojihub.CG_Importer() + with self.assertRaises(GenericError): + x.get_metadata(42, '')