-
Notifications
You must be signed in to change notification settings - Fork 203
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
Fixes #712: Mock (some of the) communication with GitHub API #774
Conversation
One failure on the travis push (and same failure on PR build)
I was having trouble with this locally as well. The mock response is too fast (like 3 - 5ms), I think it's hidden before Intern can find the loader image. This might mean we need to re-think how to test this. |
from flask import session | ||
from flask import send_from_directory |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
Ah interesting! You decided to mock at the python level. I thought that you would mock at the intern level of the functional test suite, which are the one mostly generating requests to the github API through webcompat. https://www.sitepen.com/blog/2014/07/14/mocking-data-with-intern/ Ok let me look at this one. At first sight it looks good. Let me try to import your branch. git checkout master
git fetch upstream;git merge upstream/master
# Importing your branch in a local branch
git checkout -b 712/1 upstream/issues/712/1
# Branch 712/1 set up to track remote branch issues/712/1 from upstream.
# Switched to a new branch '712/1'
python run.py
# * Running on http://localhost:5000/ (Press CTRL+C to quit)
# * Restarting with stat
# OK this part is working In a separate shell window java -jar /Users/karl/bin/selenium-server-standalone-2.46.0.jar
# 11:22:19.468 INFO - Launching a standalone Selenium Server
# 11:22:19.545 INFO - Java: Oracle Corporation 24.51-b03
# 11:22:19.545 INFO - OS: Mac OS X 10.11 x86_64
# 11:22:19.578 INFO - v2.46.0, with Core v2.46.0. Built from revision 87c69e2
# 11:22:19.706 INFO - Driver provider org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
# registration capabilities Capabilities [{platform=WINDOWS, ensureCleanSession=true, browserName=internet explorer, version=}] does not match the current platform MAC
# 11:22:19.707 INFO - Driver class not found: com.opera.core.systems.OperaDriver
# 11:22:19.707 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
# 11:22:20.134 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
# 11:22:20.134 INFO - Selenium Server is up and running In yet another shell window: workon webcompatcom
# (webcompatcom)11:24:13 ~/code/webcompat.com
node_modules/.bin/intern-runner config=tests/intern I wonder if I'm missing a couple of things. Probably CSS/JS. Some tests are failing. Interesting if I type
|
Another source for doing it on the intern side. I do not know if it's easier. |
The way I'm doing mocking this branch gets the job done, but I think it's kind of weird (and intrusive) to put in the mocking decorators right in the endpoint routes. :/
Ah yeah, start the server in test mode: I did look at Nock (and about 8 similar things -- but all my notes are local, oops). It seems like similar things work really well if your app is written in Node, or are geared towards unit testing (rather than in-browser functional testing). It might be possible to glue this and Intern together though? I'll look around. Another option I thought about was running the site behind a proxy that intern runs func tests on, and intercepts requests to port 5000 that start with |
|
(Hmm, I'm not sure about that grunt error though. O_o) |
yes. Frustrating because the UI of the different branches I'm trying is not working so far. I checked the permissions in node, some were given to root and fixed them with sudo chown -R karl:staff node_modules Tried
Ah maybe more locking in
Let's see sudo chown -R karl:staff /Users/karl/.npm Gotcha!
yeeha! Maybe I can debug @magsout issue now 432ba9e#commitcomment-13916997 |
Heh, computers are the worst. |
Oops, I forgot to run the server in test mode before pushing my "re-write" of that failing test. :/ |
A stopgap, but if the issues load faster than Intern can query the DOM, then we always fail. With this move, we have to hit the network and there is enough time. FIXME?
Needed to rebase against master to fix a conflict, so incoming destructive |
b61c280
to
94f00ac
Compare
OK, tests should be passing now. I filed #791 to come back and make sure we add/re-write the test that I ripped out to get this to pass. @karlcow, what do you think. We merge now and keep improving API mocking, including login/logout? Or not worth the effort and re-write everything w/ a proxy? That's fine (honestly, no hard feelings), but I probably won't revisit this work for a few months if so--have to move on to other Moz goals stuff and screenshot uploading. |
@miketaylr in the back of my head I have the feeling there's a way that would make it easier, but I haven't found it too. So :) To move forward and to breathe a bit, let's merge this one and we can still improve in the future. It's a step in the direction we desire. :) 💯 |
Fixes #712: Mock (some of the) communication with GitHub API
Cool, thanks. I might play with the proxy approach on some stray Saturday -- I think that will be simpler. |
r? @karlcow
Here's the general strategy:
We have a
@mockable_repsponse
decorator to add to an API endpoint.IF we're in test mode (
python run.py -t
), instead of making the request to GitHub, we serve a file fromtest/fixtures/
instead.Limitations:
I needed to remove a few tests from our label tests, but will open an issue to figure that out. Solving the WRITE mocking will help, I think.