diff options
author | gordon chung <gord@live.ca> | 2015-06-22 17:35:19 -0400 |
---|---|---|
committer | gordon chung <gord@live.ca> | 2015-06-22 17:39:10 -0400 |
commit | d81b2b482bbe3af2bac4e4a19af56acab746bc74 (patch) | |
tree | b91a65440c945e73b0701199bf6bd890c37db14f /pycadf | |
parent | 6f059c74f3ba4ae79d3da3ee62ca817c4cfcff4d (diff) | |
download | pycadf-d81b2b482bbe3af2bac4e4a19af56acab746bc74.tar.gz |
ensure id is not empty
when validating id, we should validate it's not just a string but
that it's also not empty.
Change-Id: I0d55803df5f2f8e6b35431a816e1390bcb3fe424
Closes-Bug: #1467670
Diffstat (limited to 'pycadf')
-rw-r--r-- | pycadf/identifier.py | 2 | ||||
-rw-r--r-- | pycadf/tests/test_cadf_spec.py | 5 |
2 files changed, 7 insertions, 0 deletions
diff --git a/pycadf/identifier.py b/pycadf/identifier.py index 8c74fb6..de9e8eb 100644 --- a/pycadf/identifier.py +++ b/pycadf/identifier.py @@ -49,4 +49,6 @@ def is_valid(value): """ if not isinstance(value, six.string_types): raise TypeError + elif not value: + return False return True diff --git a/pycadf/tests/test_cadf_spec.py b/pycadf/tests/test_cadf_spec.py index 9ba9676..afa1da1 100644 --- a/pycadf/tests/test_cadf_spec.py +++ b/pycadf/tests/test_cadf_spec.py @@ -34,6 +34,11 @@ from pycadf import timestamp class TestCADFSpec(base.TestCase): + + def test_identifier_empty(self): + self.assertFalse(identifier.is_valid('')) + self.assertTrue(identifier.is_valid(identifier.generate_uuid())) + def test_endpoint(self): endp = endpoint.Endpoint(url='http://192.168.0.1', name='endpoint name', |