From a08c16158d7245c7e66b29e33b29970be57d4b8e Mon Sep 17 00:00:00 2001 From: Chris Lumens Date: Thu, 9 Aug 2018 15:43:01 -0400 Subject: [PATCH] Fix more tests. These were broken due to me rebasing before sending a PR off. They should work now. (cherry picked from commit 4cb15e0a0fd32565b557e5762c3321dbac6f8d50) --- tests/composer/test_utilities.py | 17 +++++++++-------- tests/pylorax/test_server.py | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/tests/composer/test_utilities.py b/tests/composer/test_utilities.py index d8e5d58e..7bc9c935 100644 --- a/tests/composer/test_utilities.py +++ b/tests/composer/test_utilities.py @@ -16,6 +16,7 @@ # import unittest +from pylorax.api.errors import INVALID_CHARS from composer.cli.utilities import argify, toml_filename, frozen_toml_filename, packageNEVRA from composer.cli.utilities import handle_api_result @@ -53,8 +54,8 @@ class CliUtilitiesTest(unittest.TestCase): self.assertEqual(handle_api_result(result, show_json=False), (0, False)) def test_api_result_2(self): - """Test a result with errors=["some error"], and no status field""" - result = {"foo": "bar", "errors": ["some error"]} + """Test a result with errors=[{"id": INVALID_CHARS, "msg": "some error"}], and no status field""" + result = {"foo": "bar", "errors": [{"id": INVALID_CHARS, "msg": "some error"}]} self.assertEqual(handle_api_result(result, show_json=False), (1, False)) def test_api_result_3(self): @@ -68,8 +69,8 @@ class CliUtilitiesTest(unittest.TestCase): self.assertEqual(handle_api_result(result, show_json=False), (1, True)) def test_api_result_5(self): - """Test a result with status=False, and errors=["some error"]""" - result = {"status": False, "errors": ["some error"]} + """Test a result with status=False, and errors=[{"id": INVALID_CHARS, "msg": "some error"}]""" + result = {"status": False, "errors": [{"id": INVALID_CHARS, "msg": "some error"}]} self.assertEqual(handle_api_result(result, show_json=False), (1, True)) def test_api_result_6(self): @@ -78,13 +79,13 @@ class CliUtilitiesTest(unittest.TestCase): self.assertEqual(handle_api_result(result, show_json=True), (0, True)) def test_api_result_7(self): - """Test a result with show_json=True, status=False, and errors=["some error"]""" - result = {"status": False, "errors": ["some error"]} + """Test a result with show_json=True, status=False, and errors=[{"id": INVALID_CHARS, "msg": "some error"}]""" + result = {"status": False, "errors": [{"id": INVALID_CHARS, "msg": "some error"}]} self.assertEqual(handle_api_result(result, show_json=True), (1, True)) def test_api_result_8(self): - """Test a result with show_json=True, errors=["some error"], and no status field""" - result = {"foo": "bar", "errors": ["some error"]} + """Test a result with show_json=True, errors=[{"id": INVALID_CHARS, "msg": "some error"}], and no status field""" + result = {"foo": "bar", "errors": [{"id": INVALID_CHARS, "msg": "some error"}]} self.assertEqual(handle_api_result(result, show_json=True), (1, True)) def test_api_result_9(self): diff --git a/tests/pylorax/test_server.py b/tests/pylorax/test_server.py index ed813791..6e4206af 100644 --- a/tests/pylorax/test_server.py +++ b/tests/pylorax/test_server.py @@ -1036,7 +1036,7 @@ class ServerTestCase(unittest.TestCase): self.assertEqual(resp.status_code, 400) self.assertEqual(data["status"], False) self.assertTrue(len(data["errors"]) > 0) - self.assertTrue("Invalid characters in" in data["errors"][0]) + self.assertTrue("Invalid characters in" in data["errors"][0]["msg"]) def test_blueprints_list_branch(self): resp = self.server.get("/api/v0/blueprints/list?branch=" + UTF8_TEST_STRING)