-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add basic tests for repository CRUD. #28
Conversation
04d619e
to
1e6fff0
Compare
@@ -0,0 +1,226 @@ | |||
# coding=utf-8 | |||
"""Test the `repository`_ API endpoints.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No target is given for the "repository" reference. As a result, it should be broken. You can provide a target like so:
.. repository: https://example.com
Of course, you don't actually want to link the user to example.com.
Can you run the new tests and paste the output here when done? |
1e6fff0
to
f8f863e
Compare
Output is:
I'm not sure what the problem is with the user tests, but the repository test should be failing (https://pulp.plan.io/issues/1356). |
Line 169 is this failure: #34 |
I believe the failing user test is an expected failure. There's a known bug tested by that API call, and... I don't have a link to it. |
(400, {'id': None}), | ||
(400, ['Incorrect data type']), | ||
(400, {'missing_required_keys': 'id'}), | ||
(409, {'id': identical_id}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per Exception Handling, these four API calls should return a call report with ERROR_KEYS
. Can we add in a test method for that?
The two new |
attributes = {key: attributes[key] for key in self.bodies[0].keys()} | ||
self.assertEqual(self.bodies[0], attributes) | ||
|
||
def test_update_attributes_spawned_tasks(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add # noqa pylint:disable=invalid-name
to the end of this line?
As per #28 (comment), I'm going to refactor this module at a later point. Can you add |
I think that's about it. If you can address the points above, I think this is great. |
with self.subTest(key): | ||
self.assertIn(key, response['result']) | ||
self.assertEqual( | ||
self.update_body[key], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.update_body['delta'][key]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch. This could also be written as:
for key, value in self.update_body['delta'].items():
with self.subTest(key=key):
self.assertIn(key, response['result'])
self.assertEqual(value, response['result'][key])
f8f863e
to
a150499
Compare
@jeremycline Please rebase and apply this patch: diff --git a/Makefile b/Makefile
index 22b7274..1dada96 100644
--- a/Makefile
+++ b/Makefile
@@ -19,7 +19,9 @@ docs-clean:
lint:
flake8 .
- pylint --reports=n --disable=I docs/conf.py pulp_smash tests setup.py
+ pylint --reports=n --disable=I docs/conf.py tests setup.py \
+ pulp_smash/{__init__,__main__,config,constants,utils}.py
+ pylint --reports=n --disable=I,duplicate-code pulp_smash/tests/
test:
python $(TEST_OPTIONS) The above patch causes pylint to ignore any duplicate code in the |
4222c79
to
bd4cc63
Compare
@Ichimonji10 I have made it so. Note that I had to add |
@jeremycline Will that cause the makefile to break on systems that may not have bash installed, such as Mac OS (or Cygwin, or other more exotic *nix-like distros)? |
@Ichimonji10 Yes. Does |
I don't know. We can just expand those braces: diff --git a/Makefile b/Makefile
index 22b7274..1dada96 100644
--- a/Makefile
+++ b/Makefile
@@ -19,7 +19,9 @@ docs-clean:
lint:
flake8 .
- pylint --reports=n --disable=I docs/conf.py pulp_smash tests setup.py
+ pylint --reports=n --disable=I docs/conf.py tests setup.py \
+ pulp_smash/__init__.py \
+ pulp_smash/__main__.py \
+ pulp_smash/config.py \
+ pulp_smash/constants.py \
+ pulp_smash/utils.py
+ pylint --reports=n --disable=I,duplicate-code pulp_smash/tests/
test:
python $(TEST_OPTIONS) |
This commit also introduces a ``utils`` module which currently only provides a function to generate random strings using ``uuid.uuid4``.
bd4cc63
to
cda18c4
Compare
I guess we could just do that. |
Ugly, but highly compatible. |
Very true. It is done. |
This commit also introduces a
utils
module which currently onlyprovides a function to generate random strings using
uuid.uuid4
.