diff --git a/tests/cassettes/test_integration/test_api_keys.yaml b/tests/cassettes/test_integration/test_api_keys.yaml index d756121..34e0c52 100644 --- a/tests/cassettes/test_integration/test_api_keys.yaml +++ b/tests/cassettes/test_integration/test_api_keys.yaml @@ -1,6 +1,6 @@ interactions: - request: - body: '{"key_name": "pytest-211"}' + body: '{"key_name": "pytest-5482"}' headers: Accept: - application/json @@ -9,7 +9,7 @@ interactions: Connection: - keep-alive Content-Length: - - '26' + - '27' Content-Type: - application/json User-Agent: @@ -18,22 +18,22 @@ interactions: uri: https://console.neon.tech/api/v2/api_keys response: body: - string: '{"id":768698,"key":"v6z8swftqg5gy5m4ft79qhk4wmfminqw146fgb735cmg84iknyqg06jxit5d6iey","name":"pytest-211","created_at":"2024-01-23T22:17:08Z"}' + string: '{"id":768745,"key":"8b9ezkgcm46nk5fgdg84b31tw2smoojxcakymrvq46x4i0fis7puto9ad81o7d4c","name":"pytest-5482","created_at":"2024-01-23T22:34:47Z"}' headers: Connection: - keep-alive Content-Length: - - '142' + - '143' Content-Type: - application/json Date: - - Tue, 23 Jan 2024 22:17:08 GMT + - Tue, 23 Jan 2024 22:34:47 GMT Strict-Transport-Security: - max-age=15724800; includeSubDomains Vary: - Origin X-Neon-Ret-Request-Id: - - e1c23f388eb0cfbdac073b1def25c27c + - 534aa267d9215c4a9906eb1ecdecfbf1 status: code: 200 message: OK @@ -54,22 +54,22 @@ interactions: uri: https://console.neon.tech/api/v2/api_keys response: body: - string: '[{"id":768698,"name":"pytest-211","created_at":"2024-01-23T22:17:08Z","last_used_at":null,"last_used_from_addr":""},{"id":768657,"name":"pytest-330","created_at":"2024-01-23T22:04:59Z","last_used_at":null,"last_used_from_addr":""},{"id":768620,"name":"neon_client","created_at":"2024-01-23T21:56:07Z","last_used_at":"2024-01-23T22:17:08Z","last_used_from_addr":"204.111.161.156"}]' + string: '[{"id":768745,"name":"pytest-5482","created_at":"2024-01-23T22:34:47Z","last_used_at":null,"last_used_from_addr":""},{"id":768657,"name":"pytest-330","created_at":"2024-01-23T22:04:59Z","last_used_at":null,"last_used_from_addr":""},{"id":768620,"name":"neon_client","created_at":"2024-01-23T21:56:07Z","last_used_at":"2024-01-23T22:34:47Z","last_used_from_addr":"204.111.161.156"}]' headers: Connection: - keep-alive Content-Length: - - '380' + - '381' Content-Type: - application/json Date: - - Tue, 23 Jan 2024 22:17:08 GMT + - Tue, 23 Jan 2024 22:34:47 GMT Strict-Transport-Security: - max-age=15724800; includeSubDomains Vary: - Origin X-Neon-Ret-Request-Id: - - a01651498a31e4c084ebb995e8e5cc96 + - b1d947c8facb4874741524eb128f8839 status: code: 200 message: OK @@ -89,25 +89,25 @@ interactions: User-Agent: - neon-client/python version=(0.1.0) method: DELETE - uri: https://console.neon.tech/api/v2/api_keys/768698 + uri: https://console.neon.tech/api/v2/api_keys/768745 response: body: - string: '{"id":768698,"name":"pytest-211","revoked":true,"last_used_at":null,"last_used_from_addr":""}' + string: '{"id":768745,"name":"pytest-5482","revoked":true,"last_used_at":null,"last_used_from_addr":""}' headers: Connection: - keep-alive Content-Length: - - '93' + - '94' Content-Type: - application/json Date: - - Tue, 23 Jan 2024 22:17:08 GMT + - Tue, 23 Jan 2024 22:34:47 GMT Strict-Transport-Security: - max-age=15724800; includeSubDomains Vary: - Origin X-Neon-Ret-Request-Id: - - 6b2ed486535a6cfb467e8b9fbc8a6373 + - 865a6f80f3ce504a56c9f422ec7ecae9 status: code: 200 message: OK diff --git a/tests/cassettes/test_integration/test_create_project.yaml b/tests/cassettes/test_integration/test_create_project.yaml index 55121ef..c47fd93 100644 --- a/tests/cassettes/test_integration/test_create_project.yaml +++ b/tests/cassettes/test_integration/test_create_project.yaml @@ -16,27 +16,27 @@ interactions: uri: https://console.neon.tech/api/v2/projects response: body: - string: '{"projects":[]}' + string: '{"projects":[{"id":"yellow-bar-04969948","platform_id":"aws","region_id":"aws-us-east-2","name":"pytest-852","provisioner":"k8s-neonvm","default_endpoint_settings":{"autoscaling_limit_min_cu":0,"autoscaling_limit_max_cu":0,"suspend_timeout_seconds":0},"settings":{"allowed_ips":{"primary_branch_only":false},"enable_logical_replication":false},"pg_version":15,"proxy_host":"us-east-2.aws.neon.tech","branch_logical_size_limit":3072,"branch_logical_size_limit_bytes":3221225472,"store_passwords":true,"active_time":0,"cpu_used_sec":0,"creation_source":"console","created_at":"2024-01-23T22:24:44Z","updated_at":"2024-01-23T22:24:50Z","synthetic_storage_size":0,"quota_reset_at":"2024-02-01T00:00:00Z","owner_id":"838386f6-b5f1-4c3b-89a2-4f5a130ef3de"}],"pagination":{"cursor":"yellow-bar-04969948"}}' headers: Connection: - keep-alive Content-Length: - - '15' + - '798' Content-Type: - application/json Date: - - Tue, 23 Jan 2024 21:49:05 GMT + - Tue, 23 Jan 2024 22:26:03 GMT Strict-Transport-Security: - max-age=15724800; includeSubDomains Vary: - Origin X-Neon-Ret-Request-Id: - - e8e9ff2417bc4c10a2ae697216d03779 + - 7f400c82ef94c07c9e1270607f54873c status: code: 200 message: OK - request: - body: '{}' + body: null headers: Accept: - application/json @@ -45,7 +45,45 @@ interactions: Connection: - keep-alive Content-Length: - - '2' + - '0' + Content-Type: + - application/json + User-Agent: + - neon-client/python version=(0.1.0) + method: DELETE + uri: https://console.neon.tech/api/v2/projects/yellow-bar-04969948 + response: + body: + string: '{"project":{"data_storage_bytes_hour":0,"data_transfer_bytes":0,"written_data_bytes":0,"compute_time_seconds":0,"active_time_seconds":0,"cpu_used_sec":0,"id":"yellow-bar-04969948","platform_id":"aws","region_id":"aws-us-east-2","name":"pytest-852","provisioner":"k8s-neonvm","default_endpoint_settings":{"autoscaling_limit_min_cu":0.25,"autoscaling_limit_max_cu":0.25,"suspend_timeout_seconds":0},"settings":{"allowed_ips":{"ips":[],"primary_branch_only":false},"enable_logical_replication":false},"pg_version":15,"proxy_host":"us-east-2.aws.neon.tech","branch_logical_size_limit":3072,"branch_logical_size_limit_bytes":3221225472,"store_passwords":true,"creation_source":"console","history_retention_seconds":604800,"created_at":"2024-01-23T22:24:44Z","updated_at":"2024-01-23T22:24:50Z","synthetic_storage_size":0,"consumption_period_start":"0001-01-01T00:00:00Z","consumption_period_end":"0001-01-01T00:00:00Z","owner_id":"838386f6-b5f1-4c3b-89a2-4f5a130ef3de"}}' + headers: + Connection: + - keep-alive + Content-Length: + - '965' + Content-Type: + - application/json + Date: + - Tue, 23 Jan 2024 22:26:03 GMT + Strict-Transport-Security: + - max-age=15724800; includeSubDomains + Vary: + - Origin + X-Neon-Ret-Request-Id: + - db7bf26ea50193f792ad222fb26e33f8 + status: + code: 200 + message: OK +- request: + body: '{"project": {"name": "pytest-148"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '35' Content-Type: - application/json User-Agent: @@ -54,24 +92,61 @@ interactions: uri: https://console.neon.tech/api/v2/projects response: body: - string: '{"code":"","message":"invalid request: decode application/json: invalid: - project (field required)"}' + string: '{"project":{"data_storage_bytes_hour":0,"data_transfer_bytes":0,"written_data_bytes":0,"compute_time_seconds":0,"active_time_seconds":0,"cpu_used_sec":0,"id":"cold-bonus-61650555","platform_id":"aws","region_id":"aws-us-east-2","name":"pytest-148","provisioner":"k8s-neonvm","default_endpoint_settings":{"autoscaling_limit_min_cu":0.25,"autoscaling_limit_max_cu":0.25,"suspend_timeout_seconds":0},"settings":{"allowed_ips":{"ips":[],"primary_branch_only":false},"enable_logical_replication":false},"pg_version":15,"proxy_host":"us-east-2.aws.neon.tech","branch_logical_size_limit":3072,"branch_logical_size_limit_bytes":3221225472,"store_passwords":true,"creation_source":"console","history_retention_seconds":604800,"created_at":"2024-01-23T22:26:03Z","updated_at":"2024-01-23T22:26:03Z","consumption_period_start":"0001-01-01T00:00:00Z","consumption_period_end":"0001-01-01T00:00:00Z","owner_id":"838386f6-b5f1-4c3b-89a2-4f5a130ef3de"},"connection_uris":[{"connection_uri":"postgres://kennethreitz:Ke98dQHnJOcA@ep-delicate-glitter-a53ow19g.us-east-2.aws.neon.tech/neondb","connection_parameters":{"database":"neondb","password":"Ke98dQHnJOcA","role":"kennethreitz","host":"ep-delicate-glitter-a53ow19g.us-east-2.aws.neon.tech","pooler_host":"ep-delicate-glitter-a53ow19g-pooler.us-east-2.aws.neon.tech"}}],"roles":[{"branch_id":"br-raspy-sound-a54diuwm","name":"kennethreitz","password":"Ke98dQHnJOcA","protected":false,"created_at":"2024-01-23T22:26:03Z","updated_at":"2024-01-23T22:26:03Z"}],"databases":[{"id":32625886,"branch_id":"br-raspy-sound-a54diuwm","name":"neondb","owner_name":"kennethreitz","created_at":"2024-01-23T22:26:03Z","updated_at":"2024-01-23T22:26:03Z"}],"operations":[{"id":"7fda088f-8f28-41c2-9700-085b6d8e5378","project_id":"cold-bonus-61650555","branch_id":"br-raspy-sound-a54diuwm","action":"create_timeline","status":"running","failures_count":0,"created_at":"2024-01-23T22:26:03Z","updated_at":"2024-01-23T22:26:03Z","total_duration_ms":0},{"id":"c8e18275-6549-4dae-bac6-64ffa5589e9b","project_id":"cold-bonus-61650555","branch_id":"br-raspy-sound-a54diuwm","endpoint_id":"ep-delicate-glitter-a53ow19g","action":"start_compute","status":"scheduling","failures_count":0,"created_at":"2024-01-23T22:26:03Z","updated_at":"2024-01-23T22:26:03Z","total_duration_ms":0}],"branch":{"id":"br-raspy-sound-a54diuwm","project_id":"cold-bonus-61650555","name":"main","current_state":"init","pending_state":"ready","creation_source":"console","primary":true,"cpu_used_sec":0,"compute_time_seconds":0,"active_time_seconds":0,"written_data_bytes":0,"data_transfer_bytes":0,"created_at":"2024-01-23T22:26:03Z","updated_at":"2024-01-23T22:26:03Z"},"endpoints":[{"host":"ep-delicate-glitter-a53ow19g.us-east-2.aws.neon.tech","id":"ep-delicate-glitter-a53ow19g","project_id":"cold-bonus-61650555","branch_id":"br-raspy-sound-a54diuwm","autoscaling_limit_min_cu":0.25,"autoscaling_limit_max_cu":0.25,"region_id":"aws-us-east-2","type":"read_write","current_state":"init","pending_state":"active","settings":{},"pooler_enabled":false,"pooler_mode":"transaction","disabled":false,"passwordless_access":true,"creation_source":"console","created_at":"2024-01-23T22:26:03Z","updated_at":"2024-01-23T22:26:03Z","proxy_host":"us-east-2.aws.neon.tech","suspend_timeout_seconds":0,"provisioner":"k8s-neonvm"}]}' + headers: + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Tue, 23 Jan 2024 22:26:03 GMT + Strict-Transport-Security: + - max-age=15724800; includeSubDomains + Transfer-Encoding: + - chunked + Vary: + - Origin + X-Neon-Ret-Request-Id: + - dee16f249e57ca07d14194d02e29e051 + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Content-Type: + - application/json + User-Agent: + - neon-client/python version=(0.1.0) + method: DELETE + uri: https://console.neon.tech/api/v2/projects/cold-bonus-61650555 + response: + body: + string: '{"project":{"data_storage_bytes_hour":0,"data_transfer_bytes":0,"written_data_bytes":0,"compute_time_seconds":0,"active_time_seconds":0,"cpu_used_sec":0,"id":"cold-bonus-61650555","platform_id":"aws","region_id":"aws-us-east-2","name":"pytest-148","provisioner":"k8s-neonvm","default_endpoint_settings":{"autoscaling_limit_min_cu":0.25,"autoscaling_limit_max_cu":0.25,"suspend_timeout_seconds":0},"settings":{"allowed_ips":{"ips":[],"primary_branch_only":false},"enable_logical_replication":false},"pg_version":15,"proxy_host":"us-east-2.aws.neon.tech","branch_logical_size_limit":3072,"branch_logical_size_limit_bytes":3221225472,"store_passwords":true,"creation_source":"console","history_retention_seconds":604800,"created_at":"2024-01-23T22:26:03Z","updated_at":"2024-01-23T22:26:03Z","synthetic_storage_size":0,"consumption_period_start":"0001-01-01T00:00:00Z","consumption_period_end":"0001-01-01T00:00:00Z","owner_id":"838386f6-b5f1-4c3b-89a2-4f5a130ef3de"}}' headers: Connection: - keep-alive Content-Length: - - '99' + - '965' Content-Type: - application/json Date: - - Tue, 23 Jan 2024 21:49:05 GMT + - Tue, 23 Jan 2024 22:26:03 GMT Strict-Transport-Security: - max-age=15724800; includeSubDomains Vary: - Origin X-Neon-Ret-Request-Id: - - b5bb915e7fd45cd3d196e266edd268a2 + - 1cbe267907ecfafe2d806b68efe399d5 status: - code: 400 - message: Bad Request + code: 200 + message: OK version: 1 diff --git a/tests/cassettes/test_integration/test_get_project.yaml b/tests/cassettes/test_integration/test_get_project.yaml deleted file mode 100644 index 278c178..0000000 --- a/tests/cassettes/test_integration/test_get_project.yaml +++ /dev/null @@ -1,110 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Type: - - application/json - User-Agent: - - neon-client/python version=(0.1.0) - method: GET - uri: https://console.neon.tech/api/v2/projects - response: - body: - string: '{"projects":[{"id":"winter-frost-26518790","platform_id":"aws","region_id":"aws-us-east-2","name":"pytest-480","provisioner":"k8s-neonvm","default_endpoint_settings":{"autoscaling_limit_min_cu":0,"autoscaling_limit_max_cu":0,"suspend_timeout_seconds":0},"settings":{"allowed_ips":{"primary_branch_only":false},"enable_logical_replication":false},"pg_version":15,"proxy_host":"us-east-2.aws.neon.tech","branch_logical_size_limit":3072,"branch_logical_size_limit_bytes":3221225472,"store_passwords":true,"active_time":0,"cpu_used_sec":0,"creation_source":"console","created_at":"2024-01-23T22:02:45Z","updated_at":"2024-01-23T22:04:10Z","synthetic_storage_size":0,"quota_reset_at":"2024-02-01T00:00:00Z","owner_id":"838386f6-b5f1-4c3b-89a2-4f5a130ef3de"}],"pagination":{"cursor":"winter-frost-26518790"}}' - headers: - Connection: - - keep-alive - Content-Length: - - '802' - Content-Type: - - application/json - Date: - - Tue, 23 Jan 2024 22:17:08 GMT - Strict-Transport-Security: - - max-age=15724800; includeSubDomains - Vary: - - Origin - X-Neon-Ret-Request-Id: - - 93a87661221a48a5f1790cec7a1f1839 - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Type: - - application/json - User-Agent: - - neon-client/python version=(0.1.0) - method: GET - uri: https://console.neon.tech/api/v2/projects - response: - body: - string: '{"projects":[{"id":"winter-frost-26518790","platform_id":"aws","region_id":"aws-us-east-2","name":"pytest-480","provisioner":"k8s-neonvm","default_endpoint_settings":{"autoscaling_limit_min_cu":0,"autoscaling_limit_max_cu":0,"suspend_timeout_seconds":0},"settings":{"allowed_ips":{"primary_branch_only":false},"enable_logical_replication":false},"pg_version":15,"proxy_host":"us-east-2.aws.neon.tech","branch_logical_size_limit":3072,"branch_logical_size_limit_bytes":3221225472,"store_passwords":true,"active_time":0,"cpu_used_sec":0,"creation_source":"console","created_at":"2024-01-23T22:02:45Z","updated_at":"2024-01-23T22:04:10Z","synthetic_storage_size":0,"quota_reset_at":"2024-02-01T00:00:00Z","owner_id":"838386f6-b5f1-4c3b-89a2-4f5a130ef3de"}],"pagination":{"cursor":"winter-frost-26518790"}}' - headers: - Connection: - - keep-alive - Content-Length: - - '802' - Content-Type: - - application/json - Date: - - Tue, 23 Jan 2024 22:17:08 GMT - Strict-Transport-Security: - - max-age=15724800; includeSubDomains - Vary: - - Origin - X-Neon-Ret-Request-Id: - - c2239a9162a47fb6c281231f696886ef - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Type: - - application/json - User-Agent: - - neon-client/python version=(0.1.0) - method: GET - uri: https://console.neon.tech/api/v2/projects/winter-frost-26518790 - response: - body: - string: '{"project":{"data_storage_bytes_hour":0,"data_transfer_bytes":0,"written_data_bytes":0,"compute_time_seconds":0,"active_time_seconds":0,"cpu_used_sec":0,"id":"winter-frost-26518790","platform_id":"aws","region_id":"aws-us-east-2","name":"pytest-480","provisioner":"k8s-neonvm","default_endpoint_settings":{"autoscaling_limit_min_cu":0.25,"autoscaling_limit_max_cu":0.25,"suspend_timeout_seconds":0},"settings":{"allowed_ips":{"ips":[],"primary_branch_only":false},"enable_logical_replication":false},"pg_version":15,"proxy_host":"us-east-2.aws.neon.tech","branch_logical_size_limit":3072,"branch_logical_size_limit_bytes":3221225472,"store_passwords":true,"creation_source":"console","history_retention_seconds":604800,"created_at":"2024-01-23T22:02:45Z","updated_at":"2024-01-23T22:04:10Z","synthetic_storage_size":0,"consumption_period_start":"2024-01-13T02:10:30Z","consumption_period_end":"2024-02-01T00:00:00Z","quota_reset_at":"2024-02-01T00:00:00Z","owner_id":"838386f6-b5f1-4c3b-89a2-4f5a130ef3de","owner":{"email":"me@kennethreitz.org","branches_limit":10,"subscription_type":"free"},"compute_last_active_at":"2024-01-23T22:04:09Z"}}' - headers: - Connection: - - keep-alive - Content-Length: - - '1142' - Content-Type: - - application/json - Date: - - Tue, 23 Jan 2024 22:17:09 GMT - Strict-Transport-Security: - - max-age=15724800; includeSubDomains - Vary: - - Origin - X-Neon-Ret-Request-Id: - - 46bf7973a42429a67279c9898a345070 - status: - code: 200 - message: OK -version: 1 diff --git a/tests/cassettes/test_integration/test_me.yaml b/tests/cassettes/test_integration/test_me.yaml index 6382762..1d72724 100644 --- a/tests/cassettes/test_integration/test_me.yaml +++ b/tests/cassettes/test_integration/test_me.yaml @@ -27,13 +27,13 @@ interactions: Content-Type: - application/json Date: - - Tue, 23 Jan 2024 22:17:08 GMT + - Tue, 23 Jan 2024 22:34:47 GMT Strict-Transport-Security: - max-age=15724800; includeSubDomains Vary: - Origin X-Neon-Ret-Request-Id: - - 5713f0995389212ecfbededa7a5da67b + - 9544ab13ec24fbd72c3ada96e9041957 status: code: 200 message: OK diff --git a/tests/cassettes/test_integration/test_project.yaml b/tests/cassettes/test_integration/test_project.yaml index fecade9..2b69747 100644 --- a/tests/cassettes/test_integration/test_project.yaml +++ b/tests/cassettes/test_integration/test_project.yaml @@ -16,22 +16,98 @@ interactions: uri: https://console.neon.tech/api/v2/projects response: body: - string: '{"projects":[{"id":"winter-frost-26518790","platform_id":"aws","region_id":"aws-us-east-2","name":"pytest-480","provisioner":"k8s-neonvm","default_endpoint_settings":{"autoscaling_limit_min_cu":0,"autoscaling_limit_max_cu":0,"suspend_timeout_seconds":0},"settings":{"allowed_ips":{"primary_branch_only":false},"enable_logical_replication":false},"pg_version":15,"proxy_host":"us-east-2.aws.neon.tech","branch_logical_size_limit":3072,"branch_logical_size_limit_bytes":3221225472,"store_passwords":true,"active_time":0,"cpu_used_sec":0,"creation_source":"console","created_at":"2024-01-23T22:02:45Z","updated_at":"2024-01-23T22:04:10Z","synthetic_storage_size":0,"quota_reset_at":"2024-02-01T00:00:00Z","owner_id":"838386f6-b5f1-4c3b-89a2-4f5a130ef3de"}],"pagination":{"cursor":"winter-frost-26518790"}}' + string: '{"projects":[]}' headers: Connection: - keep-alive Content-Length: - - '802' + - '15' Content-Type: - application/json Date: - - Tue, 23 Jan 2024 22:17:08 GMT + - Tue, 23 Jan 2024 22:34:47 GMT Strict-Transport-Security: - max-age=15724800; includeSubDomains Vary: - Origin X-Neon-Ret-Request-Id: - - 8938099626b4ef0c435ef518ecca4b75 + - 885bb4b68476fa2b8e98495e45aec920 + status: + code: 200 + message: OK +- request: + body: '{"project": {"name": "pytest-904"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '35' + Content-Type: + - application/json + User-Agent: + - neon-client/python version=(0.1.0) + method: POST + uri: https://console.neon.tech/api/v2/projects + response: + body: + string: '{"project":{"data_storage_bytes_hour":0,"data_transfer_bytes":0,"written_data_bytes":0,"compute_time_seconds":0,"active_time_seconds":0,"cpu_used_sec":0,"id":"odd-math-29198916","platform_id":"aws","region_id":"aws-us-east-2","name":"pytest-904","provisioner":"k8s-neonvm","default_endpoint_settings":{"autoscaling_limit_min_cu":0.25,"autoscaling_limit_max_cu":0.25,"suspend_timeout_seconds":0},"settings":{"allowed_ips":{"ips":[],"primary_branch_only":false},"enable_logical_replication":false},"pg_version":15,"proxy_host":"us-east-2.aws.neon.tech","branch_logical_size_limit":3072,"branch_logical_size_limit_bytes":3221225472,"store_passwords":true,"creation_source":"console","history_retention_seconds":604800,"created_at":"2024-01-23T22:34:47Z","updated_at":"2024-01-23T22:34:47Z","consumption_period_start":"0001-01-01T00:00:00Z","consumption_period_end":"0001-01-01T00:00:00Z","owner_id":"838386f6-b5f1-4c3b-89a2-4f5a130ef3de"},"connection_uris":[{"connection_uri":"postgres://kennethreitz:m5T4RJPdEjiB@ep-tiny-art-a5s7uzng.us-east-2.aws.neon.tech/neondb","connection_parameters":{"database":"neondb","password":"m5T4RJPdEjiB","role":"kennethreitz","host":"ep-tiny-art-a5s7uzng.us-east-2.aws.neon.tech","pooler_host":"ep-tiny-art-a5s7uzng-pooler.us-east-2.aws.neon.tech"}}],"roles":[{"branch_id":"br-patient-sun-a59mbwwo","name":"kennethreitz","password":"m5T4RJPdEjiB","protected":false,"created_at":"2024-01-23T22:34:47Z","updated_at":"2024-01-23T22:34:47Z"}],"databases":[{"id":32625994,"branch_id":"br-patient-sun-a59mbwwo","name":"neondb","owner_name":"kennethreitz","created_at":"2024-01-23T22:34:47Z","updated_at":"2024-01-23T22:34:47Z"}],"operations":[{"id":"bbab693e-6ad7-4454-866d-fd845bcfaaf9","project_id":"odd-math-29198916","branch_id":"br-patient-sun-a59mbwwo","action":"create_timeline","status":"running","failures_count":0,"created_at":"2024-01-23T22:34:47Z","updated_at":"2024-01-23T22:34:47Z","total_duration_ms":0},{"id":"488a4eea-86fb-4647-8692-3c64663d73bb","project_id":"odd-math-29198916","branch_id":"br-patient-sun-a59mbwwo","endpoint_id":"ep-tiny-art-a5s7uzng","action":"start_compute","status":"scheduling","failures_count":0,"created_at":"2024-01-23T22:34:47Z","updated_at":"2024-01-23T22:34:47Z","total_duration_ms":0}],"branch":{"id":"br-patient-sun-a59mbwwo","project_id":"odd-math-29198916","name":"main","current_state":"init","pending_state":"ready","creation_source":"console","primary":true,"cpu_used_sec":0,"compute_time_seconds":0,"active_time_seconds":0,"written_data_bytes":0,"data_transfer_bytes":0,"created_at":"2024-01-23T22:34:47Z","updated_at":"2024-01-23T22:34:47Z"},"endpoints":[{"host":"ep-tiny-art-a5s7uzng.us-east-2.aws.neon.tech","id":"ep-tiny-art-a5s7uzng","project_id":"odd-math-29198916","branch_id":"br-patient-sun-a59mbwwo","autoscaling_limit_min_cu":0.25,"autoscaling_limit_max_cu":0.25,"region_id":"aws-us-east-2","type":"read_write","current_state":"init","pending_state":"active","settings":{},"pooler_enabled":false,"pooler_mode":"transaction","disabled":false,"passwordless_access":true,"creation_source":"console","created_at":"2024-01-23T22:34:47Z","updated_at":"2024-01-23T22:34:47Z","proxy_host":"us-east-2.aws.neon.tech","suspend_timeout_seconds":0,"provisioner":"k8s-neonvm"}]}' + headers: + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Tue, 23 Jan 2024 22:34:47 GMT + Strict-Transport-Security: + - max-age=15724800; includeSubDomains + Transfer-Encoding: + - chunked + Vary: + - Origin + X-Neon-Ret-Request-Id: + - d6a3d3706e83028d272e71af8033ff8f + status: + code: 201 + message: Created +- request: + body: '{"project": {"name": "pytest-renamed"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '39' + Content-Type: + - application/json + User-Agent: + - neon-client/python version=(0.1.0) + method: PATCH + uri: https://console.neon.tech/api/v2/projects/odd-math-29198916 + response: + body: + string: '{"project":{"data_storage_bytes_hour":0,"data_transfer_bytes":0,"written_data_bytes":0,"compute_time_seconds":0,"active_time_seconds":0,"cpu_used_sec":0,"id":"odd-math-29198916","platform_id":"aws","region_id":"aws-us-east-2","name":"pytest-renamed","provisioner":"k8s-neonvm","default_endpoint_settings":{"autoscaling_limit_min_cu":0.25,"autoscaling_limit_max_cu":0.25,"suspend_timeout_seconds":0},"settings":{"allowed_ips":{"ips":[],"primary_branch_only":false},"enable_logical_replication":false},"pg_version":15,"proxy_host":"us-east-2.aws.neon.tech","branch_logical_size_limit":3072,"branch_logical_size_limit_bytes":3221225472,"store_passwords":true,"creation_source":"console","history_retention_seconds":604800,"created_at":"2024-01-23T22:34:47Z","updated_at":"2024-01-23T22:34:47Z","synthetic_storage_size":0,"consumption_period_start":"0001-01-01T00:00:00Z","consumption_period_end":"0001-01-01T00:00:00Z","owner_id":"838386f6-b5f1-4c3b-89a2-4f5a130ef3de"},"operations":[]}' + headers: + Connection: + - keep-alive + Content-Length: + - '983' + Content-Type: + - application/json + Date: + - Tue, 23 Jan 2024 22:34:47 GMT + Strict-Transport-Security: + - max-age=15724800; includeSubDomains + Vary: + - Origin + X-Neon-Ret-Request-Id: + - a7a4233be7008d15eda8469e20863777 status: code: 200 message: OK @@ -52,22 +128,22 @@ interactions: uri: https://console.neon.tech/api/v2/projects response: body: - string: '{"projects":[{"id":"winter-frost-26518790","platform_id":"aws","region_id":"aws-us-east-2","name":"pytest-480","provisioner":"k8s-neonvm","default_endpoint_settings":{"autoscaling_limit_min_cu":0,"autoscaling_limit_max_cu":0,"suspend_timeout_seconds":0},"settings":{"allowed_ips":{"primary_branch_only":false},"enable_logical_replication":false},"pg_version":15,"proxy_host":"us-east-2.aws.neon.tech","branch_logical_size_limit":3072,"branch_logical_size_limit_bytes":3221225472,"store_passwords":true,"active_time":0,"cpu_used_sec":0,"creation_source":"console","created_at":"2024-01-23T22:02:45Z","updated_at":"2024-01-23T22:04:10Z","synthetic_storage_size":0,"quota_reset_at":"2024-02-01T00:00:00Z","owner_id":"838386f6-b5f1-4c3b-89a2-4f5a130ef3de"}],"pagination":{"cursor":"winter-frost-26518790"}}' + string: '{"projects":[{"id":"odd-math-29198916","platform_id":"aws","region_id":"aws-us-east-2","name":"pytest-renamed","provisioner":"k8s-neonvm","default_endpoint_settings":{"autoscaling_limit_min_cu":0,"autoscaling_limit_max_cu":0,"suspend_timeout_seconds":0},"settings":{"allowed_ips":{"primary_branch_only":false},"enable_logical_replication":false},"pg_version":15,"proxy_host":"us-east-2.aws.neon.tech","branch_logical_size_limit":3072,"branch_logical_size_limit_bytes":3221225472,"store_passwords":true,"active_time":0,"cpu_used_sec":0,"creation_source":"console","created_at":"2024-01-23T22:34:47Z","updated_at":"2024-01-23T22:34:47Z","synthetic_storage_size":0,"quota_reset_at":"2024-02-01T00:00:00Z","owner_id":"838386f6-b5f1-4c3b-89a2-4f5a130ef3de"}],"pagination":{"cursor":"odd-math-29198916"}}' headers: Connection: - keep-alive Content-Length: - - '802' + - '798' Content-Type: - application/json Date: - - Tue, 23 Jan 2024 22:17:08 GMT + - Tue, 23 Jan 2024 22:34:48 GMT Strict-Transport-Security: - max-age=15724800; includeSubDomains Vary: - Origin X-Neon-Ret-Request-Id: - - 13a185c8d2e9786288e09b5442e04d02 + - ac8e72b6c67669eed91b8d44c01d5836 status: code: 200 message: OK @@ -80,30 +156,32 @@ interactions: - gzip, deflate Connection: - keep-alive + Content-Length: + - '0' Content-Type: - application/json User-Agent: - neon-client/python version=(0.1.0) - method: GET - uri: https://console.neon.tech/api/v2/projects + method: DELETE + uri: https://console.neon.tech/api/v2/projects/odd-math-29198916 response: body: - string: '{"projects":[{"id":"winter-frost-26518790","platform_id":"aws","region_id":"aws-us-east-2","name":"pytest-480","provisioner":"k8s-neonvm","default_endpoint_settings":{"autoscaling_limit_min_cu":0,"autoscaling_limit_max_cu":0,"suspend_timeout_seconds":0},"settings":{"allowed_ips":{"primary_branch_only":false},"enable_logical_replication":false},"pg_version":15,"proxy_host":"us-east-2.aws.neon.tech","branch_logical_size_limit":3072,"branch_logical_size_limit_bytes":3221225472,"store_passwords":true,"active_time":0,"cpu_used_sec":0,"creation_source":"console","created_at":"2024-01-23T22:02:45Z","updated_at":"2024-01-23T22:04:10Z","synthetic_storage_size":0,"quota_reset_at":"2024-02-01T00:00:00Z","owner_id":"838386f6-b5f1-4c3b-89a2-4f5a130ef3de"}],"pagination":{"cursor":"winter-frost-26518790"}}' + string: '{"project":{"data_storage_bytes_hour":0,"data_transfer_bytes":0,"written_data_bytes":0,"compute_time_seconds":0,"active_time_seconds":0,"cpu_used_sec":0,"id":"odd-math-29198916","platform_id":"aws","region_id":"aws-us-east-2","name":"pytest-renamed","provisioner":"k8s-neonvm","default_endpoint_settings":{"autoscaling_limit_min_cu":0.25,"autoscaling_limit_max_cu":0.25,"suspend_timeout_seconds":0},"settings":{"allowed_ips":{"ips":[],"primary_branch_only":false},"enable_logical_replication":false},"pg_version":15,"proxy_host":"us-east-2.aws.neon.tech","branch_logical_size_limit":3072,"branch_logical_size_limit_bytes":3221225472,"store_passwords":true,"creation_source":"console","history_retention_seconds":604800,"created_at":"2024-01-23T22:34:47Z","updated_at":"2024-01-23T22:34:47Z","synthetic_storage_size":0,"consumption_period_start":"0001-01-01T00:00:00Z","consumption_period_end":"0001-01-01T00:00:00Z","owner_id":"838386f6-b5f1-4c3b-89a2-4f5a130ef3de"}}' headers: Connection: - keep-alive Content-Length: - - '802' + - '967' Content-Type: - application/json Date: - - Tue, 23 Jan 2024 22:17:08 GMT + - Tue, 23 Jan 2024 22:34:48 GMT Strict-Transport-Security: - max-age=15724800; includeSubDomains Vary: - Origin X-Neon-Ret-Request-Id: - - 2674601d7f8acaded87b12cf1989c661 + - f75e2d355a42c82bd0eb7cb457d10f1f status: code: 200 message: OK diff --git a/tests/cassettes/test_integration/test_update_project.yaml b/tests/cassettes/test_integration/test_update_project.yaml deleted file mode 100644 index c1b7ad6..0000000 --- a/tests/cassettes/test_integration/test_update_project.yaml +++ /dev/null @@ -1,112 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Type: - - application/json - User-Agent: - - neon-client/python version=(0.1.0) - method: GET - uri: https://console.neon.tech/api/v2/projects - response: - body: - string: '{"projects":[{"id":"winter-frost-26518790","platform_id":"aws","region_id":"aws-us-east-2","name":"pytest-480","provisioner":"k8s-neonvm","default_endpoint_settings":{"autoscaling_limit_min_cu":0,"autoscaling_limit_max_cu":0,"suspend_timeout_seconds":0},"settings":{"allowed_ips":{"primary_branch_only":false},"enable_logical_replication":false},"pg_version":15,"proxy_host":"us-east-2.aws.neon.tech","branch_logical_size_limit":3072,"branch_logical_size_limit_bytes":3221225472,"store_passwords":true,"active_time":0,"cpu_used_sec":0,"creation_source":"console","created_at":"2024-01-23T22:02:45Z","updated_at":"2024-01-23T22:04:10Z","synthetic_storage_size":0,"quota_reset_at":"2024-02-01T00:00:00Z","owner_id":"838386f6-b5f1-4c3b-89a2-4f5a130ef3de"}],"pagination":{"cursor":"winter-frost-26518790"}}' - headers: - Connection: - - keep-alive - Content-Length: - - '802' - Content-Type: - - application/json - Date: - - Tue, 23 Jan 2024 22:17:09 GMT - Strict-Transport-Security: - - max-age=15724800; includeSubDomains - Vary: - - Origin - X-Neon-Ret-Request-Id: - - f480a6513e5fb5e25c2ec8943df1bf5b - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Type: - - application/json - User-Agent: - - neon-client/python version=(0.1.0) - method: GET - uri: https://console.neon.tech/api/v2/projects - response: - body: - string: '{"projects":[{"id":"winter-frost-26518790","platform_id":"aws","region_id":"aws-us-east-2","name":"pytest-480","provisioner":"k8s-neonvm","default_endpoint_settings":{"autoscaling_limit_min_cu":0,"autoscaling_limit_max_cu":0,"suspend_timeout_seconds":0},"settings":{"allowed_ips":{"primary_branch_only":false},"enable_logical_replication":false},"pg_version":15,"proxy_host":"us-east-2.aws.neon.tech","branch_logical_size_limit":3072,"branch_logical_size_limit_bytes":3221225472,"store_passwords":true,"active_time":0,"cpu_used_sec":0,"creation_source":"console","created_at":"2024-01-23T22:02:45Z","updated_at":"2024-01-23T22:04:10Z","synthetic_storage_size":0,"quota_reset_at":"2024-02-01T00:00:00Z","owner_id":"838386f6-b5f1-4c3b-89a2-4f5a130ef3de"}],"pagination":{"cursor":"winter-frost-26518790"}}' - headers: - Connection: - - keep-alive - Content-Length: - - '802' - Content-Type: - - application/json - Date: - - Tue, 23 Jan 2024 22:17:09 GMT - Strict-Transport-Security: - - max-age=15724800; includeSubDomains - Vary: - - Origin - X-Neon-Ret-Request-Id: - - 879d47f3f55e6f8d12286b0bd05123e7 - status: - code: 200 - message: OK -- request: - body: '{"project": {"name": "pytest-renamed"}}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '39' - Content-Type: - - application/json - User-Agent: - - neon-client/python version=(0.1.0) - method: PATCH - uri: https://console.neon.tech/api/v2/projects/winter-frost-26518790 - response: - body: - string: '{"project":{"data_storage_bytes_hour":0,"data_transfer_bytes":0,"written_data_bytes":0,"compute_time_seconds":0,"active_time_seconds":0,"cpu_used_sec":0,"id":"winter-frost-26518790","platform_id":"aws","region_id":"aws-us-east-2","name":"pytest-renamed","provisioner":"k8s-neonvm","default_endpoint_settings":{"autoscaling_limit_min_cu":0.25,"autoscaling_limit_max_cu":0.25,"suspend_timeout_seconds":0},"settings":{"allowed_ips":{"ips":[],"primary_branch_only":false},"enable_logical_replication":false},"pg_version":15,"proxy_host":"us-east-2.aws.neon.tech","branch_logical_size_limit":3072,"branch_logical_size_limit_bytes":3221225472,"store_passwords":true,"creation_source":"console","history_retention_seconds":604800,"created_at":"2024-01-23T22:02:45Z","updated_at":"2024-01-23T22:17:09Z","synthetic_storage_size":0,"consumption_period_start":"0001-01-01T00:00:00Z","consumption_period_end":"0001-01-01T00:00:00Z","owner_id":"838386f6-b5f1-4c3b-89a2-4f5a130ef3de","compute_last_active_at":"2024-01-23T22:04:09Z"},"operations":[]}' - headers: - Connection: - - keep-alive - Content-Length: - - '1035' - Content-Type: - - application/json - Date: - - Tue, 23 Jan 2024 22:17:09 GMT - Strict-Transport-Security: - - max-age=15724800; includeSubDomains - Vary: - - Origin - X-Neon-Ret-Request-Id: - - 1c076449af9f8af0228569b63d0e8f62 - status: - code: 200 - message: OK -version: 1 diff --git a/tests/conftest.py b/tests/conftest.py index 51288ec..f023c0e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -11,20 +11,17 @@ def neon(): @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] +def random_name(*, neon): + def random_name(): + return f"pytest-{randint(0, 10000)}" - return neon.project_create(project={"name": f"pytest-{randint(0, 1000)}"}) - - return new_project + return random_name @pytest.fixture -def ensure_new_api_key(*, neon): - def new_api_key(): - return neon.api_key_create(key_name=f"pytest-{randint(0, 1000)}") +def ensure_no_projects(*, neon): + def no_projects(): + for project in neon.projects().projects: + neon.project_delete(project.id) - return new_api_key + return no_projects diff --git a/tests/test_integration.py b/tests/test_integration.py index 3c58d48..cfd4e5c 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -1,4 +1,4 @@ -import random +from random import randint import pytest import neon_client @@ -14,52 +14,46 @@ def test_me(neon): me = neon.me() assert isinstance(me, neon_client.schema.CurrentUserInfoResponse) - assert me.email == "me@kennethreitz.org" + assert me.email @pytest.mark.vcr -def test_api_keys(neon, ensure_new_api_key): - key = ensure_new_api_key() +def test_api_keys(neon, random_name): + key = neon.api_key_create(key_name=random_name()) - keys = neon.api_keys() - assert len(keys) + assert len(neon.api_keys()) key = neon.api_key_revoke(key.id) assert key.revoked @pytest.mark.vcr -def test_project(neon, ensure_project): - project = ensure_project() +def test_project(neon, ensure_no_projects, random_name): + ensure_no_projects() + + project1 = neon.project_create(project={"name": random_name()}).project + assert project1.id + + project2 = neon.project_update( + project1.id, project={"name": "pytest-renamed"} + ).project + + assert project1.name != project2.name for project in neon.projects().projects: assert hasattr(project, "id") - -@pytest.mark.vcr -def test_get_project(neon, ensure_project): - r = ensure_project() - assert neon.project(r.id).project.id == r.id + neon.project_delete(project.id) # @pytest.mark.vcr -# def test_create_project(neon, ensure_project): -# r = ensure_project() +# def test_update_project(neon, ensure_project): +# project = ensure_project() # project_update = {"project": {"name": "pytest-renamed"}} -# r = neon.project_update(r.id, **project_update) -# assert r.name == "pytest" - - -@pytest.mark.vcr -def test_update_project(neon, ensure_project): - r = ensure_project() - - project_update = {"project": {"name": "pytest-renamed"}} - - r = neon.project_update(r.id, **project_update) - assert r.project.name == "pytest-renamed" +# # r = neon.project_update(, **project_update) +# assert r.project.name == "pytest-renamed" # @pytest.mark.vcr