diff options
-rw-r--r-- | morphlib/workspace.py | 5 | ||||
-rw-r--r-- | morphlib/workspace_tests.py | 10 |
2 files changed, 15 insertions, 0 deletions
diff --git a/morphlib/workspace.py b/morphlib/workspace.py index 93f699e6..27ccbe65 100644 --- a/morphlib/workspace.py +++ b/morphlib/workspace.py @@ -87,6 +87,11 @@ class Workspace(object): dirname, root_repository_url, system_branch_name) return sb + def list_system_branches(self): + return (morphlib.sysbranchdir.open(dirname) + for dirname in + morphlib.util.find_leaves(self.root, '.morph-system-branch')) + def open(dirname): '''Open an existing workspace. diff --git a/morphlib/workspace_tests.py b/morphlib/workspace_tests.py index 83b5e54f..b25be35e 100644 --- a/morphlib/workspace_tests.py +++ b/morphlib/workspace_tests.py @@ -99,3 +99,13 @@ class WorkspaceTests(unittest.TestCase): sb = ws.create_system_branch_directory(url, branch) self.assertTrue(type(sb), morphlib.sysbranchdir.SystemBranchDirectory) + def test_lists_created_system_branches(self): + self.create_it() + ws = morphlib.workspace.open(self.workspace_dir) + + branches = ["branch/1", "branch/2"] + for branch in branches: + ws.create_system_branch_directory('test:morphs', branch) + self.assertEqual(sorted(sb.system_branch_name + for sb in ws.list_system_branches()), + branches) |