def test_bad_repo(self): """ Test git """ log.debug("Test non-git directory") with self.assertRaises(InvalidGitRepo): fail_git = IDKGit("/tmp") fail_git.branches()
def setUpClass(cls): system("rm -rf %s" % ROOTDIR) if not exists(ROOTDIR): makedirs(ROOTDIR) idk_git = IDKGit(ROOTDIR) log.info("clone repo %s", REPO) idk_git.clone(REPO)
def setUp(self): """ Setup the test case """ log.debug("Test good git directory") self.idk_git = IDKGit(ROOTDIR) self.assertTrue(self.idk_git) self.assertTrue(self.idk_git.repo) self.assertTrue(self.idk_git.repo.isValid())
class TestGit(MiUnitTest): """ Test the git for the IDK """ @classmethod def setUpClass(cls): system("rm -rf %s" % ROOTDIR) if not exists(ROOTDIR): makedirs(ROOTDIR) idk_git = IDKGit(ROOTDIR) log.info("clone repo %s", REPO) idk_git.clone(REPO) @classmethod def tearDownClass(cls): system("rm -rf %s" % ROOTDIR) def setUp(self): """ Setup the test case """ log.debug("Test good git directory") self.idk_git = IDKGit(ROOTDIR) self.assertTrue(self.idk_git) self.assertTrue(self.idk_git.repo) self.assertTrue(self.idk_git.repo.isValid()) def test_bad_repo(self): """ Test git """ log.debug("Test non-git directory") with self.assertRaises(InvalidGitRepo): fail_git = IDKGit("/tmp") fail_git.branches() def test_branch(self): branches = self.idk_git.branches() log.debug("Branches found: %s", branches) # Add a branch branch_name = "test_idk_branch" self.idk_git.create_branch(branch_name) branches = self.idk_git.branches() log.debug("Branches found: %s", branches) self.assertTrue(branch_name in branches) # add the same branch again with self.assertRaises(GitCommandException): self.idk_git.create_branch(branch_name) # switch to the new branch self.idk_git.switch_branch(branch_name) self.assertEqual(self.idk_git.get_current_branch(), branch_name) # switch to the master self.idk_git.switch_branch("master") self.assertEqual(self.idk_git.get_current_branch(), "master") # switch to an unknown branch with self.assertRaises(GitCommandException): self.idk_git.switch_branch("fffsssaaa")
class TestGit(MiUnitTest): """ Test the git for the IDK """ @classmethod def setUpClass(cls): system("rm -rf %s" % ROOTDIR) if not exists(ROOTDIR): makedirs(ROOTDIR) idk_git = IDKGit(ROOTDIR) log.info("clone repo %s", REPO) idk_git.clone(REPO) @classmethod def tearDownClass(cls): system("rm -rf %s" % ROOTDIR) def setUp(self): """ Setup the test case """ log.debug("Test good git directory") self.idk_git = IDKGit(ROOTDIR) self.assertTrue(self.idk_git) self.assertTrue(self.idk_git.repo) self.assertTrue(self.idk_git.repo.isValid()) def test_bad_repo(self): """ Test git """ log.debug("Test non-git directory") with self.assertRaises(InvalidGitRepo): fail_git = IDKGit("/tmp") fail_git.branches() def test_branch(self): branches = self.idk_git.branches() log.debug("Branches found: %s", branches) # Add a branch branch_name = 'test_idk_branch' self.idk_git.create_branch(branch_name) branches = self.idk_git.branches() log.debug("Branches found: %s", branches) self.assertTrue(branch_name in branches) # add the same branch again with self.assertRaises(GitCommandException): self.idk_git.create_branch(branch_name) # switch to the new branch self.idk_git.switch_branch(branch_name) self.assertEqual(self.idk_git.get_current_branch(), branch_name) # switch to the master self.idk_git.switch_branch('master') self.assertEqual(self.idk_git.get_current_branch(), 'master') # switch to an unknown branch with self.assertRaises(GitCommandException): self.idk_git.switch_branch('fffsssaaa')