Example #1
0
 def setUp(self):
     unregister(Encounter)
     unregister(Patient)
     register(Encounter, filter_by_parent=True)
     register(Patient, filter_by_parent=True)
     Attribute.objects.create(name='age', parent=Patient, datatype=Attribute.TYPE_INT)
     Attribute.objects.create(name='date', parent=Encounter, datatype=Attribute.TYPE_DATE)
     Attribute.objects.create(name='cost', parent=Encounter, datatype=Attribute.TYPE_FLOAT)
Example #2
0
 def test_unregistering(self):
     old_mgr = Patient.objects
     eav.register(Patient)
     self.assertTrue(Patient.objects.__class__.__name__ == 'EntityManager')
     eav.unregister(Patient)
     self.assertFalse(Patient.objects.__class__.__name__ == 'EntityManager')
     self.assertEqual(Patient.objects, old_mgr)
     self.assertFalse(hasattr(Patient, '_eav_config_cls'))
Example #3
0
 def test_registering_with_defaults(self):
     eav.register(Patient)
     self.assertTrue(hasattr(Patient, "_eav_config_cls"))
     self.assertEqual(Patient._eav_config_cls.manager_attr, "objects")
     self.assertFalse(Patient._eav_config_cls.manager_only)
     self.assertEqual(Patient._eav_config_cls.eav_attr, "eav")
     self.assertEqual(Patient._eav_config_cls.generic_relation_attr, "eav_values")
     self.assertEqual(Patient._eav_config_cls.generic_relation_related_name, None)
     eav.unregister(Patient)
Example #4
0
 def test_registering_with_defaults(self):
     register(Patient)
     self.assertTrue(hasattr(Patient, '_eav_config_cls'))
     self.assertEqual(Patient._eav_config_cls.manager_attr, 'objects')
     self.assertFalse(Patient._eav_config_cls.manager_only)
     self.assertEqual(Patient._eav_config_cls.eav_attr, 'eav')
     self.assertEqual(Patient._eav_config_cls.generic_relation_attr,
                      'eav_values')
     self.assertEqual(Patient._eav_config_cls.generic_relation_related_name,
                      None)
     unregister(Patient)
Example #5
0
 def test_registering_with_defaults(self):
     eav.register(Patient)
     self.assertTrue(hasattr(Patient, '_eav_config_cls'))
     self.assertEqual(Patient._eav_config_cls.manager_attr, 'objects')
     self.assertFalse(Patient._eav_config_cls.manager_only)
     self.assertEqual(Patient._eav_config_cls.eav_attr, 'eav')
     self.assertEqual(Patient._eav_config_cls.generic_relation_attr,
                      'eav_values')
     self.assertEqual(Patient._eav_config_cls.generic_relation_related_name,
                      None)
     eav.unregister(Patient)
Example #6
0
    def test_registering_overriding_defaults(self):
        eav.register(Patient)
        self.register_encounter()
        self.assertTrue(hasattr(Patient, '_eav_config_cls'))
        self.assertEqual(Patient._eav_config_cls.manager_attr, 'objects')
        self.assertEqual(Patient._eav_config_cls.eav_attr, 'eav')

        self.assertTrue(hasattr(Encounter, '_eav_config_cls'))
        self.assertEqual(Encounter._eav_config_cls.manager_attr, 'eav_objects')
        self.assertEqual(Encounter._eav_config_cls.eav_attr, 'eav_field')
        eav.unregister(Patient)
        eav.unregister(Encounter)
Example #7
0
    def test_registering_overriding_defaults(self):
        eav.register(Patient)
        self.register_encounter()
        self.assertTrue(hasattr(Patient, "_eav_config_cls"))
        self.assertEqual(Patient._eav_config_cls.manager_attr, "objects")
        self.assertEqual(Patient._eav_config_cls.eav_attr, "eav")

        self.assertTrue(hasattr(Encounter, "_eav_config_cls"))
        self.assertEqual(Encounter._eav_config_cls.get_attributes(), "testing")
        self.assertEqual(Encounter._eav_config_cls.manager_attr, "eav_objects")
        self.assertEqual(Encounter._eav_config_cls.eav_attr, "eav_field")
        eav.unregister(Patient)
        eav.unregister(Encounter)
    def test_illegal_assignemnt(self):
        class EncounterEavConfig(EavConfig):
            @classmethod
            def get_attributes(cls, instance=None):
                return Attribute.objects.filter(datatype=Attribute.TYPE_INT)

        eav.unregister(Encounter)
        eav.register(Encounter, EncounterEavConfig)

        p = Patient.objects.create(name='Jon')
        e = Encounter.objects.create(patient=p, num=1)

        with self.assertRaises(IllegalAssignmentException):
            e.eav.color = 'red'
            e.save()
Example #9
0
 def tearDown(self):
     eav.unregister(Encounter)
     eav.unregister(Patient)
Example #10
0
 def test_unregistering_unregistered_model_proceeds_silently(self):
     eav.unregister(Patient)
Example #11
0
 def tearDown(self):
     eav.unregister(Patient)
 def tearDown(self):
     eav.unregister(Encounter)
     eav.unregister(Patient)
Example #13
0
 def tearDown(self):
     eav.unregister(Patient)
Example #14
0
 def tearDown(self):
     unregister(Encounter)
     unregister(Patient)
Example #15
0
 def test_unregistering_via_metaclass(self):
     self.assertTrue(ExampleMetaclassModel.objects.__class__.__name__ ==
                     'EntityManager')
     eav.unregister(ExampleMetaclassModel)
     self.assertFalse(ExampleMetaclassModel.objects.__class__.__name__ ==
                      'EntityManager')