Addon Manager: Refactor installation code
Improve testability of installation code by refactoring it to completely separate the GUI and non-GUI code, and to provide more robust support for non-GUI access to some type of Addon Manager activity.
This commit is contained in:
@@ -69,7 +69,7 @@ class TestGit(unittest.TestCase):
|
||||
def tearDown(self):
|
||||
"""Clean up after the test"""
|
||||
os.chdir(self.cwd)
|
||||
#self._rmdir(self.test_dir)
|
||||
# self._rmdir(self.test_dir)
|
||||
os.rename(self.test_dir, self.test_dir + ".old." + str(time.time()))
|
||||
|
||||
def test_clone(self):
|
||||
@@ -77,7 +77,9 @@ class TestGit(unittest.TestCase):
|
||||
checkout_dir = self._clone_test_repo()
|
||||
self.assertTrue(os.path.exists(checkout_dir))
|
||||
self.assertTrue(os.path.exists(os.path.join(checkout_dir, ".git")))
|
||||
self.assertEqual(os.getcwd(),self.cwd, "We should be left in the same CWD we started")
|
||||
self.assertEqual(
|
||||
os.getcwd(), self.cwd, "We should be left in the same CWD we started"
|
||||
)
|
||||
|
||||
def test_checkout(self):
|
||||
"""Test git checkout"""
|
||||
@@ -88,7 +90,9 @@ class TestGit(unittest.TestCase):
|
||||
expected_status = "## HEAD (no branch)"
|
||||
self.assertEqual(status, expected_status)
|
||||
|
||||
self.assertEqual(os.getcwd(),self.cwd, "We should be left in the same CWD we started")
|
||||
self.assertEqual(
|
||||
os.getcwd(), self.cwd, "We should be left in the same CWD we started"
|
||||
)
|
||||
|
||||
def test_update(self):
|
||||
"""Test using git to update the local repo"""
|
||||
@@ -98,7 +102,9 @@ class TestGit(unittest.TestCase):
|
||||
self.assertTrue(self.git.update_available(checkout_dir))
|
||||
self.git.update(checkout_dir)
|
||||
self.assertFalse(self.git.update_available(checkout_dir))
|
||||
self.assertEqual(os.getcwd(),self.cwd, "We should be left in the same CWD we started")
|
||||
self.assertEqual(
|
||||
os.getcwd(), self.cwd, "We should be left in the same CWD we started"
|
||||
)
|
||||
|
||||
def test_tag_and_branch(self):
|
||||
"""Test checking the currently checked-out tag"""
|
||||
@@ -122,21 +128,25 @@ class TestGit(unittest.TestCase):
|
||||
self.assertEqual(found_branch, expected_branch)
|
||||
self.assertFalse(self.git.update_available(checkout_dir))
|
||||
|
||||
self.assertEqual(os.getcwd(),self.cwd, "We should be left in the same CWD we started")
|
||||
self.assertEqual(
|
||||
os.getcwd(), self.cwd, "We should be left in the same CWD we started"
|
||||
)
|
||||
|
||||
def test_get_remote(self):
|
||||
""" Test getting the remote location """
|
||||
"""Test getting the remote location"""
|
||||
checkout_dir = self._clone_test_repo()
|
||||
expected_remote = self.test_repo_remote
|
||||
returned_remote = self.git.get_remote(checkout_dir)
|
||||
self.assertEqual(expected_remote, returned_remote)
|
||||
self.assertEqual(os.getcwd(),self.cwd, "We should be left in the same CWD we started")
|
||||
self.assertEqual(
|
||||
os.getcwd(), self.cwd, "We should be left in the same CWD we started"
|
||||
)
|
||||
|
||||
def test_repair(self):
|
||||
""" Test the repair feature (and some exception throwing) """
|
||||
"""Test the repair feature (and some exception throwing)"""
|
||||
checkout_dir = self._clone_test_repo()
|
||||
remote = self.git.get_remote(checkout_dir)
|
||||
git_dir = os.path.join(checkout_dir,".git")
|
||||
git_dir = os.path.join(checkout_dir, ".git")
|
||||
self.assertTrue(os.path.exists(git_dir))
|
||||
self._rmdir(git_dir)
|
||||
|
||||
@@ -146,9 +156,10 @@ class TestGit(unittest.TestCase):
|
||||
|
||||
self.git.repair(remote, checkout_dir)
|
||||
status = self.git.status(checkout_dir)
|
||||
self.assertEqual(status,"## main...origin/main\n")
|
||||
self.assertEqual(os.getcwd(),self.cwd, "We should be left in the same CWD we started")
|
||||
|
||||
self.assertEqual(status, "## main...origin/main\n")
|
||||
self.assertEqual(
|
||||
os.getcwd(), self.cwd, "We should be left in the same CWD we started"
|
||||
)
|
||||
|
||||
def _rmdir(self, path):
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user