Skip to content

Instantly share code, notes, and snippets.

@sunglassatnight
Created December 2, 2013 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sunglassatnight/7751680 to your computer and use it in GitHub Desktop.
Save sunglassatnight/7751680 to your computer and use it in GitHub Desktop.
foursquare auth
from pingspot.dal.users import UserService
from sys import uuid
def test_foursquare_auth_token(dal, uniqueuser):
user = uniqueuser()
auth_token = str(uuid.uuid4())
user.foursquare_auth_token = auth_token
saved_user = UserService.users.get_or_create_by_social_identifier(user)
assert user.foursquare_auth_token == auth_token
assert user.foursquare_auth_token == saved_user.foursquare_auth_token
@jong
Copy link

jong commented Dec 2, 2013

line 3 = when you call the uuid.uuid4 function (like this uuid.uuid4(), you're getting a uuid object back, so you don't need to call it again on like 7. since your variable is storing an object, it should be named like a noun - auth_token, not a verb phrase (get_blah_blah).

also, there's no reason to have a module level variable for this thing - go ahead and move it into the test function.

also, I just happen to know that the result of uuid.uuid4() is not a string, so you'll need to create a string out of it by calling the str function with the value of the uuid.uuid4() function, like this:

auth_token = str(uuid.uuid4())

@six8
Copy link

six8 commented Dec 2, 2013

UserService.users.get_or_create_by_social_identifier(user) should actually be dal.users.get_or_create_by_social_identifier(user). However, as we discussed in chat, what we need here is dal.users.set_foursquare_auth_token(user, token)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment