def setUp(self): """Create test organisation and user.""" org = SpokeOrg() org.create(self.org_name) user = SpokeUser(self.org_name) user.create(self.email_addr, self.first, self.last) svn = SpokeSVN(self.org_name, self.user_id) svn.create(self.svn_repo_name)
def test_disable_svn_access(self): """Disable svn access; verify svn access disabled.""" org = 'o=%s' % (self.org_name) people = '%s=%s' % (self.container_attr, self.user_container) uid = '%s=%s' % (self.user_key, self.user_id) dn = '%s,%s,%s,%s' % (uid, people, org, self.base_dn) dn_info = {self.svn_enable_attr: ['FALSE']} expected_result = [(dn, dn_info)] svn = SpokeSVN(self.org_name, self.user_id) result = svn.modify(enable=False)['data'] self.assertEqual(result, expected_result)
def test_get_svn_repo(self): """Retrieve an svn repo; return svn account details.""" org = "o=%s" % (self.org_name) people = "%s=%s" % (self.container_attr, self.user_container) uid = "%s=%s" % (self.user_key, self.user_id) dn = "%s,%s,%s,%s" % (uid, people, org, self.base_dn) dn_info = {self.svn_enable_attr: ["TRUE"], self.svn_repo_attr: [self.svn_repo_name]} expected_result = [(dn, dn_info)] svn = SpokeSVN(self.org_name, self.user_id) result = svn.get(self.svn_repo_name)["data"] self.assertEqual(result, expected_result)
def test_disable_svn_access(self): """Disable svn access; verify svn access disabled.""" org = "o=%s" % (self.org_name) people = "%s=%s" % (self.container_attr, self.user_container) uid = "%s=%s" % (self.user_key, self.user_id) dn = "%s,%s,%s,%s" % (uid, people, org, self.base_dn) dn_info = {self.svn_enable_attr: ["FALSE"]} expected_result = [(dn, dn_info)] svn = SpokeSVN(self.org_name, self.user_id) result = svn.modify(enable=False)["data"] self.assertEqual(result, expected_result)
def test_get_svn_repo(self): """Retrieve an svn repo; return svn account details.""" org = 'o=%s' % (self.org_name) people = '%s=%s' % (self.container_attr, self.user_container) uid = '%s=%s' % (self.user_key, self.user_id) dn = '%s,%s,%s,%s' % (uid, people, org, self.base_dn) dn_info = { self.svn_enable_attr: ['TRUE'], self.svn_repo_attr: [self.svn_repo_name] } expected_result = [(dn, dn_info)] svn = SpokeSVN(self.org_name, self.user_id) result = svn.get(self.svn_repo_name)['data'] self.assertEqual(result, expected_result)
def test_add_svn_repo(self): """Add a svn repo to a user account; return svn account details.""" repo = 'testcreaterepo' org = 'o=%s' % (self.org_name) people = '%s=%s' % (self.container_attr, self.user_container) uid = '%s=%s' % (self.user_key, self.user_id) dn = '%s,%s,%s,%s' % (uid, people, org, self.base_dn) dn_info = {self.svn_repo_attr: [self.svn_repo_name, repo]} expected_result = [(dn, dn_info)] svn = SpokeSVN(self.org_name, self.user_id) result = svn.create(repo)['data'][0] attrs = result[1] svn_attrs = {} svn_attrs[self.svn_repo_attr] = attrs[self.svn_repo_attr] svn_result = [(result[0], svn_attrs)] self.assertEqual(svn_result, expected_result)
def test_add_svn_repo(self): """Add a svn repo to a user account; return svn account details.""" repo = "testcreaterepo" org = "o=%s" % (self.org_name) people = "%s=%s" % (self.container_attr, self.user_container) uid = "%s=%s" % (self.user_key, self.user_id) dn = "%s,%s,%s,%s" % (uid, people, org, self.base_dn) dn_info = {self.svn_repo_attr: [self.svn_repo_name, repo]} expected_result = [(dn, dn_info)] svn = SpokeSVN(self.org_name, self.user_id) result = svn.create(repo)["data"][0] attrs = result[1] svn_attrs = {} svn_attrs[self.svn_repo_attr] = attrs[self.svn_repo_attr] svn_result = [(result[0], svn_attrs)] self.assertEqual(svn_result, expected_result)
def test_add_svn_repo_twice(self): """Add an existing svn repo to a user account; raise AlreadyExists.""" svn = SpokeSVN(self.org_name, self.user_id) self.assertRaises(error.AlreadyExists, svn.create, self.svn_repo_name)
def test_enable_missing_svn_access(self): """Enable missing svn access; raise NotFound.""" svn = SpokeSVN(self.org_name, self.user_id) svn.delete(self.svn_repo_name) self.assertRaises(error.NotFound, svn.modify, enable=True)
def test_delete_missing_svn_repo(self): """Delete a missing svn repo; return True.""" repo = 'testdeletemissingrepo' svn = SpokeSVN(self.org_name, self.user_id) self.assertRaises(error.NotFound, svn.delete, repo)
def test_delete_svn_repo(self): """Delete an svn repo; return True.""" svn = SpokeSVN(self.org_name, self.user_id) self.assertTrue(svn.delete(self.svn_repo_name))
def test_get_missing_svn_repo(self): """Retrieve a missing svn repo; return empty list.""" repo = 'testgetmissingrepo' svn = SpokeSVN(self.org_name, self.user_id) self.assertFalse(svn.get(repo)['data'])
def test_get_missing_svn_repo(self): """Retrieve a missing svn repo; return empty list.""" repo = "testgetmissingrepo" svn = SpokeSVN(self.org_name, self.user_id) self.assertFalse(svn.get(repo)["data"])