Skip to content
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

Tests Fail with Django 1.9 #275

Closed
alexphelps opened this issue Dec 4, 2015 · 32 comments
Closed

Tests Fail with Django 1.9 #275

alexphelps opened this issue Dec 4, 2015 · 32 comments

Comments

@alexphelps
Copy link

Tests fail with Django 1.9 meaning that all new Pull Requests will fail given that the current requirements_test.txt has django>=1.7 which will result in 1.9 being installed during the build.

Example build - https://travis-ci.org/pydanny/dj-stripe/jobs/94795855

I wish I knew how to fix this but it's a little over my head as to how these tests actually work. 😖

======================================================================
ERROR: test_change_sub_stripe_error (tests.test_views.ChangePlanViewTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/virtualenv/python3.5.0/lib/python3.5/site-packages/mock/mock.py", line 1305, in patched
    return func(*args, **keywargs)
  File "/home/travis/build/pydanny/dj-stripe/tests/test_views.py", line 333, in test_change_sub_stripe_error
    self.assertIn("No such plan: test_id_3", response.context["form"].errors["__all__"])
KeyError: '__all__'
======================================================================
ERROR: test_post_new_sub_no_proration (tests.test_views.ChangePlanViewTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/virtualenv/python3.5.0/lib/python3.5/site-packages/mock/mock.py", line 1305, in patched
    return func(*args, **keywargs)
  File "/home/travis/build/pydanny/dj-stripe/tests/test_views.py", line 273, in test_post_new_sub_no_proration
    self.assertIn("You must already be subscribed to a plan before you can change it.", response.context["form"].errors["__all__"])
KeyError: '__all__'
======================================================================
ERROR: test_post_no_card (tests.test_views.ConfirmFormViewTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/virtualenv/python3.5.0/lib/python3.5/site-packages/mock/mock.py", line 1305, in patched
    return func(*args, **keywargs)
  File "/home/travis/build/pydanny/dj-stripe/tests/test_views.py", line 235, in test_post_no_card
    self.assertIn("Invalid source object:", response.context["form"].errors["__all__"])
KeyError: '__all__'
@pydanny
Copy link
Contributor

pydanny commented Dec 17, 2015

@alexphelps, thanks for letting us know about this issue. We're working on it right now (and deprecating 1.7 while we are at it per #278 278).

@kavdev
Copy link
Member

kavdev commented Dec 23, 2015

This is due to a regression in 1.9 that will be fixed in 1.9.1. See the bug report and the commit.

I'll make a note of it in the documentation.

kavdev added a commit that referenced this issue Dec 23, 2015
kavdev added a commit that referenced this issue Dec 23, 2015
@kavdev
Copy link
Member

kavdev commented Dec 23, 2015

Tested with 1.9.1 dev; no issues. Give it a shot if you'd like:

pip uninstall django
pip install git+https://github.com/django/django.git@0154702a987bd06d20e53fe23284b2c4a93b9063

@kavdev kavdev closed this as completed Dec 23, 2015
@alexphelps
Copy link
Author

Nice 👍

@jayfk jayfk mentioned this issue Dec 31, 2015
@kavdev
Copy link
Member

kavdev commented Jan 2, 2016

Good news! 1.9.1 just released

@patroqueeet
Copy link

patroqueeet commented Apr 22, 2017

why am I seeing

~/.ve/local/lib/python2.7/site-packages/djstripe/__init__.py:23: UserWarning: dj-stripe deprecation notice: Django 1.7 and lower are no longer
supported. Please upgrade to Django 1.8 or higher.
Reference: https://github.com/pydanny/dj-stripe/issues/275

in my Django 1.10.7 installation? shouldn't that be void?

@tobydeh
Copy link

tobydeh commented May 30, 2017

Why am I being asked to upgrade to django 1.8 or higher when I'm running django 1.11.1?

@kavdev
Copy link
Member

kavdev commented May 30, 2017

@tobydeh see #307. We haven't cherry-picked that fix into master and won't because we're about to release 1.0.0

@the-webguys
Copy link

Hello

I am receiving two different errors, this:
UserWarning: dj-stripe deprecation notice: Django 1.7 and lower are no longer
supported. Please upgrade to Django 1.8 or higher.
Reference: https://github.com/pydanny/dj-stripe/issues/275
warnings.warn(msg)
I am using: Django==1.11.3 | stripe==1.62.0

And this, when running the final command 'python manage.py djstripe_init_customers' i receive the following
if ("email" not in subscriber_model._meta.get_all_field_names()) and not hasattr(subscriber_model, 'email'):
AttributeError: 'Options' object has no attribute 'get_all_field_names'

@kavdev
Copy link
Member

kavdev commented Jul 31, 2017

@the-webguys Go ahead and switch to the 1.0.0 branch. You'll find the errors will disappear

@the-webguys
Copy link

@kavdev sorry for my ignorance, how do i switch? since i used pip install, is there a different command i need to run?

@kavdev
Copy link
Member

kavdev commented Jul 31, 2017

@the-webguys no worries! We've been slow to release the major version change.

pip install git+https://github.com/dj-stripe/dj-stripe.git@1.0.0

@the-webguys
Copy link

you are a legend, thank you

@the-webguys
Copy link

the-webguys commented Jul 31, 2017

@kavdev any reason i am seeing this error
?: (djstripe.C003) Bad Stripe test API key.
HINT: STRIPE_TEST_SECRET_KEY should start with "sk_test_"
The key is a test key lol

@the-webguys
Copy link

solved it, i needed to change STRIPE_SECRET_KEY to STRIPE_TEST_SECRET_KEY

@the-webguys
Copy link

the-webguys commented Jul 31, 2017

@kavdev but i have a load of new issues, where is the best place to put this, do you have slack?

@kavdev
Copy link
Member

kavdev commented Jul 31, 2017

@the-webguys stackoverflow is the best place to post the question, then just ping us about it on gitter

In the meantime, this is the setup I've used for a multi-server (prod, staging, etc.) setup that doesn't keep track of live and test data in the same db. I change the key in the environment for each server.

STRIPE_SECRET_KEY = get_env_variable("STRIPE_SECRET_KEY")
STRIPE_PUBLISHABLE_KEY = get_env_variable("STRIPE_PUBLISHABLE_KEY")
STRIPE_PUBLIC_KEY = STRIPE_PUBLISHABLE_KEY
STRIPE_LIVE_SECRET_KEY = STRIPE_TEST_SECRET_KEY = STRIPE_SECRET_KEY
STRIPE_LIVE_MODE = get_env_variable("STRIPE_LIVE_MODE")

@kavdev
Copy link
Member

kavdev commented Jul 31, 2017

@the-webguys only go to stackoverflow if it's a question on how to configure or set up dj-stripe; if you find a possible bug, file an issue 👍

@the-webguys
Copy link

@kavdev what would be the test mode for this?
STRIPE_LIVE_MODE = get_env_variable("STRIPE_LIVE_MODE")
STRIPE_TEST_MODE ?

@kavdev
Copy link
Member

kavdev commented Jul 31, 2017

@the-webguys STRIPE_LIVE_MODE is a boolean

@the-webguys
Copy link

@kavdev would this work?
STRIPE_LIVE_MODE = false

@kavdev
Copy link
Member

kavdev commented Jul 31, 2017

@the-webguys with a capital F, yes 😉

@the-webguys
Copy link

the-webguys commented Jul 31, 2017

@kavdev
In the install / setup, the examples are
STRIPE_PUBLIC_KEY = os.environ.get("STRIPE_PUBLIC_KEY", "pk_test_XXXXXXXXXXXXXXXXX")
but here you use
STRIPE_SECRET_KEY = get_env_variable("STRIPE_SECRET_KEY")
i just receive an error
NameError: name 'get_env_variable' is not defined

@kavdev
Copy link
Member

kavdev commented Jul 31, 2017

@the-webguys yeah sorry that's just an example from a product of mine (I'm essentially using the env method described in Two Scoops).

Go ahead and use the format described in the docs

@the-webguys
Copy link

@kavdev
which should be just the following 2 lines, of do i need the STRIPE_LIVE_MODE = False also

STRIPE_PUBLIC_KEY = os.environ.get("STRIPE_PUBLIC_KEY", "pk_test_XXXXXXXXXX")
STRIPE_SECRET_KEY = os.environ.get("STRIPE_SECRET_KEY", "sk_test_XXXXXXXXXX")

@kavdev
Copy link
Member

kavdev commented Jul 31, 2017

yep. also STRIPE_LIVE_SECRET_KEY = STRIPE_TEST_SECRET_KEY = STRIPE_SECRET_KEY if you're not splitting up the keys

@the-webguys
Copy link

that's a little confusing, the way i have it now with STRIPE_LIVE_MODE = False will or should work, as they are?
Sorry, I am fairly new to django

@the-webguys
Copy link

as follows:

STRIPE_PUBLIC_KEY = os.environ.get("STRIPE_PUBLIC_KEY", "pk_test_XXXXXXXXXX")
STRIPE_SECRET_KEY = os.environ.get("STRIPE_SECRET_KEY", "sk_test_XXXXXXXXXX")
STRIPE_LIVE_MODE = False

gives the following error
HINT: STRIPE_TEST_SECRET_KEY should start with "sk_test_"

@kavdev
Copy link
Member

kavdev commented Jul 31, 2017

@the-webguys it has to do with the way we're reading the variables. Technically you should be adding in both test and live keys explicitly.

For this to work as is, just add the following line:
STRIPE_LIVE_SECRET_KEY = STRIPE_TEST_SECRET_KEY = STRIPE_SECRET_KEY

@the-webguys
Copy link

Do i replace STRIPE_TEST_SECRET_KEY with my test key?

@kavdev
Copy link
Member

kavdev commented Jul 31, 2017

Ideally, you would set

STRIPE_LIVE_SECRET_KEY
STRIPE_LIVE_PUBLIC_KEY
STRIPE_TEST_SECRET_KEY
STRIPE_TEST_PUBLIC_KEY
STRIPE_LIVE_MODE

And populate them from the environment (hard-coding keys is bad practice)

@the-webguys
Copy link

Think i have that correct, thanks again

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

No branches or pull requests

6 participants