@pytest.fixture
def dataset(admin_client, data_catalog, reference_data, requests_client, dataset_list_url):
def _dataset(
json_file_name,
endpoint_url=dataset_list_url,
client=admin_client,
admin_created=True,
create=True,
user_token=None,
server_url=None,
):
data = DatasetData(json_file_name)
if admin_created and create:
data.response = client.post(endpoint_url, data.json(), content_type="application/json")
data.dataset_id = data.response.data["id"]
elif admin_created is False and create:
full_url = f"{server_url}{endpoint_url}"
requests_client.headers.update({"Authorization": f"Bearer {user_token}"})
data.response = requests_client.post(full_url, json=data.json())
data.dataset_id = data.response.json()["id"]
return data
return _dataset