diff --git a/sdk/python/src/snapapi/__pycache__/__init__.cpython-312.pyc b/sdk/python/src/snapapi/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..07474a5 Binary files /dev/null and b/sdk/python/src/snapapi/__pycache__/__init__.cpython-312.pyc differ diff --git a/sdk/python/src/snapapi/__pycache__/client.cpython-312.pyc b/sdk/python/src/snapapi/__pycache__/client.cpython-312.pyc new file mode 100644 index 0000000..223ed01 Binary files /dev/null and b/sdk/python/src/snapapi/__pycache__/client.cpython-312.pyc differ diff --git a/sdk/python/src/snapapi/client.py b/sdk/python/src/snapapi/client.py index 63983f9..fb2fa0e 100644 --- a/sdk/python/src/snapapi/client.py +++ b/sdk/python/src/snapapi/client.py @@ -144,6 +144,8 @@ class SnapAPI: """ if options: body = options.to_dict() + if not body.get('url'): + raise ValueError("url is required") else: if not url: raise ValueError("url is required") diff --git a/sdk/python/tests/__pycache__/test_snapapi.cpython-312.pyc b/sdk/python/tests/__pycache__/test_snapapi.cpython-312.pyc new file mode 100644 index 0000000..650078a Binary files /dev/null and b/sdk/python/tests/__pycache__/test_snapapi.cpython-312.pyc differ diff --git a/sdk/python/tests/test_snapapi.py b/sdk/python/tests/test_snapapi.py index 8a2cdf9..8ca56ab 100644 --- a/sdk/python/tests/test_snapapi.py +++ b/sdk/python/tests/test_snapapi.py @@ -165,8 +165,12 @@ class TestSnapAPI(unittest.TestCase): self.snap.capture(None) self.assertEqual(str(cm.exception), "url is required") - # Note: When using ScreenshotOptions object, URL validation doesn't happen early - # This could be considered a bug in the SDK but we're testing current behavior + def test_capture_raises_value_error_if_options_has_empty_url(self): + """capture(options=ScreenshotOptions(url='')) should raise ValueError.""" + options = ScreenshotOptions(url="") + with self.assertRaises(ValueError) as cm: + self.snap.capture(options=options) + self.assertEqual(str(cm.exception), "url is required") @patch('snapapi.client.urllib.request.urlopen') def test_capture_raises_snap_api_error_on_http_error(self, mock_urlopen):