Example #1
0
class JomFactoryTestCase(TestCase):
    
    def setUp(self):
        self.factory = JomFactory()
        
    def tearDown(self):
        self.factory = None
        
    def testRegisterJomDescriptor(self):
        descriptor = self.factory.register(SimpleModelJomDescriptor)
        self.assertTrue(isinstance(descriptor, SimpleModelJomDescriptor))
    
    def testGetForName(self):
        name = SimpleModel.__name__
        descriptor = self.factory.register(SimpleModelJomDescriptor)
        self.assertEqual(descriptor, self.factory.getForName(name))
    
    def testGetForModel(self):
        descriptor = self.factory.register(SimpleModelJomDescriptor)
        self.assertEqual(descriptor, self.factory.getForModel(SimpleModel))
    
    def testGetJomInstance(self):
        instance = SimpleModel.objects.create(name = "foo")
        descriptor = self.factory.register(SimpleModelJomDescriptor)
        self.assertEqual(descriptor,
                self.factory.getJomInstance(instance).descriptor)
        instance.delete()
        
    def testGetJomClass(self):
        descriptor = self.factory.register(SimpleModelJomDescriptor)
        self.assertEqual(descriptor,
                self.factory.getJomClass(SimpleModel).descriptor)
Example #2
0
class JomDescriptorTestCase(TestCase):
    
    def setUp(self):
        self.factory = JomFactory()
        self.descriptor = self.factory.register(
                ModelWithAllFieldsJomDescriptor)
        
    def tearDown(self):
        self.factory = None
        self.descriptor = None
        
    def testJomFieldsCreated(self):
        fields = self.descriptor.jom_fields
    
        self.assertEqual(StringJomField, fields['slug'])
        self.assertEqual(StringJomField, fields['text'])
        self.assertEqual(StringJomField, fields['char'])
        self.assertEqual(StringJomField, fields['email'])
        self.assertEqual(StringJomField, fields['url'])
        self.assertEqual(StringJomField, fields['comma_separated_integer'])
        
        self.assertEqual(NumeralJomField, fields['integer'])
        self.assertEqual(NumeralJomField, fields['positive_integer'])
        self.assertEqual(NumeralJomField, fields['small_integer'])
        self.assertEqual(NumeralJomField, fields['small_positive_integer'])
        self.assertEqual(NumeralJomField, fields['big_integer'])
        self.assertEqual(NumeralJomField, fields['float'])
        
        self.assertEqual(BooleanJomField, fields['boolean'])
        
        self.assertEqual(DateJomField, fields['date'])
        self.assertEqual(DateJomField, fields['time'])
        self.assertEqual(DateJomField, fields['datetime'])
        
        self.assertEqual(UrlJomField, fields['file'])
        self.assertEqual(UrlJomField, fields['image'])