def test_rm(self, mock_continue_prompt, mock_delete): ShellContext.current_path = Path("/") t = "foo/6b6a7f47-807e-4c39-8ac6-3adcf2f5498f" mock_delete.return_value = True cmds.rm(resource=t, force=True) mock_delete.assert_has_calls([mock.call(Path("/foo/6b6a7f47-807e-4c39-8ac6-3adcf2f5498f"))]) self.assertFalse(mock_continue_prompt.called)
def test_rm_recursive(self, mock_continue_prompt, mock_delete, mock_get): ShellContext.current_path = Path("/") t = "foo/6b6a7f47-807e-4c39-8ac6-3adcf2f5498f" mock_continue_prompt.return_value = True mock_get.side_effect = [ { 'foo': { 'href': Path("/foo/6b6a7f47-807e-4c39-8ac6-3adcf2f5498f"), 'bar_back_refs': [ { "href": Path("/bar/22916187-5b6f-40f1-b7b6-fc6fe9f23bce") }, { "href": Path("/bar/776bdf88-6283-4c4b-9392-93a857807307") } ] } }, { 'bar': { 'href': Path("/bar/22916187-5b6f-40f1-b7b6-fc6fe9f23bce"), 'foobar_back_refs': [ { 'href': Path("/foobar/1050223f-a230-4ed6-96f1-c332700c5e01") } ] } }, { 'foobar': { 'href': Path("/foobar/1050223f-a230-4ed6-96f1-c332700c5e01") } }, { 'bar': { 'href': Path("/bar/776bdf88-6283-4c4b-9392-93a857807307") } } ] mock_delete.return_value = True cmds.rm(resource=t, recursive=True) mock_delete.assert_has_calls([ mock.call(Path("/bar/776bdf88-6283-4c4b-9392-93a857807307")), mock.call(Path("/foobar/1050223f-a230-4ed6-96f1-c332700c5e01")), mock.call(Path("/bar/22916187-5b6f-40f1-b7b6-fc6fe9f23bce")), mock.call(Path("/foo/6b6a7f47-807e-4c39-8ac6-3adcf2f5498f")) ])
def test_rm_noconfirm(self, mock_continue_prompt, mock_delete): ShellContext.current_path = Path("/") mock_continue_prompt.return_value = False t = "foo/6b6a7f47-807e-4c39-8ac6-3adcf2f5498f" cmds.rm(resource=t) self.assertFalse(mock_delete.called)