Esempio n. 1
0
 def test_redirects_to_user_profile_when_valid(self):
     from cody.views.users import create
     from cody.models import User
     from pyramid.httpexceptions import HTTPFound
     request = testing.DummyRequest()
     request.params['username'] = u'john55'
     request.params['password'] = u'password'
     request.params['name'] = u'John Doe'
     request.params['email'] = u'*****@*****.**'
     request.params['location'] = u'Quebec'
     response = create(request)
     self.assertEqual(type(response), HTTPFound)
     self.assertEqual(response.location, 'http://example.com/users/1')
Esempio n. 2
0
 def test_creates_user_when_valid(self):
     from cody.views.users import create
     from cody.models import User
     from pyramid.httpexceptions import HTTPFound
     from cody.models import DBSession
     request = testing.DummyRequest()
     request.params['username'] = u'john55'
     request.params['password'] = u'password'
     request.params['name'] = u'John Doe'
     request.params['email'] = u'*****@*****.**'
     request.params['location'] = u'Quebec'
     response = create(request)
     session = DBSession()
     user = DBSession.query(User).one()
     self.assertEqual(user.username, u'john55')
     self.assertGreater(len(user.password), 0)
     self.assertEqual(user.name, u'John Doe')
     self.assertEqual(user.email, u'*****@*****.**')
     self.assertEqual(user.location, u'Quebec')