def create(cls, substance): def _validate(substance): if not substance: return False if not substance.get("author_name"): return False if not substance.get("mail_address"): return False if not substance.get("password"): return False return True if not _validate(substance): raise IllegalRequestError(None) if Author.exists_by_mail_address(substance.get("mail_address")): raise AlreadyRegisteredError(None) author = Author( id=Author.make_author_id_hash(), author_name=substance.get("author_name"), password=Author.make_password_hash(substance.get("password")), mail_address=substance.get("mail_address") ) author.put() return True
def test_to_hash(self): author = Author( mail_address="*****@*****.**", author_name="test user", password="******", ) author_key = author.put() author.to_hash() self.assertEqual(1, 1)