-
Notifications
You must be signed in to change notification settings - Fork 106
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
Update form for adding distribution #639
Conversation
Codecov Report
@@ Coverage Diff @@
## master #639 +/- ##
==========================================
- Coverage 90.55% 90.54% -0.01%
==========================================
Files 56 56
Lines 2690 2698 +8
Branches 352 355 +3
==========================================
+ Hits 2436 2443 +7
Misses 197 197
- Partials 57 58 +1
Continue to review full report at Codecov.
|
news/PR639.feature
Outdated
@@ -0,0 +1 @@ | |||
Update form for adding new distribution |
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.
Update form for adding new distribution | |
Update form for adding new distributions |
anitya/forms.py
Outdated
distro = SelectField( | ||
'Distribution', | ||
[validators.DataRequired()], | ||
choices=[(item, item) for item in []]) |
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.
What express it this way? Isn't this basically just saying choices=[]
?
anitya/tests/test_flask.py
Outdated
"""Assert admins can add distributions.""" | ||
with login_user(self.flask_app, self.user): | ||
output = self.client.get('/distro/add') | ||
print(output.data) |
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.
print(output.data) |
anitya/tests/test_flask.py
Outdated
|
||
output = self.client.post('/distro/add', data=data, follow_redirects=True) | ||
|
||
# self.assertEqual(201, output.status_code) |
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.assertEqual(201, output.status_code) |
b'name="csrf_token" type="hidden" value="')[1].split(b'">')[0] | ||
data = {'name': 'Fedora', 'csrf_token': csrf_token} | ||
|
||
output = self.client.post('/distro/add', data=data, follow_redirects=True) |
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.
Does self.client.post()
assert that the return code is 200
by default?
dup_output = self.client.post('/distro/add', data=data, follow_redirects=True) | ||
|
||
self.assertTrue(b'Distribution added' in create_output.data) | ||
self.assertTrue(b'Could not add this distro' in dup_output.data) |
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.
It seems like it'd be good to assert that an HTTP error code was used here. Perhaps 409 (conflict)?
self.assertTrue(b'Could not add this distro' in dup_output.data) | |
self.assertTrue(b'Could not add this distro' in dup_output.data) | |
self.assertEqual(409, output.status_code) |
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.
The user is redirected to /distros
page, so the user gets 301 redirect.
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.
It would also be helpful to give more information in the commit message, and to make the title more descriptive. What are we updating it to do that it doesn't do now?
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.
LGTM, though I recommend squashing the commits before merging.
squash |
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.
This one also fails in Travis - does the master branch fail linting?
* To add distribution through distros page user no longer needs to be admin * Distribution in mapping page is now selected from dropdown, not automatically created if it doesn't exists * Add confirmation dialog to `/distro/add` page if there are distributions with similar names (this is also showed on the page itself before submit) * Polished `/distro/add` and `/project/<id>/map` pages to look a little better * Add information where user can add new distribution directly to `/project/<id>/map` * Fix failing test
The PR fixing the lint issue was merged, so I'm doing a rebase to fix also this PR. |
This PR implements #594.
What was changed:
/distro/add
page if there are distributions with similar names (this is also showed on the page itself before submit)/distro/add
and/project/<id>/map
pages to look a little better/project/<id>/map
This changes should prevent making distributions containing typos and duplicates of already existing distributions.