def test_delete_logset(mocked_url, mocked_rw_apikey, capsys): mocked_url.return_value = LOGSET_API mocked_rw_apikey.return_value = misc_ex.TEST_APIKEY_WITH_VALID_LENGTH httpretty.register_uri(httpretty.DELETE, LOGSET_API + '/123', status=204, content_type='application/json') api.delete_logset('123') out, err = capsys.readouterr() assert "Deleted logset with id: 123" in out
def test_delete_logset(mocked_url, mocked_rw_apikey, capsys): mocked_url.return_value = '', MOCK_API_URL mocked_rw_apikey.return_value = str(uuid.uuid4()) httpretty.register_uri(httpretty.DELETE, MOCK_API_URL, status=204, content_type='application/json') api.delete_logset('123') out, err = capsys.readouterr() assert not err assert "Deleted logset with id: 123" in out
def test_delete_unknown_logset(mocked_url, mocked_rw_apikey, capsys): with pytest.raises(SystemExit) as exit: mocked_url.return_value = LOGSET_API mocked_rw_apikey.return_value = misc_ex.TEST_APIKEY_WITH_VALID_LENGTH httpretty.register_uri(httpretty.DELETE, LOGSET_API + '/123', status=404, content_type='application/json') api.delete_logset('123') out, err = capsys.readouterr() assert "404" in out assert exit.code is 1
def test_delete_unknown_logset(mocked_url, mocked_rw_apikey, capsys): with pytest.raises(SystemExit) as exit: mocked_url.return_value = '', MOCK_API_URL mocked_rw_apikey.return_value = str(uuid.uuid4()) httpretty.register_uri(httpretty.DELETE, MOCK_API_URL, status=404, content_type='application/json') api.delete_logset('123') out, err = capsys.readouterr() assert err assert "404" in out assert exit.code is 1
def test_delete_logset_with_log_in_another_logset(mocked_url, mocked_rw_apikey, mocked_ro_apikey, capsys): mocked_url.return_value = '', MOCK_API_URL mocked_rw_apikey.return_value = str(uuid.uuid4()) mocked_ro_apikey.return_value = str(uuid.uuid4()) httpretty.register_uri(httpretty.DELETE, MOCK_API_URL, status=204, content_type='application/json') httpretty.register_uri(httpretty.GET, MOCK_API_URL, status=200, content_type='application/json', body=json.dumps({})) api.delete_logset('123') api.get_logset('456') out, err = capsys.readouterr() assert not err
def test_delete_logset_with_log_in_another_logset(mocked_url, mocked_rw_apikey, mocked_ro_apikey, capsys): mocked_url.return_value = LOGSET_API mocked_rw_apikey.return_value = misc_ex.TEST_APIKEY_WITH_VALID_LENGTH mocked_ro_apikey.return_value = misc_ex.TEST_APIKEY_WITH_VALID_LENGTH httpretty.register_uri(httpretty.DELETE, LOGSET_API + '/123', status=204, content_type='application/json') httpretty.register_uri(httpretty.GET, LOGSET_API + '/456', status=200, content_type='application/json', body=resp_ex.basic_logset_response_with_log) api.delete_logset('123') api.get_logset('456') out, err = capsys.readouterr() assert "XXXXXXXX-ABCD-YYYY-DCBA-XXXXXXXXXXXX" in out
def deletelogset(logset_id): """ Delete a logset """ api.delete_logset(logset_id)