def test_spoke_org_create(self): """Create an org with default children; return True.""" org_name = 'testSpokeOrgCreate' base_dn = self.base_dn org = SpokeOrg() dn = 'o=%s,%s' % (org_name, base_dn) dn_info = { 'objectClass': ['top', self.org_class], self.org_attr: [org_name] } expected_result = [(dn, dn_info)] self.assertTrue(org.create(org_name)) result = org.get(org_name)['data'] self.assertEqual(result, expected_result) for child_name in self.org_children: child = SpokeOrgChild(org_name) rdn = self.container_attr + '=' + child_name organisation = self.org_attr + '=' + org_name dn = rdn + ',' + organisation + ',' + self.base_dn dn_info = { 'objectClass': ['top', self.container_class], self.container_attr: [child_name] } expected_result = [(dn, dn_info)] result = child.get(child_name)['data'] self.assertEqual(result, expected_result) org.delete(org_name)
def test_spoke_org_get_child(self): """Retrieve an org's child; return a child object.""" child_name = 'people' rdn = self.container_attr + '=' + child_name organisation = self.org_attr + '=' + self.org_name dn = rdn + ',' + organisation + ',' + self.base_dn dn_info = {'objectClass': ['top', self.container_class], self.container_attr: [child_name]} expected_result = [(dn, dn_info)] child = SpokeOrgChild(self.org_name) result = child.get(child_name)['data'] self.assertEqual(result, expected_result)
def test_spoke_org_get_children(self): """Retrieve all an org's immediate child containers; return a list.""" expected_result = [] for child_name in self.org_children: dn = '%s=%s,%s=%s,%s' % (self.container_attr, child_name, self.org_attr, self.org_name, self.base_dn) dn_info = {'objectClass': ['top', self.container_class], self.container_attr: [child_name]} expected_result.append((dn, dn_info)) child = SpokeOrgChild(self.org_name) result = child.get()['data'] self.assertEqual(result, expected_result)
def test_create_child_container(self): """Create a child container; return True.""" child_name = 'test' child = self.container_attr + '=' + child_name organisation = self.org_attr + '=' + self.org_name dn = child + ',' + organisation + ',' + self.base_dn dn_info = {'objectClass': ['top', self.container_class], self.container_attr: [child_name]} expected_result = [(dn, dn_info)] child = SpokeOrgChild(self.org_name) self.assertTrue(child.create(child_name)) result = child.get(child_name)['data'] self.assertEqual(result, expected_result) child.delete(child_name)
def test_spoke_org_create(self): """Create an org with default children; return True.""" org_name = 'testSpokeOrgCreate' base_dn = self.base_dn org = SpokeOrg() dn = 'o=%s,%s' % (org_name, base_dn) dn_info = {'objectClass': ['top', self.org_class], self.org_attr: [org_name]} expected_result = [(dn, dn_info)] self.assertTrue(org.create(org_name)) result = org.get(org_name)['data'] self.assertEqual(result, expected_result) for child_name in self.org_children: child = SpokeOrgChild(org_name) rdn = self.container_attr + '=' + child_name organisation = self.org_attr + '=' + org_name dn = rdn + ',' + organisation + ',' + self.base_dn dn_info = {'objectClass': ['top', self.container_class], self.container_attr: [child_name]} expected_result = [(dn, dn_info)] result = child.get(child_name)['data'] self.assertEqual(result, expected_result) org.delete(org_name)
def test_spoke_org_get_child_missing(self): """Retrieve an org's missing child; return an empty list.""" child_name = 'child_missing' child = SpokeOrgChild(self.org_name) self.assertFalse(child.get(child_name)['data'])