Skip to content

Commit

Permalink
Skip tests failing due to bug 1356
Browse files Browse the repository at this point in the history
Update class `CreateFailureTestCase` in module
`pulp_smash.tests.platform.api_v2.test_repository`:

* Refactor all of its test methods to make them produce more useful output upon
  failure.
* Rename `test_exception_json_http_status` to `test_body_status_code`.
* Make `test_status_code` and `test_body_status_code` selectively skip sub-tests
  using the new `bug_is_untestable` utility functions.

Before diff:

    ============  ========================================
    Pulp Version  Test Suite Results
    ============  ========================================
    2.6           FAILED (failures=7, skipped=6)
    2.7           FAILED (failures=7, skipped=5)
    dev           FAILED (failures=7, errors=1, skipped=5)
    ============  ========================================

After diff:

    ============  ========================================
    Pulp Version  Test Suite Results
    ============  ========================================
    2.6           FAILED (failures=5, skipped=8)
    2.7           FAILED (failures=5, skipped=7)
    dev           FAILED (failures=5, errors=1, skipped=7)
    ============  ========================================
  • Loading branch information
Ichimonji10 committed Dec 10, 2015
1 parent b9af988 commit e204f9f
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions pulp_smash/tests/platform/api_v2/test_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@

from pulp_smash.config import get_config
from pulp_smash.constants import REPOSITORY_PATH, ERROR_KEYS
from pulp_smash.utils import create_repository, delete, require, uuid4
from pulp_smash.utils import (
bug_is_untestable,
create_repository,
delete,
require,
uuid4,
)
from requests.exceptions import HTTPError
from unittest2 import TestCase

Expand Down Expand Up @@ -110,31 +116,37 @@ def setUpClass(cls):

def test_status_code(self):
"""Assert that each response has the expected HTTP status code."""
for response, status_code in zip(self.responses, self.status_codes):
with self.subTest((response, status_code)):
for body, response, status_code in zip(
self.bodies, self.responses, self.status_codes):
with self.subTest(body=body):
if body == ['Incorrect data type'] and bug_is_untestable(1356):
self.skipTest('https://pulp.plan.io/issues/1356')
self.assertEqual(response.status_code, status_code)

def test_body_status_code(self):
"""Assert that each response body has the expected HTTP status code."""
for body, response, status_code in zip(
self.bodies, self.responses, self.status_codes):
with self.subTest(body=body):
if body == ['Incorrect data type'] and bug_is_untestable(1356):
self.skipTest('https://pulp.plan.io/issues/1356')
self.assertEqual(response.json()['http_status'], status_code)

def test_location_header(self):
"""Assert that the Location header is correctly set in the response."""
for i, response in enumerate(self.responses):
with self.subTest(i=i):
for body, response in zip(self.bodies, self.responses):
with self.subTest(body=body):
self.assertNotIn('Location', response.headers)

def test_exception_keys_json(self):
"""Assert the JSON body returned contains the correct keys."""
for i, response in enumerate(self.responses):
with self.subTest(i=i):
for body, response in zip(self.bodies, self.responses):
with self.subTest(body=body):
self.assertEqual(
frozenset(response.json().keys()),
ERROR_KEYS,
)

def test_exception_json_http_status(self):
"""Assert the JSON body returned contains the correct HTTP code."""
for response, status_code in zip(self.responses, self.status_codes):
with self.subTest((response, status_code)):
self.assertEqual(response.json()['http_status'], status_code)

@classmethod
def tearDownClass(cls):
"""Delete the created repositories."""
Expand Down

0 comments on commit e204f9f

Please sign in to comment.