Ejemplo n.º 1
0
 def test_attribute_checkers(self):
     self.assert_true(
         is_resource_class_terminal_attribute(IMyEntity, 'text'))
     self.assert_true(
         is_resource_class_member_attribute(IMyEntity, 'parent'))
     self.assert_true(
         is_resource_class_collection_attribute(IMyEntity, 'children'))
     self.assert_true(
         is_resource_class_resource_attribute(IMyEntity, 'parent'))
     self.assert_true(
         is_resource_class_resource_attribute(IMyEntity, 'children'))
     attr_names = list(get_resource_class_attribute_names(MyEntityMember))
     self.assert_equal(attr_names, ATTRIBUTE_NAMES)
     it = get_resource_class_attribute_iterator(MyEntityMember)
     self.assert_equal([attr.resource_attr for attr in it], ATTRIBUTE_NAMES)
Ejemplo n.º 2
0
 def test_attribute_checkers(self):
     self.assert_true(is_resource_class_terminal_attribute(IMyEntity,
                                                           'text'))
     self.assert_true(is_resource_class_member_attribute(IMyEntity,
                                                         'parent'))
     self.assert_true(is_resource_class_collection_attribute(IMyEntity,
                                                             'children'))
     self.assert_true(is_resource_class_resource_attribute(IMyEntity,
                                                           'parent'))
     self.assert_true(is_resource_class_resource_attribute(IMyEntity,
                                                           'children'))
     attr_names = list(get_resource_class_attribute_names(MyEntityMember))
     self.assert_equal(attr_names, ATTRIBUTE_NAMES)
     it = get_resource_class_attribute_iterator(MyEntityMember)
     self.assert_equal([attr.resource_attr for attr in it],
                       ATTRIBUTE_NAMES)
Ejemplo n.º 3
0
 def visit(mb_cls, grph, path, incl_backrefs):
     for attr_name in get_resource_class_attribute_names(mb_cls):
         if is_resource_class_terminal_attribute(mb_cls, attr_name):
             continue
         child_descr = getattr(mb_cls, attr_name)
         child_mb_cls = get_member_class(child_descr.attr_type)
         # We do not follow cyclic references back to a resource class
         # that is last in the path.
         if len(path) > 0 and child_mb_cls is path[-1] \
            and not incl_backrefs:
             continue
         if not grph.has_node(child_mb_cls):
             grph.add_node(child_mb_cls)
             path.append(mb_cls)
             visit(child_mb_cls, grph, path, incl_backrefs)
             path.pop()
         if not grph.has_edge((mb_cls, child_mb_cls)):
             grph.add_edge((mb_cls, child_mb_cls))
Ejemplo n.º 4
0
 def visit(mb_cls, grph, path, incl_backrefs):
     for attr_name in get_resource_class_attribute_names(mb_cls):
         if is_resource_class_terminal_attribute(mb_cls, attr_name):
             continue
         child_descr = getattr(mb_cls, attr_name)
         child_mb_cls = get_member_class(child_descr.attr_type)
         # We do not follow cyclic references back to a resource class
         # that is last in the path.
         if len(path) > 0 and child_mb_cls is path[-1] \
            and not incl_backrefs:
             continue
         if not grph.has_node(child_mb_cls):
             grph.add_node(child_mb_cls)
             path.append(mb_cls)
             visit(child_mb_cls, grph, path, incl_backrefs)
             path.pop()
         if not grph.has_edge((mb_cls, child_mb_cls)):
             grph.add_edge((mb_cls, child_mb_cls))
Ejemplo n.º 5
0
 def test_organization_representer(self, organization_cenix):
     coll = create_staging_collection(IOrganization)
     org_mb = coll.create_member(organization_cenix)
     attrs = get_resource_class_attribute_names(OrganizationMember)
     self.__test_rpr_for_member(org_mb, (XmlMime,), attrs)
Ejemplo n.º 6
0
 def test_names(self):
     self.assert_equal(
             list(get_resource_class_attribute_names(MyEntityMember)),
             ATTRIBUTE_NAMES)
Ejemplo n.º 7
0
 def test_names(self):
     self.assert_equal(
         list(get_resource_class_attribute_names(MyEntityMember)),
         ATTRIBUTE_NAMES)
Ejemplo n.º 8
0
 def test_organization_representer(self, organization_cenix):
     coll = create_staging_collection(IOrganization)
     org_mb = coll.create_member(organization_cenix)
     attrs = get_resource_class_attribute_names(OrganizationMember)
     self.__test_rpr_for_member(org_mb, (XmlMime, ), attrs)