def test_set_name_error(self): response = self.app.post(url("set_name_accounts"), extra_environ=self.extra_environ) sess = response.environ['beaker.session'] from columns.model import User tmp = User.get_from_id(1) self.assertEquals(tmp.name,u"test_user") self.assertEquals(sess[u'user_name'],u"test_user")
def test_set_name_true(self): response = self.app.post(url("set_name_accounts"), extra_environ=self.extra_environ, params={'name':'qwertyuiop'}) sess = response.environ['beaker.session'] from columns.model import User tmp = User.get_from_id(1) self.assertEquals(tmp.name,u"qwertyuiop") self.assertEquals(sess[u'user_name'],u"qwertyuiop")
def test_delete_browser_fakeout(self): tmp_environ = {'test.session':{ 'user_id':1, 'user_name':u'test_user', 'user_type':9, 'user_profile':u'http://www.example.com', 'user_openid':u'http://tester.example.com', 'user_fbid':None, 'user_twitterid':None, 'auth_type':u'twitter', 'oid':u'1234567890' },'columns.authorize.disabled':True} response = self.app.post(url('accounts'), extra_environ=tmp_environ, params=dict(_method='delete')) sess = response.environ['beaker.session'] from columns.model import User tmp = User.get_from_id(1) self.assertEquals(tmp,None) self.assertEquals(sess.get('user_id',None),None)
def test_update_json(self): response = self.app.put(url('formatted_user', id=1, format='json'), extra_environ=self.extra_environ, content_type='application/json', body=json.dumps(dict( name=u'test_user', open_id=u'http://myfake.openid.com', fb_id='', twitter_id='', type=1, profile=u'http://www.example.com/32', ))) from columns.model import User tmp = User.get_from_id(1) print tmp.to_dict() assert tmp.name == u'test_user' assert tmp.open_id == u'http://myfake.openid.com' assert tmp.fb_id == None assert tmp.twitter_id == None assert tmp.type == 1 assert tmp.profile == u'http://www.example.com/32'
def test_update(self): response = self.app.put(url('user', id=1), extra_environ=self.extra_environ, params=dict( name=u'test_user', open_id=u'http://myfake.openid.com', fb_id='', twitter_id='', type=1, profile=u'http://www.example.com/32', )) from columns.model import User tmp = User.get_from_id(1) print tmp.to_dict() assert tmp.name == u'test_user' assert tmp.open_id == u'http://myfake.openid.com' assert tmp.fb_id == None assert tmp.twitter_id == None assert tmp.type == 1 assert tmp.profile == u'http://www.example.com/32'
def test_update_2(self): tmp_environ = {'test.session':{ 'user_id':1, 'user_name':u'test_user', 'user_type':9, 'user_profile':u'http://www.example.com', 'user_openid':u'http://tester.example.com', 'user_fbid':None, 'user_twitterid':None, 'auth_type':u'openid', 'oid':u'1234567890' },'columns.authorize.disabled':True} response = self.app.put(url('accounts'), extra_environ=tmp_environ, params={'profile':'http://test.com'}) sess = response.environ['beaker.session'] from columns.model import User tmp = User.get_from_id(1) self.assertEquals(tmp.profile,u'http://test.com') self.assertEquals(sess['user_profile'],u'http://test.com') self.assertEquals(tmp.open_id,u'1234567890')
def test_delete_browser_fakeout(self): response = self.app.post(url('user', id=1), extra_environ=self.extra_environ, params=dict(_method='delete')) from columns.model import User tmp = User.get_from_id(1) assert tmp == None
def test_delete(self): response = self.app.delete(url('user', id=1), extra_environ=self.extra_environ) from columns.model import User tmp = User.get_from_id(1) assert tmp == None