예제 #1
0
 def test_new_user(self, mock):
     mock.side_effect = render
     start_count = Session.query(User).count()
     response = self.app.get(url('/users/new'))
     assert response.form is not None
     response.form["name"] = "Example User"
     response.form["email"] = "*****@*****.**"
     response.form["password"] = "******"
     response.form["password_confirmation"] = "foobar"
     response = response.form.submit('submit')
     assert response.status_int == 302
     response = response.follow()
     mock.assert_called_with("/derived/users/show.mako")
     assert start_count + 1 == Session.query(User).count()
예제 #2
0
 def test_success(self):
     response = self.app.post(url(controller='users', action='create'), params=self.a_user)
     u=Session.query(User).filter(User.email==self.a_user["email"]).first()
     assert response.status_int == 302, response.status
     assert urlparse(response.response.location).path == url('user', id=u.id)
     assert response.session.has_key("flash")
     msg = response.session["flash"]
     assert re.search("welcome to the sample app", msg[0][1], re.I)
예제 #3
0
 def test_no_new_user(self):
     start_count = Session.query(User).count()
     response = self.app.get(url('/users/new'))
     response = response.form.submit('submit')
     assert start_count == Session.query(User).count()
예제 #4
0
def create_obj(cls, **kwargs):
    obj = cls(**kwargs)
    Session.add(obj)
    Session.commit()
    return obj