Skip to content

Instantly share code, notes, and snippets.

@Deviad
Created July 21, 2017 20:48
Show Gist options
  • Save Deviad/f283b202caab477a39670dc717e1c831 to your computer and use it in GitHub Desktop.
Save Deviad/f283b202caab477a39670dc717e1c831 to your computer and use it in GitHub Desktop.
Getting out of context error
import json
import urllib
from pprint import pprint
from urllib import request, parse
import pytest
from inspect import getsourcefile
from os import path, sys
current_dir = path.dirname(path.abspath(getsourcefile(lambda:0)))
sys.path.insert(0, current_dir[:current_dir.rfind(path.sep)])
from theroot.users_bundle.models.user import User
from theroot import app
from theroot.db import *
from theroot.users_bundle.controllers import do_the_signup
sys.path.pop(0)
app.testing = True
client = app.test_client()
class TestApp(object):
def test_create_user(self):
values = {
"data": {
"email": "cicciopizzo100@gmail.com",
"password": "test",
"first_name": "ciccio",
"last_name": "pizzo",
"role": "1",
"address": {
"country": "Italy",
"address_line": "Test Address, 1998, WXDJI Neverland, Italy",
"coordinates": {
"lat": "41.0914808",
"long": "16.8672337"
}
}
}
}
do_the_signup(values)
# email = 'cicciorizzo02@gmail.com'
# password = 'thesuperpassword'
# user = User(email, password)
# db.session.add(user)
# db.session.commit()
# pprint(user.email)
user_name = ', '.join(db.session.query(User.email).filter_by(email=values['data']['email']).first())
assert values['data']['email'] == user_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment