mirror of
https://github.com/kennethreitz/neon-api-python.git
synced 2026-06-05 22:50:18 +00:00
Update test_integration.py with new tests
This commit is contained in:
+96
-15
@@ -29,36 +29,117 @@ def test_api_keys(neon, random_name):
|
||||
|
||||
@pytest.mark.vcr
|
||||
def test_project(neon, ensure_no_projects, random_name):
|
||||
# Ensure there are no projects.
|
||||
ensure_no_projects()
|
||||
|
||||
# Create a project.
|
||||
project1 = neon.project_create(project={"name": random_name()}).project
|
||||
assert project1.id
|
||||
|
||||
project2 = neon.project_update(
|
||||
project1.id, project={"name": "pytest-renamed"}
|
||||
).project
|
||||
# Get the project.
|
||||
project = neon.project(project1.id).project
|
||||
assert project.id == project1.id
|
||||
|
||||
# Rename the project.
|
||||
project2 = neon.project_update(project1.id, project={"name": random_name()}).project
|
||||
|
||||
# Ensure that the names are different.
|
||||
assert project1.name != project2.name
|
||||
|
||||
# Ensure that the IDs are present.
|
||||
for project in neon.projects().projects:
|
||||
assert hasattr(project, "id")
|
||||
|
||||
# Delete the project.
|
||||
neon.project_delete(project.id)
|
||||
|
||||
|
||||
# @pytest.mark.vcr
|
||||
# def test_update_project(neon, ensure_project):
|
||||
# project = ensure_project()
|
||||
@pytest.mark.vcr
|
||||
def test_branches(neon, ensure_no_projects, random_name):
|
||||
# Ensure there are no projects.
|
||||
ensure_no_projects()
|
||||
|
||||
# project_update = {"project": {"name": "pytest-renamed"}}
|
||||
# Create a project.
|
||||
project = neon.project_create(project={"name": random_name()}).project
|
||||
assert project.id
|
||||
|
||||
# # r = neon.project_update(, **project_update)
|
||||
# assert r.project.name == "pytest-renamed"
|
||||
# import time
|
||||
|
||||
# time.sleep(5)
|
||||
|
||||
# Create a branch.
|
||||
# branch1 = neon.branch_create(project.id, branch={"name": random_name()}).branch
|
||||
# assert branch1.id
|
||||
|
||||
# Rename the branch.
|
||||
# branch2 = neon.branch_update(branch1.id, branch={"name": random_name()}).branch
|
||||
# Ensure that the names are different.
|
||||
# assert branch2.name != branch1.name
|
||||
|
||||
# Ensure that the IDs are present.
|
||||
# for i, branch in neon.branches(project.id).branches:
|
||||
# if i == 0:
|
||||
# Only set the first branch as primary.
|
||||
# neon.branch_set_as_primary(project.id, branch.id)
|
||||
# pass
|
||||
|
||||
# List branches.
|
||||
neon.branches(project.id)
|
||||
# Delete the project.
|
||||
# neon.branch_delete(project.id, branch_id=neon.branches(project.id).branches[].id)
|
||||
|
||||
|
||||
# @pytest.mark.vcr
|
||||
# def test_project_delete(neon, ensure_project):
|
||||
# r = ensure_project()
|
||||
# print(r)
|
||||
# exit()
|
||||
# r = neon.project_delete(r.id)
|
||||
@pytest.mark.vcr
|
||||
def test_database(neon, ensure_no_projects, random_name):
|
||||
# Ensure there are no projects.
|
||||
ensure_no_projects()
|
||||
|
||||
# Create a project.
|
||||
project = neon.project_create(project={"name": random_name()}).project
|
||||
assert project.id
|
||||
|
||||
branch = neon.branches(project.id).branches[0]
|
||||
|
||||
# List databases.
|
||||
databases = neon.databases(project.id, branch.id).databases
|
||||
assert len(databases)
|
||||
|
||||
# Create a database.
|
||||
# database = neon.database_create(
|
||||
# project.id,
|
||||
# branch.id,
|
||||
# database={"name": random_name(), "owner_name": "kennethreitz"},
|
||||
# ).database
|
||||
|
||||
# Get the Database.
|
||||
# database = neon.database(project.id, branch.id, database.id).database
|
||||
# assert database.id
|
||||
|
||||
# # Rename the database.
|
||||
# database = neon.database_update(
|
||||
# project.id,
|
||||
# branch.id,
|
||||
# database.id,
|
||||
# database={"name": random_name()},
|
||||
# ).database
|
||||
|
||||
|
||||
@pytest.mark.vcr
|
||||
def test_operations(neon, ensure_no_projects, random_name):
|
||||
# Ensure there are no projects.
|
||||
ensure_no_projects()
|
||||
|
||||
# Create a project.
|
||||
project = neon.project_create(project={"name": random_name()}).project
|
||||
assert project.id
|
||||
|
||||
branch = neon.branches(project.id).branches[0]
|
||||
|
||||
# List operations.
|
||||
operations = neon.operations(project.id).operations
|
||||
assert len(operations)
|
||||
|
||||
# Get the operation.
|
||||
operation = operations[0]
|
||||
operation = neon.operation(project.id, operation.id).operation
|
||||
assert operation.id
|
||||
|
||||
Reference in New Issue
Block a user