diff --git a/sahara/tests/unit/service/validation/test_ng_template_validation_create.py b/sahara/tests/unit/service/validation/test_ng_template_validation_create.py index 518e086d..029f0618 100644 --- a/sahara/tests/unit/service/validation/test_ng_template_validation_create.py +++ b/sahara/tests/unit/service/validation/test_ng_template_validation_create.py @@ -67,7 +67,7 @@ class TestNGTemplateCreateValidation(u.ValidationTestCase): 'node_processes': [] }, bad_req_i=(1, 'VALIDATION_ERROR', - u'[] is too short') + u'\[\] is too short') ) def test_ng_template_create_v_names(self): @@ -142,7 +142,7 @@ class TestNGTemplateCreateValidation(u.ValidationTestCase): 'volumes_per_node': -1 }, bad_req_i=(1, 'VALIDATION_ERROR', - u'-1.0 is less than the minimum of 0') + u'-1(.0)? is less than the minimum of 0') ) self._assert_create_object_validation( data={ @@ -154,7 +154,7 @@ class TestNGTemplateCreateValidation(u.ValidationTestCase): 'volumes_size': 0 }, bad_req_i=(1, 'VALIDATION_ERROR', - u'0.0 is less than the minimum of 1') + u'0(.0)? is less than the minimum of 1') ) def test_ng_template_create_v_types(self): @@ -238,7 +238,7 @@ class TestNGTemplateCreateValidation(u.ValidationTestCase): 'volumes_per_node': -1 }, bad_req_i=(1, 'VALIDATION_ERROR', - u'-1.0 is less than the minimum of 0') + u'-1(.0)? is less than the minimum of 0') ) self._assert_create_object_validation( data={ @@ -250,7 +250,7 @@ class TestNGTemplateCreateValidation(u.ValidationTestCase): 'volumes_size': 0 }, bad_req_i=(1, 'VALIDATION_ERROR', - u'0.0 is less than the minimum of 1') + u'0(.0)? is less than the minimum of 1') ) self._assert_create_object_validation( data={ diff --git a/sahara/tests/unit/service/validation/utils.py b/sahara/tests/unit/service/validation/utils.py index 6b40d239..736473ec 100644 --- a/sahara/tests/unit/service/validation/utils.py +++ b/sahara/tests/unit/service/validation/utils.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import re + import mock import novaclient.exceptions as nova_ex @@ -255,7 +257,14 @@ class ValidationTestCase(base.SaharaTestCase): else: self.assertEqual(mock.call_count, call_info[0]) self.assertEqual(mock.call_args[0][0].code, call_info[1]) - self.assertEqual(mock.call_args[0][0].message, call_info[2]) + + # Note(slukjanov): the call_info[2] is an expected validation + # message regex; regex needed because of different + # versions of jsonschema generates different + # messages. + if not re.match(call_info[2], mock.call_args[0][0].message): + self.assertEqual(call_info[2], mock.call_args[0][0].message, + "Validation message didn't match expected") @mock.patch("sahara.utils.api.request_data") @mock.patch("sahara.utils.api.bad_request")