def test_remove_file(): f = File({}) f._delete_url = 'http://delete.me/uri' f._delete = MagicMock(return_value=FakeResponse(204, {'data': {}})) f.remove() assert f._delete.called
def test_remove_file_failed(): f = File({}) f.path = 'some/path' f._delete_url = 'http://delete.me/uri' f._delete = MagicMock(return_value=FakeResponse(404, {'data': {}})) with pytest.raises(RuntimeError) as e: f.remove() assert f._delete.called assert 'Could not delete' in e.value.args[0]