Esempio n. 1
0
 def test_init_args(self):
     User = odm.create_model('User', 'name', 'email')
     user = User('luca')
     self.assertEqual(user.name, 'luca')
     self.assertEqual(user.email, None)
     user = User('bla', 'bla@foo')
     self.assertEqual(user.name, 'bla')
     self.assertEqual(user.email, 'bla@foo')
     self.assertRaises(ValueError, User, 'foo', 'jhjh', 'gjgj')
Esempio n. 2
0
 def test_create_name(self):
     User = odm.create_model('UserBase',
                             'name',
                             'email',
                             'name',
                             abstract=True)
     self.assertEqual(User.__name__, 'UserBase')
     self.assertTrue(User._meta.abstract)
     self.assertRaises(AttributeError, User._meta.pkname)
Esempio n. 3
0
 def test_init_args(self):
     User = odm.create_model('User', 'name', 'email')
     user = User('luca')
     self.assertEqual(user.name, 'luca')
     self.assertEqual(user.email, None)
     user = User('bla', 'bla@foo')
     self.assertEqual(user.name, 'bla')
     self.assertEqual(user.email, 'bla@foo')
     self.assertRaises(ValueError, User, 'foo', 'jhjh', 'gjgj')
Esempio n. 4
0
 def test_create(self):
     User = odm.create_model('User', 'name', 'email', 'name')
     self.assertTrue(isinstance(User, odm.ModelType))
     self.assertEqual(User._meta.attributes, ('name', 'email'))
Esempio n. 5
0
 def test_router(self):
     models = odm.Router()
     User = odm.create_model('User', 'name', 'email', 'name')
     models.register(User)
     self.assertEqual(models.user.model, User)
Esempio n. 6
0
 def test_init(self):
     User = odm.create_model('User', 'name', 'email')
     user = User(name='luca')
     self.assertEqual(user.name, 'luca')
     self.assertEqual(user.email, None)
     self.assertRaises(ValueError, User, bla='foo')
Esempio n. 7
0
 def test_create(self):
     User = odm.create_model('User', 'name', 'email', 'name')
     self.assertTrue(isinstance(User, odm.ModelType))
     self.assertEqual(User._meta.attributes, ('name', 'email'))
Esempio n. 8
0
 def test_router(self):
     models = odm.Router()
     User = odm.create_model('User', 'name', 'email', 'name')
     models.register(User)
     self.assertEqual(models.user.model, User)
Esempio n. 9
0
 def test_init(self):
     User = odm.create_model('User', 'name', 'email')
     user = User(name='luca')
     self.assertEqual(user.name, 'luca')
     self.assertEqual(user.email, None)
     self.assertRaises(ValueError, User, bla='foo')
Esempio n. 10
0
 def test_create_name(self):
     User = odm.create_model('UserBase', 'name', 'email', 'name',
                             abstract=True)
     self.assertEqual(User.__name__, 'UserBase')
     self.assertTrue(User._meta.abstract)
     self.assertRaises(AttributeError, User._meta.pkname)