Skip to content

Fixes #1035 - Unified code for version string#1504

Merged
miketaylr merged 2 commits intowebcompat:masterfrom
moraveyo:issues/1035/1
Apr 18, 2017
Merged

Fixes #1035 - Unified code for version string#1504
miketaylr merged 2 commits intowebcompat:masterfrom
moraveyo:issues/1035/1

Conversation

@moraveyo
Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown
Member

@miketaylr miketaylr left a comment

Choose a reason for hiding this comment

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

Looks good! Just a few naming/comment issues, then should be good to merge. 👍

Comment thread webcompat/helpers.py Outdated
session['avatar_url'] = gh_user.get('avatar_url')


def version_string(json_section):

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

Comment thread webcompat/helpers.py Outdated


def version_string(json_section):
'''Gives version string out of section with `major`, `minor`, and `patch`.'''

This comment was marked as abuse.

Comment thread tests/test_helpers.py
self.assertEqual(get_browser(True), 'Unknown')
self.assertEqual(get_browser(False), 'Unknown')
self.assertEqual(get_browser(None), 'Unknown')
self.assertEqual(get_browser_name('<script>lol()</script>'), 'unknown')

This comment was marked as abuse.

@miketaylr
Copy link
Copy Markdown
Member

miketaylr commented Apr 14, 2017

@moraveyo I'm not sure if this is ready for re-review yet, can you ping when it is?

Thanks!

(no rush, just want to make sure I'm not ignoring your work.)

@moraveyo
Copy link
Copy Markdown
Contributor Author

r? @miketaylr
What "bizarre UA strings" can I add to tests, to test the name treatment? (Just can't make it up)

@miketaylr
Copy link
Copy Markdown
Member

What "bizarre UA strings" can I add to tests, to test the name treatment? (Just can't make it up)

You could use some of the bogus stuff in these tests: https://github.com/moraveyo/webcompat.com/blob/eadb82be50b3e6d8e7095c57959725b467b0114e/tests/test_helpers.py#L145-L151, or you could invent something wacky like

"Nozilla/1.0 (TI-83 Graphing Calculator;) CoolBrowser/1.0"

@miketaylr
Copy link
Copy Markdown
Member

@moraveyo can you run pep8 on your changes? There's a few style nits here -- thanks!

pep8 webcompat/helpers.py
webcompat/helpers.py:104:1: W293 blank line contains whitespace
webcompat/helpers.py:105:80: E501 line too long (85 > 79 characters)
webcompat/helpers.py:109:19: E701 multiple statements on one line (colon)
webcompat/helpers.py:111:17: E701 multiple statements on one line (colon)
webcompat/helpers.py:113:17: E701 multiple statements on one line (colon)
webcompat/helpers.py:114:19: E221 multiple spaces before operator
webcompat/helpers.py:119:1: W293 blank line contains whitespace

@moraveyo
Copy link
Copy Markdown
Contributor Author

Oops... I first tried pep8 --show-source --show-pep8 . from CONTRIBUTING.md, and it does million of messages, so I thought it's broken.

@moraveyo
Copy link
Copy Markdown
Contributor Author

r? @miketaylr
As to "bizarre UA strings", I thought about some string resulting in 'family':'Other' with any version number. After some research I see it's not possible.
So I guess tests already cover things, and it's done.

@miketaylr
Copy link
Copy Markdown
Member

LGTM! We just need to clean up the git history. Maybe 3 commits: 1 for the unified code refactor, one for the new tests, and one for fixing the existing tests? LMK if you get stuck on that!

@moraveyo
Copy link
Copy Markdown
Contributor Author

r? @miketaylr
I'm putting the code with new tests in one commit: there already was a commit with both, I don't know how to split it.
Hope I didn't do wrong with Rebase.

@moraveyo
Copy link
Copy Markdown
Contributor Author

Looks like I did the mess with rebase

@moraveyo
Copy link
Copy Markdown
Contributor Author

r? @miketaylr
Now I hope it's OK.

@miketaylr
Copy link
Copy Markdown
Member

Awesome, thanks! And yeah, splitting git commits is not fun (or easy...). This looks great, thanks for all your work here.

@miketaylr miketaylr merged commit 5d647d1 into webcompat:master Apr 18, 2017
@miketaylr
Copy link
Copy Markdown
Member

(there were some pep8 errors, but I pushed a fixup commit here: e02eccb)

@moraveyo
Copy link
Copy Markdown
Contributor Author

Strange, I've already removed some spaces so that pep8 tests/test_helpers.py made no messages for remaining ones.
All those spaces were for visual clearness...

@moraveyo
Copy link
Copy Markdown
Contributor Author

I first even tried # nopep8 at the end of each line - didn't work.

@miketaylr
Copy link
Copy Markdown
Member

Hmm, odd that we saw different things. In general, python style doesn't like whitespace for alignment. See https://www.python.org/dev/peps/pep-0008/#whitespace-in-expressions-and-statements (look for "More than one space around an assignment (or other) operator to align it with another. ")

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.

2 participants