def fixtures(): '''Create some fixtures!''' with app.app_context(): user = User( name=u'tester', email_addr=u'*****@*****.**', api_key='tester' ) user.set_password(u'tester') db.session.add(user) db.session.commit()
def test_user_public_info_keys(self): """Test public info keys works.""" user = User( email_addr="*****@*****.**", name="johndoe", fullname="John Doe", info=dict(avatar='image.png', container='foldr3', token='security'), locale="en") public_info_keys = ['avatar', 'container'] user.set_password("juandiso") assert public_info_keys.sort() == user.public_info_keys().sort() data = user.to_public_json() err_msg = "There are some keys that should not be public" assert data.get('info').keys().sort() == public_info_keys.sort(), err_msg
def test_user_public_info_keys(self): """Test public info keys works.""" user = User(email_addr="*****@*****.**", name="johndoe", fullname="John Doe", info=dict(avatar='image.png', container='foldr3', token='security'), locale="en") public_info_keys = ['avatar', 'container'] user.set_password("juandiso") assert public_info_keys.sort() == user.public_info_keys().sort() data = user.to_public_json() err_msg = "There are some keys that should not be public" assert list( data.get('info').keys()).sort() == public_info_keys.sort(), err_msg
def create_users(cls): root = User( email_addr = cls.root_addr, name = cls.root_name, passwd_hash = cls.root_password, fullname = cls.fullname, api_key = cls.root_api_key) root.set_password(cls.root_password) user = User( email_addr = cls.email_addr, name = cls.name, passwd_hash = cls.password, fullname = cls.fullname, api_key = cls.api_key) user.set_password(cls.password) user2 = User( email_addr = cls.email_addr2, name = cls.name2, passwd_hash = cls.password + "2", fullname = cls.fullname2, api_key=cls.api_key_2) user2.set_password(cls.password) return root, user, user2
def create_users(self): root = User( email_addr = self.root_addr, name = self.root_name, passwd_hash = self.root_password, fullname = self.fullname, api_key = self.root_api_key) root.set_password(self.root_password) user = User( email_addr = self.email_addr, name = self.name, passwd_hash = self.password, fullname = self.fullname, api_key = self.api_key ) user.set_password(self.password) user2 = User( email_addr = self.email_addr2, name = self.name2, passwd_hash = self.password + "2", fullname = self.fullname2, api_key=self.api_key_2) user2.set_password(self.password) return root, user, user2
def create_users(cls): root = User(email_addr=cls.root_addr, name=cls.root_name, passwd_hash=cls.root_password, fullname=cls.fullname, api_key=cls.root_api_key) root.set_password(cls.root_password) user = User(email_addr=cls.email_addr, name=cls.name, passwd_hash=cls.password, fullname=cls.fullname, api_key=cls.api_key) user.set_password(cls.password) user2 = User(email_addr=cls.email_addr2, name=cls.name2, passwd_hash=cls.password + "2", fullname=cls.fullname2, api_key=cls.api_key_2) user2.set_password(cls.password) return root, user, user2
def create_users(self): root = User(email_addr=self.root_addr, name=self.root_name, passwd_hash=self.root_password, fullname=self.fullname, api_key=self.root_api_key) root.set_password(self.root_password) user = User(email_addr=self.email_addr, name=self.name, passwd_hash=self.password, fullname=self.fullname, api_key=self.api_key) user.set_password(self.password) user2 = User(email_addr=self.email_addr2, name=self.name2, passwd_hash=self.password + "2", fullname=self.fullname2, api_key=self.api_key_2) user2.set_password(self.password) return root, user, user2
def test_user_public_attributes(self): """Test public attributes works.""" user = User( email_addr="*****@*****.**", name="johndoe", pro=1, fullname="John Doe", locale="en") public_attributes = ['created', 'name', 'fullname', 'locale', 'info', 'task_runs', 'registered_ago', 'rank', 'score'] user.set_password("juandiso") assert public_attributes.sort() == user.public_attributes().sort() data = user.to_public_json() err_msg = "There are some keys that should not be public" assert data.keys().sort() == public_attributes.sort(), err_msg all_attributes = user.dictize().keys() s = set(public_attributes) private_attributes = [x for x in all_attributes if x not in s] for attr in private_attributes: err_msg = "This attribute should be private %s" % attr assert data.get(attr) is None, err_msg
def test_user_public_attributes(self): """Test public attributes works.""" user = User(email_addr="*****@*****.**", name="johndoe", pro=1, fullname="John Doe", locale="en") public_attributes = [ 'created', 'name', 'fullname', 'locale', 'info', 'task_runs', 'registered_ago', 'rank', 'score' ] user.set_password("juandiso") assert public_attributes.sort() == user.public_attributes().sort() data = user.to_public_json() err_msg = "There are some keys that should not be public" assert data.keys().sort() == public_attributes.sort(), err_msg all_attributes = user.dictize().keys() s = set(public_attributes) private_attributes = [x for x in all_attributes if x not in s] for attr in private_attributes: err_msg = "This attribute should be private %s" % attr assert data.get(attr) is None, err_msg