@@ -0,0 +1,1654 @@
+%22%22%22Unit tests for ckanserviceprovider/db.py.%22%22%22%0Aimport nose.tools%0A%0Aimport ckanserviceprovider.db as db%0A%0A%0Adef test_validate_error_with_none():%0A    %22%22%22_validate_error() should return None if given None.%22%22%22%0A    assert db._validate_error(None) is None%0A%0A%0Adef test_validate_error_with_string():%0A    %22%22%22If given a string _validate_error() should return it wrapped in a dict.%0A%0A    %22%22%22%0A    assert db._validate_error(%22Something went wrong%22) == %7B%0A        %22message%22: %22Something went wrong%22%7D%0A%0A%0Adef test_validate_error_with_valid_dict():%0A    %22%22%22If given a valid dict _validate_error() should return the same dict.%22%22%22%0A    job_dict = %7B%22message%22: %22Something went wrong%22%7D%0A    assert db._validate_error(job_dict) == job_dict%0A%0A%0Adef test_validate_error_with_dict_with_invalid_error():%0A    %22%22%22_validate_error() should raise if given a dict with an invalid message.%0A%0A    %22%22%22%0A    job_dict = %7B%22message%22: 42%7D  # Error message is invalid: it's not a string.%0A    nose.tools.assert_raises(%0A        db.InvalidErrorObjectError, db._validate_error, job_dict)%0A%0A%0Adef test_validate_error_with_dict_with_no_error_key():%0A    %22%22%22_validate_error() should raise if given a dict with no %22message%22 key.%22%22%22%0A    job_dict = %7B%22foo%22: %22bar%22%7D%0A    nose.tools.assert_raises(%0A        db.InvalidErrorObjectError, db._validate_error, job_dict)%0A%0A%0Adef test_validate_error_with_random_object():%0A    %22%22%22_validate_error() should raise if given an object of the wrong type.%22%22%22%0A%0A    class Foo(object):%0A        pass%0A%0A    # An error object that is not None and is not string- or dict-like at all.%0A    error_obj = Foo()%0A%0A    nose.tools.assert_raises(%0A        db.InvalidErrorObjectError, db._validate_error, error_obj)%0A

Add unit tests for new _validate_error() function