-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[Fixed #872] Filter Builds according to commit #3544
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
Changes from all commits
34e17be
5f3fb59
c052f59
8b0e34c
27be502
f56cbd1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -152,6 +152,22 @@ def test_make_build_commands(self): | |
self.assertEqual(build['commands'][0]['run_time'], 5) | ||
self.assertEqual(build['commands'][0]['description'], 'foo') | ||
|
||
def test_build_filter_by_commit(self): | ||
""" | ||
Create a build with commit | ||
Should return the list of builds according to the | ||
commit query params | ||
""" | ||
get(Build, project_id=1, version_id=1, builder='foo', commit='test') | ||
get(Build, project_id=2, version_id=1, builder='foo', commit='other') | ||
client = APIClient() | ||
api_user = get(User, staff=False, password='test') | ||
client.force_authenticate(user=api_user) | ||
resp = client.get('/api/v2/build/', {'commit': 'test'}, format='json') | ||
self.assertEqual(resp.status_code, 200) | ||
build = resp.data | ||
self.assertEqual(len(build['results']), 1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't realize this the other day but, is it OK to return a list of one element when we already know that it's going to be always one element? I suppose it shouldn't be possible to have two different commits with the same hash, right? Although, what would happen for projects that are not git-based? SVN for example which are just plain numbers? In that case, this endpoint will break (not because the code itself but in meaning, I think) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @humitos As per (build model)[https://github.com/rtfd/readthedocs.org/blob/master/readthedocs/builds/models.py#L430], the Regarding SVN, I actually do not know whats save in the commit field. Can you please elaborate? |
||
|
||
|
||
class APITests(TestCase): | ||
fixtures = ['eric.json', 'test_data.json'] | ||
|
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 call
super
instead of making thequeryset
?Something like
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.
I understand and I have looked into it as to why you asked me to do so as well. Your assistance was very well appreciated and I have made the requested changes. You can review it if you wish @safwanrahman.