stevenleeg / geemusic

A bridge between Google Music and Amazon's Alexa
GNU General Public License v3.0
664 stars 181 forks source link

Adds basic integration tests and travis-ci. #235

Closed fergyfresh closed 6 years ago

fergyfresh commented 6 years ago

So I hacked through this the other night, there's still some stuff I have to work though and clean up to make sure that the integration tests actually test the correct things. There's a lot of mocking we would have to do based on our assumptions of some things, gmusicapi and Heroku/AWS etc.

Haven't done these kind of "smoke tests" before so any help or advice would be greatly accepted!

I also had to add the environment variables inside of travis instead of putting them in the YAML file because security, but its only a 1time thing and they are the same exact variables as you have to setup for deployment (Heroku, ngrok, Lambda, etc). There is a way to encrypt them, but I don't really wanna have my credentials living out there in the wild even if they are encrypted.

fergyfresh commented 6 years ago

There's also a new environment variable that I introduced into the config which is ASK_VERIFY_REQUESTS. Anything other than ASK_VERIFY_REQUESTS='False' will keep it on it's default setting. It's basically to set verify=False for all requests calls inside of Flask-Ask.

fergyfresh commented 6 years ago

The first two tests are for testing that the app builds and basic Flask-Ask functionality extensions work properly and the third one is an integration test that tests that the stream url gets generated properly without erroring out. We can trust the gmusicapi CI for most of our stuff, just trying to get CI propped up around features I care about ;)

fergyfresh commented 6 years ago

@stevenleeg hey man. I finally got around to figuring out how to end-to-end functionally test a few pieces of functionality. Over time we can test everything, but 8 tests are better than 0 tests. Setting it up with travis-ci is wicked easy. If you need help I'll be available all afternoon/most of tonight/and all morning tomorrow.

stevenleeg commented 6 years ago

Sorry about the delay here. This looks awesome! Let me see what I can do to get Travis CI on this repo.

stevenleeg commented 6 years ago

Hmm @fergyfresh are you using your google username/password in ENV variables while testing?

fergyfresh commented 6 years ago

So I used these:

APP_URL="my_deployed_copy" ASK_VERIFY_REQUESTS="False" DEBUG_MODE="True" GOOGLE_EMAIL="myactualemail@gmail.com" GOOGLE_PASSWORD="app_password"

I did not use ANDROID_ID. Confirmed!

fergyfresh commented 6 years ago

@stevenleeg let me know if you need anything else. I think you should be good now though, I meant to dump those out before, oops!

mikeage commented 6 years ago

looks like you need to have these environment vars set in .travis.yml (and set to a real email/password), or else all the tests are failing

fergyfresh commented 5 years ago

https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions

I have the ANDROID_ID env var set now and it will work. Maybe we have a staging branch to get around the tests not being able to be run on PR. They seemingly can only be run on commit per that link there. In less someone can come up with a workaround. @mikeage @stevenleeg any ideas?

mikeage commented 5 years ago

Why do the tests need an ANDROID_ID anyway? Would it be possible (better?) just to mock the get_stream_url call from gmusicapi?

If you need the ANDROID_ID, I don't see an alternative to a staging branch (or something like git flow). You could try registering a fake email and using that for all tests, but I assume when Google sees so many logins from so many different IPs, they'll give you problems.

fergyfresh commented 5 years ago

You only around the IP problem with an android I'd. We could mock that call too though.

On Tue, Oct 16, 2018, 2:34 PM Mike Miller notifications@github.com wrote:

Why do the tests need an ANDROID_ID anyway? Would it be possible (better?) just to mock the get_stream_url call from gmusicapi?

If you need the ANDROID_ID, I don't see an alternative to a staging branch (or something like git flow). You could try registering a fake email and using that for all tests, but I assume when Google sees so many logins from so many different IPs, they'll give you problems.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/stevenleeg/geemusic/pull/235#issuecomment-430347913, or mute the thread https://github.com/notifications/unsubscribe-auth/AJN8OB8lebnEu9MWXKB2mJ-capK7_05Yks5uliaxgaJpZM4U4ckk .