Skip to content

Commit

Permalink
Make new constant: CALL_REPORT_KEYS
Browse files Browse the repository at this point in the history
Make a new constant: `pulp_smash.constants.CALL_REPORT_KEYS`. Update code base
by referencing this single constant and dropping other private declarations of
the call report keys.

Test suite results do not change when run against either Pulp 2.6 or 2.7, on
either Python 2 or 3.
  • Loading branch information
Ichimonji10 committed Dec 4, 2015
1 parent 005ea25 commit 8580aa1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
9 changes: 9 additions & 0 deletions pulp_smash/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
from __future__ import unicode_literals


CALL_REPORT_KEYS = frozenset(('error', 'result', 'spawned_tasks'))
"""See: `Call Report`_.
.. _Call Report:
http://pulp.readthedocs.org/en/latest/dev-guide/conventions/sync-v-async.html#call-report
"""


ERROR_KEYS = frozenset((
'_href',
'error',
Expand Down
11 changes: 7 additions & 4 deletions pulp_smash/tests/platform/api_v2/test_content_applicability.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

import requests
from pulp_smash.config import get_config
from pulp_smash.constants import CALL_REPORT_KEYS
from unittest2 import TestCase

_CALL_REPORT_KEYS = {'error', 'result', 'spawned_tasks'}
_CONSUMER = '/pulp/api/v2/consumers/actions/content/regenerate_applicability/'
_REPO = '/pulp/api/v2/repositories/actions/content/regenerate_applicability/'

Expand Down Expand Up @@ -47,8 +47,8 @@ def test_body(self):
for i, response in enumerate(self.responses):
with self.subTest(i):
self.assertEqual(
set(response.json().keys()),
_CALL_REPORT_KEYS,
frozenset(response.json().keys()),
CALL_REPORT_KEYS,
)


Expand Down Expand Up @@ -82,4 +82,7 @@ def test_body(self):
"""Assert that the responses are JSON and appear to be call reports."""
for i, resp in enumerate(self.responses):
with self.subTest(i):
self.assertNotEqual(set(resp.json().keys()), _CALL_REPORT_KEYS)
self.assertNotEqual(
frozenset(resp.json().keys()),
CALL_REPORT_KEYS,
)
5 changes: 3 additions & 2 deletions pulp_smash/tests/rpm/api_v2/test_sync_publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import os
import requests
from pulp_smash.config import get_config
from pulp_smash.constants import CALL_REPORT_KEYS
from pulp_smash.utils import (
create_repository,
delete,
Expand Down Expand Up @@ -512,8 +513,8 @@ def test_call_reports_keys(self):
for step in {'import', 'copy', 'publish'}:
with self.subTest(step=step):
self.assertEqual(
set(self.bodies[step].keys()),
{'error', 'result', 'spawned_tasks'},
frozenset(self.bodies[step].keys()),
CALL_REPORT_KEYS,
)

def test_call_reports_values(self):
Expand Down

0 comments on commit 8580aa1

Please sign in to comment.