Esempio n. 1
0
 def test_create_tables(self):
     """Test that model.create_tables correctly creates all database tables."""
     self.assertRaises(OperationalError, User.by_user_name, u'test')
     create_tables()
     assert _create_test_user()
     create_tables()
     assert User.by_user_name(u'creosote')
     create_tables(drop_all=True)
     user = User.by_user_name(u'creosote')
     assert user is None
Esempio n. 2
0
def _create_test_user():
    obj = User()
    obj.user_name = u"creosote"
    obj.email_address = u"*****@*****.**"
    obj.display_name = u"Mr Creosote"
    obj.password = u"Wafer-thin Mint"
    # mark object as 'to be saved'
    session.add(obj)
    # flush marked object to database
    session.flush()
    return obj
Esempio n. 3
0
 def test_create_default_user(self):
     "Test that the default user is created correctly"
     create_tables()
     create_default_user(u'creosote', u'secret')
     retrieved_user = User.by_email_address(u'*****@*****.**' % u'creosote')
     assert retrieved_user
     assert retrieved_user.user_name == u'creosote'
     assert retrieved_user.display_name == u'Default User'
     assert retrieved_user.password
Esempio n. 4
0
 def test_user_creation(self):
     """Object creation should set the name."""
     obj = _create_test_user()
     retrieved_user = User.by_email_address(u'*****@*****.**')
     assert retrieved_user, \
         'User should have been found by email address'
     assert retrieved_user.user_name == u'creosote', \
         "User name should have been creosote, not '%s'" % retrieved_user.user_name
     assert obj.display_name == u"Mr Creosote"