From d6ff7facf1a08ca25964fe217d8dff3d8b52775e Mon Sep 17 00:00:00 2001 From: Andrii Balitskyi <10balian10@gmail.com> Date: Fri, 27 Jun 2025 15:09:34 +0200 Subject: [PATCH] Remove Seam API tests --- tests/AccessCodesTest.php | 152 -------------------------------- tests/ActionAttemptsTest.php | 114 ------------------------ tests/ClientSessionsTest.php | 18 ---- tests/ConnectWebviewsTest.php | 61 ------------- tests/ConnectedAccountsTest.php | 84 ------------------ tests/DevicesTest.php | 101 --------------------- tests/EventsTest.php | 46 ---------- tests/LocksTest.php | 40 --------- tests/NoiseThresholdsTest.php | 72 --------------- tests/ReadmeTest.php | 11 --- tests/SmokeTest.php | 29 ------ tests/WorkspacesTest.php | 20 ----- 12 files changed, 748 deletions(-) delete mode 100644 tests/AccessCodesTest.php delete mode 100644 tests/ActionAttemptsTest.php delete mode 100644 tests/ClientSessionsTest.php delete mode 100644 tests/ConnectWebviewsTest.php delete mode 100644 tests/ConnectedAccountsTest.php delete mode 100644 tests/DevicesTest.php delete mode 100644 tests/EventsTest.php delete mode 100644 tests/LocksTest.php delete mode 100644 tests/NoiseThresholdsTest.php delete mode 100644 tests/ReadmeTest.php delete mode 100644 tests/SmokeTest.php delete mode 100644 tests/WorkspacesTest.php diff --git a/tests/AccessCodesTest.php b/tests/AccessCodesTest.php deleted file mode 100644 index 095a6d26..00000000 --- a/tests/AccessCodesTest.php +++ /dev/null @@ -1,152 +0,0 @@ -devices->list(); - $first_device_id = $devices[0]->device_id; - $second_device_id = $devices[1]->device_id; - - $access_codes = $seam->access_codes->list(device_id: $first_device_id); - $this->assertIsArray($access_codes); - - $seam->access_codes->create(device_id: $first_device_id, code: "1235"); - $seam->access_codes->create(device_id: $first_device_id, code: "3456"); - - $access_codes = $seam->access_codes->list(device_id: $first_device_id); - $this->assertTrue(count($access_codes) > 0); - - $access_code_id = $access_codes[0]->access_code_id; - $access_codes = $seam->access_codes->list( - device_id: $first_device_id, - access_code_ids: [$access_code_id] - ); - $this->assertTrue(count($access_codes) === 1); - - $access_code = $seam->access_codes->get( - access_code_id: $access_code_id - ); - $this->assertTrue($access_code->access_code_id === $access_code_id); - - $access_code = $seam->access_codes->get( - device_id: $first_device_id, - code: "1235" - ); - $this->assertTrue($access_code->code === "1235"); - - $seam->access_codes->update( - access_code_id: $access_code_id, - code: "5679" - ); - $access_code = $seam->access_codes->get( - access_code_id: $access_code_id - ); - $this->assertTrue($access_code->code === "5679"); - - $action_attempt = $seam->access_codes->delete( - access_code_id: $access_code_id - ); - - try { - $seam->access_codes->get(access_code_id: $access_code_id); - - $this->fail("Expected the code to be deleted"); - } catch (\Seam\HttpApiError $exception) { - $this->assertTrue( - str_contains($exception->getMessage(), "Access Code Not Found") - ); - } - - $start_date = new DateTime("+2 months"); - $end_date = new DateTime("+3 months"); - - $time_bound_access_code = $seam->access_codes->create( - device_id: $first_device_id, - code: "5679", - starts_at: $start_date->format(DateTime::ATOM), - ends_at: $end_date->format(DateTime::ATOM) - ); - - $formatted_starts_at = (new DateTime( - $time_bound_access_code->starts_at - ))->format("Y-m-d"); - $formatted_ends_at = (new DateTime( - $time_bound_access_code->ends_at - ))->format("Y-m-d"); - - $seam->access_codes->update( - access_code_id: $time_bound_access_code->access_code_id, - type: "ongoing" - ); - $updated_access_code = $seam->access_codes->get( - access_code_id: $time_bound_access_code->access_code_id - ); - $this->assertTrue($updated_access_code->type === "ongoing"); - - $this->assertTrue( - $formatted_starts_at === $start_date->format("Y-m-d") - ); - $this->assertTrue($formatted_ends_at === $end_date->format("Y-m-d")); - - $access_codes = $seam->access_codes->create_multiple( - device_ids: [$first_device_id, $second_device_id] - ); - $this->assertTrue(count($access_codes) === 2); - } - - public function testUnmanagedAccessCodes(): void - { - $seam = Fixture::getTestServer(); - - $device_id = $seam->devices->list()[0]->device_id; - - $managed_access_codes_before_update = $seam->access_codes->list( - device_id: $device_id - ); - - $seam->access_codes->simulate->create_unmanaged_access_code( - device_id: $device_id, - name: "Test Unmanaged Code", - code: "1234" - ); - - $unmanaged_access_codes = $seam->access_codes->unmanaged->list( - device_id: $device_id - ); - $this->assertTrue(count($unmanaged_access_codes) === 1); - $this->assertTrue($unmanaged_access_codes[0]->is_managed === false); - - $unmanaged_access_code_id = $unmanaged_access_codes[0]->access_code_id; - $seam->access_codes->unmanaged->update( - access_code_id: $unmanaged_access_code_id, - is_managed: true - ); - - usleep(200000); - - $current_managed_access_codes = $seam->access_codes->list( - device_id: $device_id - ); - $this->assertTrue( - count($managed_access_codes_before_update) + 1 === - count($current_managed_access_codes) - ); - $this->assertTrue( - !empty( - array_filter($current_managed_access_codes, function ($ac) use ( - $unmanaged_access_code_id - ) { - return $ac->access_code_id === $unmanaged_access_code_id; - }) - ) - ); - } -} diff --git a/tests/ActionAttemptsTest.php b/tests/ActionAttemptsTest.php deleted file mode 100644 index d6c45d7e..00000000 --- a/tests/ActionAttemptsTest.php +++ /dev/null @@ -1,114 +0,0 @@ -devices->list()[0]->device_id; - $action_attempt = $seam->locks->lock_door(device_id: $device_id); - - $action_attempt_id = $action_attempt->action_attempt_id; - $action_attempt = $seam->action_attempts->get( - action_attempt_id: $action_attempt_id - ); - $this->assertTrue( - $action_attempt->action_attempt_id === $action_attempt_id - ); - - $updated_action_attempt = $seam->action_attempts->poll_until_ready( - $action_attempt_id - ); - $this->assertEquals($updated_action_attempt->status, "success"); - - $action_attempts = $seam->action_attempts->list([$action_attempt_id]); - $this->assertTrue(count($action_attempts) > 0); - } - - public function testFailedActionAttempt(): void - { - $seam = Fixture::getTestServer(); - - $device_id = $seam->devices->list()[0]->device_id; - $action_attempt = $seam->locks->unlock_door( - device_id: $device_id, - wait_for_action_attempt: false - ); - - $this->assertEquals("pending", $action_attempt->status); - - $seam->request( - "POST", - "/_fake/update_action_attempt", - json: [ - "action_attempt_id" => $action_attempt->action_attempt_id, - "status" => "error", - "error" => [ - "message" => "Failed", - "type" => "failed_attempt", - ], - ] - ); - - try { - $seam->action_attempts->poll_until_ready( - $action_attempt->action_attempt_id - ); - $this->fail("Expected ActionAttemptFailedError"); - } catch (\Seam\ActionAttemptFailedError $e) { - $this->assertEquals( - $action_attempt->action_attempt_id, - $e->getActionAttempt()->action_attempt_id - ); - $this->assertEquals("error", $e->getActionAttempt()->status); - $this->assertEquals("failed_attempt", $e->getErrorCode()); - $this->assertEquals("Failed", $e->getMessage()); - } - } - - public function testTimeoutActionAttempt(): void - { - $seam = Fixture::getTestServer(); - - $device_id = $seam->devices->list()[0]->device_id; - $action_attempt = $seam->locks->unlock_door( - device_id: $device_id, - wait_for_action_attempt: false - ); - - $this->assertEquals("pending", $action_attempt->status); - - $seam->request( - "POST", - "/_fake/update_action_attempt", - json: [ - "action_attempt_id" => $action_attempt->action_attempt_id, - "status" => "pending", - ] - ); - - try { - $seam->action_attempts->poll_until_ready( - $action_attempt->action_attempt_id, - 0.1 - ); - $this->fail("Expected TimeoutError"); - } catch (\Seam\ActionAttemptTimeoutError $e) { - $this->assertEquals( - $action_attempt->action_attempt_id, - $e->getActionAttempt()->action_attempt_id - ); - $this->assertEquals("pending", $e->getActionAttempt()->status); - $this->assertEquals( - "Timed out waiting for action attempt after 0.1s", - $e->getMessage() - ); - } - } -} diff --git a/tests/ClientSessionsTest.php b/tests/ClientSessionsTest.php deleted file mode 100644 index 8a1ed11f..00000000 --- a/tests/ClientSessionsTest.php +++ /dev/null @@ -1,18 +0,0 @@ -client_sessions->create(); - - $this->assertIsString($client_session->client_session_id); - $this->assertIsString($client_session->token); - } -} diff --git a/tests/ConnectWebviewsTest.php b/tests/ConnectWebviewsTest.php deleted file mode 100644 index af3233df..00000000 --- a/tests/ConnectWebviewsTest.php +++ /dev/null @@ -1,61 +0,0 @@ -connect_webviews->create( - accepted_providers: ["august"] - ); - $this->assertIsString($connect_webview->connect_webview_id); - $this->assertIsString($connect_webview->url); - $this->assertNull($connect_webview->custom_redirect_url); - $this->assertNull($connect_webview->custom_redirect_failure_url); - $this->assertTrue($connect_webview->status == "pending"); - } - - public function testCreateWebviewWithRedirectUrl(): void - { - $seam = Fixture::getTestServer(); - $connect_webview = $seam->connect_webviews->create( - accepted_providers: ["august"], - custom_redirect_url: "https://seam.co/" - ); - $this->assertIsString($connect_webview->connect_webview_id); - $this->assertIsString($connect_webview->url); - $this->assertEquals( - $connect_webview->custom_redirect_url, - "https://seam.co/" - ); - $this->assertTrue($connect_webview->status == "pending"); - } - - public function testGetAndListConnectWebviews(): void - { - $seam = Fixture::getTestServer(); - $connect_webviews = $seam->connect_webviews->list(); - $this->assertIsArray($connect_webviews); - - $connect_webview_id = $connect_webviews[0]->connect_webview_id; - $connect_webview = $seam->connect_webviews->get( - connect_webview_id: $connect_webview_id - ); - $this->assertTrue( - $connect_webview->connect_webview_id === $connect_webview_id - ); - $connect_webviews = $seam->connect_webviews->list(); - $this->assertTrue( - count( - array_filter($connect_webviews, function ($connect_webview) { - return !empty($connect_webview->connected_account_id ?? ""); - }) - ) > 0 - ); - } -} diff --git a/tests/ConnectedAccountsTest.php b/tests/ConnectedAccountsTest.php deleted file mode 100644 index 4d7e5053..00000000 --- a/tests/ConnectedAccountsTest.php +++ /dev/null @@ -1,84 +0,0 @@ -connected_accounts->list(); - $this->assertIsArray($connected_accounts); - - $connected_account_id = $connected_accounts[0]->connected_account_id; - $connected_account = $seam->connected_accounts->get( - connected_account_id: $connected_account_id - ); - $this->assertTrue( - $connected_account->connected_account_id === $connected_account_id - ); - } - - public function testDeleteConnectedAccount(): void - { - $seam = Fixture::getTestServer(); - $connected_accounts = $seam->connected_accounts->list(); - - $connected_account_id = $connected_accounts[0]->connected_account_id; - - $connected_account = $seam->connected_accounts->get( - connected_account_id: $connected_account_id - ); - $this->assertTrue( - $connected_account->connected_account_id === $connected_account_id - ); - - $seam->connected_accounts->delete( - connected_account_id: $connected_account_id - ); - - try { - $connected_account = $seam->connected_accounts->get( - connected_account_id: $connected_account_id - ); - $this->fail("Expected the account to be deleted"); - } catch (\Seam\HttpApiError $exception) { - $this->assertTrue( - str_contains( - $exception->getErrorCode(), - "connected_account_not_found" - ) - ); - } - } - - public function testUpdateConnectedAccount(): void - { - $seam = Fixture::getTestServer(); - $connected_accounts = $seam->connected_accounts->list(); - - $connected_account_id = $connected_accounts[0]->connected_account_id; - - $connected_account = $seam->connected_accounts->get( - connected_account_id: $connected_account_id - ); - $this->assertTrue( - $connected_account->automatically_manage_new_devices === true - ); - - $seam->connected_accounts->update( - connected_account_id: $connected_account_id, - automatically_manage_new_devices: false - ); - - $connected_account = $seam->connected_accounts->get( - connected_account_id: $connected_account_id - ); - $this->assertTrue( - $connected_account->automatically_manage_new_devices === false - ); - } -} diff --git a/tests/DevicesTest.php b/tests/DevicesTest.php deleted file mode 100644 index 6a3156f5..00000000 --- a/tests/DevicesTest.php +++ /dev/null @@ -1,101 +0,0 @@ -devices->list(); - $this->assertTrue(count($devices) > 0); - - $device_ids = [$devices[0]->device_id]; - $devices = $seam->devices->list(device_ids: $device_ids); - $this->assertTrue(count($devices) == 1); - - $connected_account = $seam->connected_accounts->list()[0]; - $devices = $seam->devices->list( - connected_account_id: $connected_account->connected_account_id - ); - $this->assertTrue(count($devices) > 0); - - $devices = $seam->devices->list(device_type: "august_lock"); - $this->assertTrue(count($devices) > 0); - - $device_id = $devices[0]->device_id; - $device = $seam->devices->get(device_id: $device_id); - $this->assertTrue($device->device_id === $device_id); - - $device_name = $devices[0]->properties->name; - $device = $seam->devices->get(name: $device_name); - $this->assertTrue($device->properties->name === $device_name); - - $devices = $seam->devices->list(manufacturer: "august"); - $this->assertTrue(count($devices) > 0); - - $manufacturer = $devices[0]->properties->manufacturer; - $device = $seam->devices->get(name: $device_name); - $this->assertTrue($device->properties->manufacturer === $manufacturer); - - $stable_device_providers = $seam->devices->list_device_providers( - provider_category: "stable" - ); - $this->assertTrue(count($stable_device_providers) > 0); - } - - public function testUnmanagedDevices(): void - { - $seam = Fixture::getTestServer(); - - $devices = $seam->devices->list(); - $this->assertTrue(count($devices) > 0); - - $unmanaged_devices = $seam->devices->unmanaged->list(); - $this->assertTrue(count($unmanaged_devices) == 0); - - $device_id = $devices[0]->device_id; - $device_name = $devices[0]->properties->name; - - $seam->devices->update(device_id: $device_id, is_managed: false); - $unmanaged_devices = $seam->devices->unmanaged->list(); - $this->assertTrue(count($unmanaged_devices) == 1); - - $unmanaged_device = $seam->devices->unmanaged->get( - device_id: $device_id - ); - $this->assertTrue($unmanaged_device->device_id === $device_id); - $unmanaged_device = $seam->devices->unmanaged->get(name: $device_name); - $this->assertTrue($unmanaged_device->properties->name === $device_name); - - $connected_account = $seam->connected_accounts->list()[0]; - $devices = $seam->devices->unmanaged->list( - connected_account_id: $connected_account->connected_account_id - ); - $this->assertTrue(count($devices) > 0); - $devices = $seam->devices->unmanaged->list( - connected_account_ids: [$connected_account->connected_account_id] - ); - $this->assertTrue(count($devices) > 0); - - $devices = $seam->devices->unmanaged->list(device_type: "august_lock"); - $this->assertTrue(count($devices) > 0); - $devices = $seam->devices->unmanaged->list( - device_types: ["august_lock"] - ); - $this->assertTrue(count($devices) > 0); - - $devices = $seam->devices->unmanaged->list(manufacturer: "august"); - $this->assertTrue(count($devices) > 0); - - $seam->devices->unmanaged->update( - device_id: $device_id, - is_managed: true - ); - $unmanaged_devices = $seam->devices->unmanaged->list(); - $this->assertTrue(count($unmanaged_devices) == 0); - } -} diff --git a/tests/EventsTest.php b/tests/EventsTest.php deleted file mode 100644 index f9c02abb..00000000 --- a/tests/EventsTest.php +++ /dev/null @@ -1,46 +0,0 @@ -events->list(since: "1970-01-01T00:00:00.000Z"); - $this->assertIsArray($events); - - $device = $seam->devices->list()[0]; - $events = $seam->events->list( - since: "1970-01-01T00:00:00.000Z", - device_id: $device->device_id - ); - $this->assertIsArray($events); - - $seam->access_codes->create(device_id: $device->device_id); - $events = $seam->events->list( - since: "1970-01-01T00:00:00.000Z", - device_id: $device->device_id - ); - $this->assertIsArray($events); - - $event_id = $events[0]->event_id; - $event = $seam->events->get(event_id: $event_id); - $this->assertTrue($event->event_id === $event_id); - } - - public function testListEventsError(): void - { - $seam = Fixture::getTestServer(); - try { - $seam->events->list(since: "invalid_date"); - } catch (\Seam\HttpInvalidInputError $e) { - $this->assertTrue( - str_contains($e->getMessage(), "Must be parsable date string") - ); - } - } -} diff --git a/tests/LocksTest.php b/tests/LocksTest.php deleted file mode 100644 index 5aef886b..00000000 --- a/tests/LocksTest.php +++ /dev/null @@ -1,40 +0,0 @@ -locks->list(); - $this->assertIsArray($locks); - - $device_id = $locks[0]->device_id; - $lock = $seam->locks->get(device_id: $device_id); - $this->assertTrue($lock->device_id === $device_id); - - $lock_name = $lock->properties->name; - $lock = $seam->locks->get(name: $lock_name); - $this->assertTrue($lock->properties->name === $lock_name); - - $connect_webview = $seam->connect_webviews->list()[0]; - $locks = $seam->locks->list( - connect_webview_id: $connect_webview->connect_webview_id - ); - $this->assertTrue(count($locks) > 0); - - // Unlock door and check properties.locked - $seam->locks->lock_door($lock->device_id); - $lock = $seam->locks->get(device_id: $device_id); - $this->assertTrue($lock->properties->locked); - - $seam->locks->unlock_door($lock->device_id); - - $lock = $seam->locks->get(device_id: $device_id); - $this->assertFalse($lock->properties->locked); - } -} diff --git a/tests/NoiseThresholdsTest.php b/tests/NoiseThresholdsTest.php deleted file mode 100644 index e6d7bda3..00000000 --- a/tests/NoiseThresholdsTest.php +++ /dev/null @@ -1,72 +0,0 @@ -noise_sensors->noise_thresholds->list( - device_id: $device_id - ); - } - - $devices = $seam->devices->list(device_type: "minut_sensor"); - $device_id = $devices[0]->device_id; - - $noise_thresholds = getMinutDeviceNoiseThresholds($seam, $device_id); - $this->assertTrue(count($noise_thresholds) === 1); - - $seam->noise_sensors->noise_thresholds->create( - device_id: $device_id, - starts_daily_at: "20:00:00[America/Los_Angeles]", - ends_daily_at: "08:00:00[America/Los_Angeles]", - noise_threshold_decibels: 75 - ); - $noise_thresholds = getMinutDeviceNoiseThresholds($seam, $device_id); - $this->assertTrue(count($noise_thresholds) === 2); - - $quiet_hours_threshold = array_filter($noise_thresholds, function ( - $nt - ) { - return $nt->name !== "builtin_normal_hours"; - }); - $quiet_hours_threshold_id = reset($quiet_hours_threshold) - ->noise_threshold_id; - - $devices = $seam->noise_sensors->noise_thresholds->delete( - device_id: $device_id, - noise_threshold_id: $quiet_hours_threshold_id - ); - $noise_thresholds = getMinutDeviceNoiseThresholds($seam, $device_id); - $this->assertTrue(count($noise_thresholds) === 1); - - $normal_hours_threshold = array_filter($noise_thresholds, function ( - $nt - ) { - return $nt->name === "builtin_normal_hours"; - }); - $normal_hours_threshold_id = reset($normal_hours_threshold) - ->noise_threshold_id; - - $seam->noise_sensors->noise_thresholds->update( - device_id: $device_id, - noise_threshold_id: $normal_hours_threshold_id, - noise_threshold_decibels: 80 - ); - $updated_noise_threshold = $seam->noise_sensors->noise_thresholds->get( - noise_threshold_id: $normal_hours_threshold_id - ); - - $this->assertTrue( - $updated_noise_threshold->noise_threshold_decibels == 80 - ); - } -} diff --git a/tests/ReadmeTest.php b/tests/ReadmeTest.php deleted file mode 100644 index 93d6fb3a..00000000 --- a/tests/ReadmeTest.php +++ /dev/null @@ -1,11 +0,0 @@ -devices->list(); - $this->assertIsString($devices_response[0]->device_id); - } - public function testCreateAccessCode(): void - { - $seam = Fixture::getTestServer(); - - $access_code = $seam->access_codes->create( - device_id: "august_device_1", - code: "1234" - ); - - $this->assertTrue($access_code->status === "setting"); - $this->assertTrue($access_code->code === "1234"); - } -} diff --git a/tests/WorkspacesTest.php b/tests/WorkspacesTest.php deleted file mode 100644 index 61f57a8a..00000000 --- a/tests/WorkspacesTest.php +++ /dev/null @@ -1,20 +0,0 @@ -workspaces->list(); - $this->assertTrue(count($workspaces) > 0); - - $workspace = $seam->workspaces->get(); - $this->assertIsObject($workspace); - } -}