mirror of
https://github.com/kennethreitz/neon-api-python.git
synced 2026-06-05 22:50:18 +00:00
Add fixtures for project creation and API key generation
Enable Pydantic in Neon client
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
from random import randint
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@@ -6,3 +8,23 @@ def neon():
|
||||
from neon_client import NeonAPI
|
||||
|
||||
return NeonAPI.from_environ()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def ensure_project(find_existing=True, *, neon):
|
||||
def new_project():
|
||||
# Return main project if it exists.
|
||||
if neon.projects().projects:
|
||||
return neon.projects().projects[0]
|
||||
|
||||
return neon.project_create(project={"name": f"pytest-{randint(0, 1000)}"})
|
||||
|
||||
return new_project
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def ensure_new_api_key(*, neon):
|
||||
def new_api_key():
|
||||
return neon.api_key_create(key_name=f"pytest-{randint(0, 1000)}")
|
||||
|
||||
return new_api_key
|
||||
|
||||
Reference in New Issue
Block a user