Skip to content
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

Introduce RetrieveAPIAutoTestCase #482

Closed
wants to merge 3 commits into from
Closed

Introduce RetrieveAPIAutoTestCase #482

wants to merge 3 commits into from

Conversation

kmeht
Copy link
Member

@kmeht kmeht commented Jul 2, 2016

This introduces the first auto test case for the retrieve API. The implementor provides the actual object under test, and a tuple of (username, password, expected_error). The expected error is what that user should get from the API. If it's None, that means the request should be accepted.

If the request is accepted, we then use the serializer to figure out what fields the object is going to have. Most of the time, it's pretty straightforward, but sometimes (like for decimal fields, or relational fields), we have to do some transformations.

This will (hopefully) make it much easier to add test cases to the API. Or, at the very least, it'll allow us to clean up our fugly existing test cases.

Task: #475

This introduces the first auto test case for the retrieve API. The implementor provides the actual object under test, and a tuple of (username, password, expected_error). The expected error is what that user should get from the API. If it's `None`, that means the request should be accepted.

If the request is accepted, we then use the serializer to figure out what fields the object is going to have. Most of the time, it's pretty straightforward, but sometimes (like for decimal fields, or relational fields), we have to do some transformations.

This will (hopefully) make it much easier to add test cases to the API. Or, at the very least, it'll allow us to clean up our fugly existing test cases.

Task: #475
from huxley.api.tests import RetrieveAPITestCase


class RetrieveAPIAutoTestCase(RetrieveAPITestCase):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we add more AutoTestCases, do you think we will be able to reuse some of the functionality by making an AbstractAutoTest case or something along those lines?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope so! I figure we'll take it one step at a time, and the requirements of the other AutoTestCases will shape what the abstract one will look like.

@tdowds
Copy link
Contributor

tdowds commented Jul 2, 2016

This is awesome!

(None, None, cls.NOT_AUTHENTICATED),
(test_object.advisor.username, 'test', None),
('user1', 'user1', None),
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a better way to write this now, but this return statement is not very clear. Maybe switching over to a python dictionary would allow more clarity and readability. For right now I think a class comment would suffice so that devs trying to replicate can easily do so.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, agreed that this is pretty terrible. Let's keep thinking on it and make improvements later.

@nathanielparke
Copy link
Contributor

nathanielparke commented Jul 3, 2016

This is a great start. As mentioned above I think readability will be important as we introduce more automation. IMO there needs to be a bit more abstraction added between the implemented test case and the factory. That decoupling can come after we get rid of the old tests though. LGTM

@kmeht kmeht closed this in f9df764 Jul 3, 2016
@kmeht kmeht deleted the autoTest branch July 3, 2016 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants