예제 #1
0
파일: base.py 프로젝트: ejesse/ogorm
 def _instantiate_fields(self):
     # read through the fields in the class variable
     # and assign new instances to their attribute names
     for k in self._field_defs.keys():
         # we'll need a way to bypass our get/set fancy/schmancy
         # so put copies of the fields in _fields
         self._fields[k] = self._field_defs[k].__class__.__call__()
         super(Model, self).__setattr__(k, self._fields[k])
         # set inherited fields
         for class_base in self.__class__.__bases__:
             if class_base is not Model:
                 if k in class_base._field_defs.keys():
                     self._fields[k].inherited = True
         # setup the field mapping
         self._py_to_orient_field_mapping[k] = to_java_case(k)
         # in both directions
         # note: it works fine if they are the same!
         self._py_to_orient_field_mapping[to_java_case(k)] = k 
예제 #2
0
    def test_create_class_with_attribues(self):

        create_class(ClassWithAttributes, client=self.client)

        # we will get the properties and make sure they are
        # correct types and names
        r = self.client.command("select expand(properties) from ( select expand(classes) from metadata:schema) where name = '%s'" % get_orient_valid_class_name(ClassWithAttributes))
        cwa = ClassWithAttributes()
        # loop through the fields and make sure they are defined
        # the way we expect in OrientDB
        for f in cwa._fields.keys():
            self.assertTrue(any(x.type == cwa._fields[f].orientdb_type_id for x in r))
            self.assertTrue(any(x.name == to_java_case(f) for x in r))
예제 #3
0
    def test_create_inheriting_class(self):
        
        create_class(ClassWithAttributes, client=self.client)
        create_class(InheritingClass, client=self.client)

        # we will get the properties and make sure they are
        # correct types and names
        r = self.client.command("select expand(properties) from ( select expand(classes) from metadata:schema) where name = '%s'" % get_orient_valid_class_name(InheritingClass))
        ic = InheritingClass()
        # loop through the fields and make sure they are defined
        # the way we expect in OrientDB
        # orient will NOT show inherited fields
        for f in ic._fields.keys():
            if not ic._fields[f].inherited:
                self.assertTrue(any(x.type == ic._fields[f].orientdb_type_id for x in r))
                self.assertTrue(any(x.name == to_java_case(f) for x in r))
예제 #4
0
파일: field_tests.py 프로젝트: ejesse/ogorm
 def test_to_java_case(self):
     
     self.assertEqual(to_java_case("COnvert_this_to_java_case"), "convertThisToJavaCase")