def test_multiple_repos(self): p = self.project self.assertFalse(p.has_repository) # create Git Repository self.git = GitRepository( project = p, name = "My Git Repos", url = "git://some.git.repos/me/project.git", ) self.git.save() self.assertEqual(1, p.repository_set.count()) self.assertEqual(unicode(self.git), "My Git Repos") self.assertTrue(p.has_repository) # create SVN Repository self.svn = SVNRepository( project = p, name = "My SVN Repository", url = "http://my.svn.host/svn/test", ) self.svn.save() self.assertEqual(2, p.repository_set.count()) # check that models can downcast properly expect = ["Git", "SVN"] for i,r in enumerate(p.repository_set.all()): # calling method on parent class should raise exception self.assertRaises(NotImplementedError, r.get_config_type) self.assertRaises(NotImplementedError, r.get_config_class) self.assertRaises(NotImplementedError, r.get_config_args) self.assertRaises(NotImplementedError, r.get_change_id) # should work with r.cast() self.assertEqual(expect[i], r.cast().get_config_type())
def test_name_uniqueness(self): """ Ensure that a project cannot have multiple repos with the same name """ p = self.project r1 = SVNRepository( # first repost project = p, name = "My SVN Repository", url = "http://my.svn.host/svn/test", ) r1.save() r = SVNRepository( # another repos with the same name project = p, name = "My SVN Repository", url = "http://another.svn.host/svn/test", ) self.assertRaises(IntegrityError, r.save) self.assertEqual(r.id, None) # ... but the the same name can be used in a different project np = Project( name = "Another Test Project", owner = self.user, ) np.save() r = SVNRepository( project = np, name = "My SVN Repository", url = "http://my.svn.host/svn/test", ) r.save() self.assertNotEqual(r.id, None)
def test_create_extra(self): p = self.project # extra information svnurl = "http://lsc.svn.repos/svn/next" r = SVNRepository( project = p, name = "Another SVN Repos", url = svnurl, poll_interval = 123, username = '******', password = '******', ) r.save() self.assertEqual(_("SVN"), r.get_config_type()) # check args args = r.get_config_args() self.assertEqual(args.get("svnurl", None), svnurl) self.assertEqual(args.get("pollinterval", None), 123 * 60) self.assertEqual(args.get("svnuser", None), "lsc") self.assertEqual(args.get("svnpasswd", None), "sekrit") # check that the config object can be instantiated self.assert_valid_buildbot_config(r.get_config_class(), args) # Check that the resulting config string is sensible self.assert_config_string_executable(r)
def test_with_repos_filter(self): """ Change scheduler which affects only a specific repository """ sched = ChangeScheduler(project = self.project, name = "change") sched.save() self.assertNotEqual(sched.id, None) repo = GitRepository(project = self.project, name = "gitrepo", url = "http://some.git.repo/project.git", ) repo.save() self.assertNotEqual(repo.id, None) sched.limit_to_repository.add(repo) repo2 = SVNRepository(project = self.project, name = "svnrepo", url = "http://some.host/svn/project", ) repo2.save() self.assertNotEqual(repo2.id, None) sched.limit_to_repository.add(repo2) # check filter class self.assertNotEqual(sched.cast().get_filter_class(), None) self.assertNotEqual(sched.cast().get_filter_args(), None) args = sched.cast().get_filter_args() repolist = args.get("repository", []) self.assertEqual(len(repolist), 2) self.assertEqual(repolist[0], "http://some.git.repo/project.git") self.assertEqual(repolist[1], "http://some.host/svn/project") # try instantiating buildbot config object self.assert_valid_buildbot_config(sched.cast().get_filter_class(), args) # Check that the resulting config string is sensible self.assert_config_string_executable(sched.cast())
class AbstractTestCheckout(BbotuiModelTestCase): """ Abstract class for test cases in this file. Instantiates self.project, self.builder, self.svn, self.git. """ def setUp(self): # call method in parent class (instantiates self.project) super(AbstractTestCheckout, self).setUp() # create builder self.builder = Builder(project=self.project, name="test builder") self.builder.save() self.assertTrue(self.builder.id != None) # create svn repos self.svn = SVNRepository(project=self.project, name="test svn repo", url="http://some.url/svn/proj/trunk") self.svn.save() self.assertTrue(self.svn.id != None) # create git repos self.git = GitRepository(project=self.project, name="test git repo", url="http://some.url/abc.git") self.git.save() self.assertTrue(self.git.id != None)
def test_create_init(self): p = self.project # minimal information svnurl = "http://lsc.svn.repos/svn/myproj" r = SVNRepository( project = p, name = "My SVN Repos", url = svnurl, ) r.save() self.assertEqual(_("SVN"), r.get_config_type()) # check default arguments args = r.get_config_args() self.assertEqual(args.get("svnurl", None), svnurl) self.assertEqual(args.get("pollinterval", None), settings.DEFAULT_POLL_INTERVAL * 60) # check that the config object can be instantiated self.assert_valid_buildbot_config(r.get_config_class(), args) # Check that the resulting config string is sensible self.assert_config_string_executable(r)
class TestRepositoryAbstraction(BbotuiModelTestCase): """ Test repository type abstraction. """ def test_multiple_repos(self): p = self.project self.assertFalse(p.has_repository) # create Git Repository self.git = GitRepository( project = p, name = "My Git Repos", url = "git://some.git.repos/me/project.git", ) self.git.save() self.assertEqual(1, p.repository_set.count()) self.assertEqual(unicode(self.git), "My Git Repos") self.assertTrue(p.has_repository) # create SVN Repository self.svn = SVNRepository( project = p, name = "My SVN Repository", url = "http://my.svn.host/svn/test", ) self.svn.save() self.assertEqual(2, p.repository_set.count()) # check that models can downcast properly expect = ["Git", "SVN"] for i,r in enumerate(p.repository_set.all()): # calling method on parent class should raise exception self.assertRaises(NotImplementedError, r.get_config_type) self.assertRaises(NotImplementedError, r.get_config_class) self.assertRaises(NotImplementedError, r.get_config_args) self.assertRaises(NotImplementedError, r.get_change_id) # should work with r.cast() self.assertEqual(expect[i], r.cast().get_config_type()) def test_name_uniqueness(self): """ Ensure that a project cannot have multiple repos with the same name """ p = self.project r1 = SVNRepository( # first repost project = p, name = "My SVN Repository", url = "http://my.svn.host/svn/test", ) r1.save() r = SVNRepository( # another repos with the same name project = p, name = "My SVN Repository", url = "http://another.svn.host/svn/test", ) self.assertRaises(IntegrityError, r.save) self.assertEqual(r.id, None) # ... but the the same name can be used in a different project np = Project( name = "Another Test Project", owner = self.user, ) np.save() r = SVNRepository( project = np, name = "My SVN Repository", url = "http://my.svn.host/svn/test", ) r.save() self.assertNotEqual(r.id, None)