def test_exec_with_wrong_command(self): """Test workspace without subcommand.""" ws = Mock() args = Mock() args.workspace_subcommand = "test" self.subcommand.ws = ws self.assertIsNone(self.subcommand.execute(args))
def test_exec_without_command(self): """Test workspace without subcommand.""" ws = Mock() args = Mock() args.workspace_subcommand = None self.workspace.ws = ws self.assertIsNone(self.workspace.execute(args))
def test_exec_remove(self): """Test workspace remove execution.""" ws = Mock() ws.remove = Mock() args = Mock() args.workspace_subcommand = "remove" args.name = "foo" self.subcommand.ws = ws self.subcommand.execute(args) ws.remove.assert_called_with("foo")
def test_exec_add(self): """Test workspace add execution.""" ws = Mock() ws.add = Mock() args = Mock() args.workspace_subcommand = "add" args.name = "foo" args.path = "/foo" self.subcommand.ws = ws self.subcommand.execute(args) ws.add.assert_called_with("foo", "/foo")
def test_exec_remove_call_slashes2dash(self): """ Test workspace remove execution call slashes2dash function for name argument. """ args = Mock() args.workspace_subcommand = "remove" args.name = "bar" self.subcommand.ws = Mock() with patch("yoda.subcommand.workspace.slashes2dash") as s2d: self.subcommand.execute(args) s2d.assert_called_once_with("bar")
def test_exec_add_call_slashes2dash(self): """ Test workspace add execution call slashes2dash function for name argument. """ args = Mock() args.workspace_subcommand = "add" args.name = "foo" args.path = "/foo" self.subcommand.ws = Mock() with patch("yoda.subcommand.workspace.slashes2dash") as s2d: self.subcommand.execute(args) s2d.assert_called_once_with("foo")
def test_exec_list(self): """Test workspace list execution.""" ws_list = { "yoda": { "path": "/project/yoda", "repositories": { "yoda": "/project/yoda/src" } }, "test": { "path": "/project/test" } } ws = Mock() ws.list = Mock(return_value=ws_list) args = Mock() args.workspace_subcommand = "list" self.subcommand.ws = ws self.subcommand.execute(args) ws.list.assert_called_with()