def testSwitchRemoteBranch(self): scm = Git(Process(quiet=True)) self.branch(self.packagedir, '2.x') self.clone() self.assertEqual(scm.get_branch_from_sandbox(self.clonedir), 'master') self.assertEqual(scm.switch_branch(self.clonedir, '2.x'), 0) self.assertEqual(scm.get_branch_from_sandbox(self.clonedir), '2.x')
def testSwitchSameBranch(self): scm = Git() self.assertEqual(scm.get_branch_from_sandbox(self.packagedir), 'parking') self.assertEqual(scm.switch_branch(self.packagedir, 'parking'), 0) self.assertEqual(scm.get_branch_from_sandbox(self.packagedir), 'parking')
def testCreateTag(self): scm = Git() self.assertEqual(scm.tag_exists(self.packagedir, '2.6'), False) self.assertEqual( scm.create_tag(self.packagedir, '2.6', 'testpackage', '2.6', False), 0) self.assertEqual(scm.tag_exists(self.packagedir, '2.6'), True)
def testSwitchRemoteBranch(self): scm = Git(Process(quiet=True)) self.branch(self.packagedir, "2.x") self.clone() self.assertEqual(scm.get_branch_from_sandbox(self.clonedir), "master") self.assertEqual(scm.switch_branch(self.clonedir, "2.x"), 0) self.assertEqual(scm.get_branch_from_sandbox(self.clonedir), "2.x")
def testCommitAndPushDirtyRemoteSandbox(self): scm = Git(Process(quiet=True)) self.clone() self.modify(self.clonedir) self.assertEqual(scm.commit_sandbox(self.clonedir, "testpackage", "2.6", True), 0) self.verify(self.clonedir) self.update(self.packagedir) self.verify(self.packagedir)
def testCreateExistingTag(self): scm = Git(Process(quiet=True)) self.assertEqual( scm.create_tag(self.packagedir, '2.6', 'testpackage', '2.6', False), 0) self.assertEqual(scm.tag_exists(self.packagedir, '2.6'), True) self.assertRaises(SystemExit, scm.create_tag, self.packagedir, '2.6', 'testpackage', '2.6', False)
def testCreateAndPushRemoteTag(self): scm = Git(Process(quiet=True)) self.clone() self.assertEqual( scm.create_tag(self.clonedir, '2.6', 'testpackage', '2.6', True), 0) self.assertEqual(scm.tag_exists(self.clonedir, '2.6'), True) self.assertEqual(scm.tag_exists(self.packagedir, '2.6'), True)
def testCheckinAndPushDirtyRemoteSandbox(self): scm = Git(Process(quiet=True)) self.clone() self.modify(self.clonedir) self.assertEqual(scm.checkin_sandbox(self.clonedir, 'testpackage', '2.6', True), 0) self.verify(self.clonedir) self.update(self.packagedir) self.verify(self.packagedir)
def testCommitAndPushDirtyRemoteSandbox(self): scm = Git(Process(quiet=True)) self.clone() self.modify(self.clonedir) self.assertEqual( scm.commit_sandbox(self.clonedir, 'testpackage', '2.6', True), 0) self.verify(self.clonedir) self.update(self.packagedir) self.verify(self.packagedir)
def testCheckRaises(self): scm = Git() self.assertRaises(SystemExit, scm.check_valid_sandbox, 'foo') self.assertRaises(SystemExit, scm.check_valid_sandbox, join(self.packagedir, 'setup.py')) self.destroy() self.assertRaises(SystemExit, scm.check_valid_sandbox, self.packagedir)
def testWhitebox(self): def func(cmd): if cmd == 'git branch': return 0, ['* master'] return 1, [] scm = Git(MockProcess(func=func)) self.assertRaises(SystemExit, scm.get_tracked_branch_from_sandbox, self.packagedir)
def testWhitebox(self): self.called = 0 def func(cmd): if cmd == 'git branch': return 0, ['* master'] if cmd == 'git config -l': self.called += 1 if self.called == 1: return 0, ['branch.master.remote=origin'] return 1, [] scm = Git(MockProcess(func=func)) self.assertRaises(SystemExit, scm.get_url_from_sandbox, self.packagedir)
def testBadProcess(self): scm = Git(MockProcess(rc=1)) self.assertRaises(SystemExit, scm.check_tag_exists, self.packagedir, '2.6')
def testTagExists(self): scm = Git() self.tag(self.packagedir, '2.6') self.assertEqual(scm.tag_exists(self.packagedir, '2.6'), True)
def testBadProcess(self): scm = Git(MockProcess(rc=1)) self.assertRaises(SystemExit, scm.switch_branch, self.packagedir, 'master')
def testGetSubfolderRoot(self): scm = Git() self.assertEqual( scm.get_root_from_sandbox(join(self.packagedir, 'testpackage')), self.packagedir)
def testNotADir(self): scm = Git() self.assertEqual( scm.is_valid_sandbox(join(self.packagedir, 'setup.py')), False)
def testBadProcess(self): scm = Git(MockProcess(rc=1)) self.assertRaises(SystemExit, scm.create_tag, self.packagedir, '2.6', 'testpackage', '2.6', False)
def testFileUrl(self): scm = Git() self.assertEqual(scm.is_valid_url("file://"), True)
def testCreateExistingTag(self): scm = Git(Process(quiet=True)) self.assertEqual(scm.create_tag(self.packagedir, "2.6", "testpackage", "2.6", False), 0) self.assertEqual(scm.tag_exists(self.packagedir, "2.6"), True) self.assertRaises(SystemExit, scm.create_tag, self.packagedir, "2.6", "testpackage", "2.6", False)
def testCreateTag(self): scm = Git() self.assertEqual(scm.tag_exists(self.packagedir, "2.6"), False) self.assertEqual(scm.create_tag(self.packagedir, "2.6", "testpackage", "2.6", False), 0) self.assertEqual(scm.tag_exists(self.packagedir, "2.6"), True)
def testTagExists(self): scm = Git() self.tag(self.packagedir, "2.6") self.assertEqual(scm.tag_exists(self.packagedir, "2.6"), True)
def testGitSshUrl(self): scm = Git() self.assertEqual(scm.is_valid_url("[email protected]:Jarn/jarn.mkrelease"), True)
def testTagDoesNotExist(self): scm = Git() self.assertEqual(scm.tag_exists(self.packagedir, "2.6"), False)
def testEmptyBranchId(self): scm = Git() self.assertEqual(scm.make_branchid(self.packagedir, ""), "master")
def testSandbox(self): scm = Git() self.assertEqual(scm.is_valid_sandbox(self.packagedir), True)
def testCommitAndPushDirtyLocalSandbox(self): scm = Git(Process(quiet=True)) self.modify(self.packagedir) self.assertEqual(scm.commit_sandbox(self.packagedir, "testpackage", "2.6", True), 0)
def testCreateAndPushLocalTag(self): scm = Git() self.assertEqual(scm.create_tag(self.packagedir, "2.6", "testpackage", "2.6", True), 0) self.assertEqual(scm.tag_exists(self.packagedir, "2.6"), True)
def testBadPush(self): scm = Git(Process(quiet=True)) self.clone() self.destroy() self.assertRaises(SystemExit, scm.create_tag, self.packagedir, '2.6', 'testpackage', '2.6', True)
def testCreateAndPushRemoteTag(self): scm = Git(Process(quiet=True)) self.clone() self.assertEqual(scm.create_tag(self.clonedir, "2.6", "testpackage", "2.6", True), 0) self.assertEqual(scm.tag_exists(self.clonedir, "2.6"), True) self.assertEqual(scm.tag_exists(self.packagedir, "2.6"), True)
def testVersionInfo(self): scm = Git() self.failIfEqual(scm.version_info, ())
def testCommitCleanSandbox(self): scm = Git(Process(quiet=True)) self.assertEqual(scm.commit_sandbox(self.packagedir, "testpackage", "2.6", False), 0)
def testGetVersion(self): scm = Git() self.assertNotEqual(scm.get_version(), "")
def testSwitchSameBranch(self): scm = Git() self.assertEqual(scm.get_branch_from_sandbox(self.packagedir), "master") self.assertEqual(scm.switch_branch(self.packagedir, "master"), 0) self.assertEqual(scm.get_branch_from_sandbox(self.packagedir), "master")
def testSubdirOfSandbox(self): scm = Git() self.assertEqual(scm.is_valid_sandbox(join(self.packagedir, "testpackage")), True)
def testTagDoesNotExist(self): scm = Git() self.assertEqual(scm.tag_exists(self.packagedir, '2.6'), False)
def testNotExists(self): scm = Git() self.assertEqual(scm.is_valid_sandbox("foo"), False)
def testBadSandbox(self): scm = Git(Process(quiet=True)) self.destroy() self.assertRaises(SystemExit, scm.check_tag_exists, self.packagedir, '2.6')
def testNotADir(self): scm = Git() self.assertEqual(scm.is_valid_sandbox(join(self.packagedir, "setup.py")), False)
def testCheckRaises(self): scm = Git() self.tag(self.packagedir, '2.6') self.assertRaises(SystemExit, scm.check_tag_exists, self.packagedir, '2.6')
def testNotACheckout(self): scm = Git() self.destroy() self.assertEqual(scm.is_valid_sandbox(self.packagedir), False)
def testCommitAndPushCleanRemoteSandbox(self): scm = Git(Process(quiet=True)) self.clone() self.assertEqual(scm.commit_sandbox(self.clonedir, "testpackage", "2.6", True), 0)
def testGetRoot(self): scm = Git() self.assertEqual(scm.get_root_from_sandbox(self.packagedir), self.packagedir)
def testCreateAndPushLocalTag(self): scm = Git() self.assertEqual( scm.create_tag(self.packagedir, '2.6', 'testpackage', '2.6', True), 0) self.assertEqual(scm.tag_exists(self.packagedir, '2.6'), True)
def testGetCloneRoot(self): scm = Git() self.clone() self.assertEqual(scm.get_root_from_sandbox(self.clonedir), self.clonedir)
def testSubdirOfSandbox(self): scm = Git() self.assertEqual( scm.is_valid_sandbox(join(self.packagedir, 'testpackage')), True)
def testGetCloneSubfolderRoot(self): scm = Git() self.clone() self.assertEqual(scm.get_root_from_sandbox(join(self.clonedir, "testpackage")), self.clonedir)
def testBadSandbox(self): scm = Git(Process(quiet=True)) self.destroy() self.assertRaises(SystemExit, scm.create_tag, self.packagedir, '2.6', 'testpackage', '2.6', False)
def testDeletedButTrackedFile(self): scm = Git() self.delete(self.packagedir) # Note: The sandbox is reported as unclean self.assertEqual(scm.is_unclean_sandbox(self.packagedir), True)
def testGetVersion(self): scm = Git() self.failIfEqual(scm.get_version(), '')
def testMakeBranchId(self): scm = Git() self.assertEqual(scm.make_branchid(self.packagedir, "2.x"), "2.x")
def testNotExists(self): scm = Git() self.assertEqual(scm.is_valid_sandbox('foo'), False)
def testCloneUrl(self): scm = Git(Process(quiet=True)) self.assertEqual(scm.clone_url(self.packagedir, "testclone"), 0) self.assertEqual(isdir("testclone"), True)
def testBadProtocol(self): scm = Git() self.assertEqual(scm.is_valid_url("svn://"), False)
def testBadSandbox(self): scm = Git(Process(quiet=True)) self.destroy() self.assertRaises(SystemExit, scm.switch_branch, self.packagedir, 'master')
def testEmptyString(self): scm = Git() self.assertEqual(scm.is_valid_url(""), False)