diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ce37efd..31b31c7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -5,23 +5,46 @@ on: types: [published] jobs: - deploy: - runs-on: ubuntu-20.04 + build: + runs-on: ubuntu-22.04 strategy: - matrix: - python: [3.7, 3.8, 3.9, '3.10'] + matrix: + python: [3.7, 3.8, 3.9, '3.10', '3.11', '3.12'] + urllib3-line: ["lt2", "ge2"] + exclude: + - python: "3.7" + urllib3-line: "ge2" + - python: "3.8" + urllib3-line: "ge2" steps: - - uses: actions/checkout@v1 - - name: Set up Python - uses: actions/setup-python@v1 + - uses: actions/checkout@v5 + - name: Setup Python + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} + - name: Install deps + run: | + pip install -r requirements/requirements.txt + if [ "${{ matrix.urllib3-line }}" = "lt2" ]; then + pip install "urllib3<2" + else + pip install "urllib3!=2.0.0,<3" + fi + pip install -e . - name: Install Tox and any other packages run: | python -m pip install --upgrade pip pip install -r requirements/test.txt - name: Run Tox run: tox -e py + release: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v5 + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: 3.12 - name: Install build dependencies run: | pip install setuptools wheel twine diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 17ce471..773ed9f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,18 +4,32 @@ on: [push, pull_request] jobs: build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: + fail-fast: false matrix: - python: [3.7, 3.8, 3.9, '3.10'] + python: [3.7, 3.8, 3.9, '3.10', '3.11', '3.12', '3.13'] + urllib3-line: ["lt2", "ge2"] + exclude: + - python: "3.7" + urllib3-line: "ge2" + - python: "3.8" + urllib3-line: "ge2" steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v5 - name: Setup Python - uses: actions/setup-python@v1 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} - - name: Install Tox and any other packages - run: pip install -r requirements/test.txt + - name: Install deps + run: | + pip install -r requirements/test.txt + if [ "${{ matrix.urllib3-line }}" = "lt2" ]; then + pip install "urllib3<2" + else + pip install "urllib3!=2.0.0,<3" + fi + pip install -e . - name: Run Tox run: tox -e py - name: Upload Coverage to codecov diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 7758d16..13342e0 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -1,3 +1,8 @@ -requests>=2.22.0 -requests_toolbelt==0.10.1 -urllib3==1.26.* \ No newline at end of file +requests_toolbelt>=1.0.0 + +urllib3<3; python_version >= "3.9" +urllib3!=2.0.0,<3; python_version < "3.9" + +requests>=2.32.2; python_version >= "3.9" +requests>=2.22.0,<2.32; python_version >= "3.7" and python_version < "3.9" +requests>=2.22.0,<2.28; python_version < "3.7" \ No newline at end of file diff --git a/requirements/test.txt b/requirements/test.txt index 2d600d6..7df3a74 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -1,7 +1,23 @@ -requests>=2.22.0 -black==19.10b0 -coverage==4.5.4 -tox==3.14.2 -responses==0.17.0 -requests_toolbelt==0.10.1 -urllib3==1.26.* \ No newline at end of file +requests_toolbelt>=1.0.0 +urllib3<3; python_version >= "3.9" +urllib3!=2.0.0,<3; python_version < "3.9" + +requests>=2.32.2; python_version >= "3.9" +requests>=2.22.0,<2.32; python_version >= "3.7" and python_version < "3.9" +requests>=2.22.0,<2.28; python_version < "3.7" + +coverage>=7.6.0; python_version >= "3.13" +coverage>=7.5.0; python_version >= "3.9" and python_version < "3.13" +coverage>=5.0,<7.0; python_version >= "3.7" and python_version < "3.9" +coverage==4.5.4; python_version < "3.7" + +responses>=0.25.0; python_version >= "3.8" +responses>=0.18.0,<0.25; python_version >= "3.7" and python_version < "3.8" +responses<0.18.0; python_version < "3.7" + +black>=24.8.0; python_version >= "3.8" +black==19.10b0; python_version < "3.8" + +tox>=4; python_version >= "3.13" +tox==3.14.2; python_version < "3.13" + diff --git a/tests/test_custom_metadata_fields_ops.py b/tests/test_custom_metadata_fields_ops.py index 49b2e03..0e43a95 100644 --- a/tests/test_custom_metadata_fields_ops.py +++ b/tests/test_custom_metadata_fields_ops.py @@ -62,6 +62,7 @@ def test_get_custom_metadata_fields_succeeds(self): responses.add( responses.GET, url, + content_type="application/json", body="""[{ "id": "62a9d5f6db485107347bb7f2", "name": "test10", @@ -115,7 +116,7 @@ def test_get_custom_metadata_fields_succeeds(self): ], "httpStatusCode": 200, "headers": { - "Content-Type": "text/plain", + "Content-Type": "application/json", "Accept-Encoding": "gzip, deflate", "Authorization": "Basic ZmFrZTEyMjo=", }, @@ -303,7 +304,7 @@ def test_delete_custom_metadata_fields_succeeds(self): URL.API_BASE_URL = "http://test.com" url = "{}/v1/customMetadataFields/{}".format(URL.API_BASE_URL, self.field_id) headers = create_headers_for_test() - responses.add(responses.DELETE, url, status=204, headers=headers, body="{}") + responses.add(responses.DELETE, url, status=204, headers=headers) resp = self.client.delete_custom_metadata_field(self.field_id) mock_response_metadata = { @@ -385,13 +386,14 @@ def test_create_custom_metadata_fields_succeeds_with_type_number(self): """ URL.API_BASE_URL = "http://test.com" url = "{}/v1/customMetadataFields".format(URL.API_BASE_URL) - headers = {"Content-Type": "application/json"} + headers = {} headers.update(create_headers_for_test()) responses.add( responses.POST, url, status=201, headers=headers, + content_type="application/json", body="""{ "id": "62dfc03b1b02a58936efca37", "name": "test", @@ -422,7 +424,7 @@ def test_create_custom_metadata_fields_succeeds_with_type_number(self): }, "httpStatusCode": 201, "headers": { - "Content-Type": "text/plain, application/json", + "Content-Type": "application/json", "Accept-Encoding": "gzip, deflate", "Authorization": "Basic ZmFrZTEyMjo=", }, @@ -457,13 +459,14 @@ def test_create_custom_metadata_fields_succeeds_with_type_textarea(self): """ URL.API_BASE_URL = "http://test.com" url = "{}/v1/customMetadataFields".format(URL.API_BASE_URL) - headers = {"Content-Type": "application/json"} + headers = {} headers.update(create_headers_for_test()) responses.add( responses.POST, url, status=201, headers=headers, + content_type="application/json", body="""{ "id": "62e0d7ae1b02a589360dc1fd", "name": "test", @@ -493,7 +496,7 @@ def test_create_custom_metadata_fields_succeeds_with_type_textarea(self): mock_response_metadata = { "headers": { - "Content-Type": "text/plain, application/json", + "Content-Type": "application/json", "Accept-Encoding": "gzip, deflate", "Authorization": "Basic ZmFrZTEyMjo=", }, @@ -543,13 +546,14 @@ def test_create_custom_metadata_fields_succeeds_with_type_date(self): """ URL.API_BASE_URL = "http://test.com" url = "{}/v1/customMetadataFields".format(URL.API_BASE_URL) - headers = {"Content-Type": "application/json"} + headers = {} headers.update(create_headers_for_test()) responses.add( responses.POST, url, status=201, headers=headers, + content_type="application/json", body="""{ "id": "62dfc9f41b02a58936f0d284", "name": "test-date", @@ -575,7 +579,7 @@ def test_create_custom_metadata_fields_succeeds_with_type_date(self): mock_response_metadata = { "headers": { - "Content-Type": "text/plain, application/json", + "Content-Type": "application/json", "Accept-Encoding": "gzip, deflate", "Authorization": "Basic ZmFrZTEyMjo=", }, @@ -621,13 +625,14 @@ def test_create_custom_metadata_fields_succeeds_with_type_boolean(self): """ URL.API_BASE_URL = "http://test.com" url = "{}/v1/customMetadataFields".format(URL.API_BASE_URL) - headers = {"Content-Type": "application/json"} + headers = {} headers.update(create_headers_for_test()) responses.add( responses.POST, url, status=201, headers=headers, + content_type="application/json", body="""{ "id": "62dfcb801b02a58936f0fc39", "name": "test-boolean", @@ -653,7 +658,7 @@ def test_create_custom_metadata_fields_succeeds_with_type_boolean(self): mock_response_metadata = { "headers": { - "Content-Type": "text/plain, application/json", + "Content-Type": "application/json", "Accept-Encoding": "gzip, deflate", "Authorization": "Basic ZmFrZTEyMjo=", }, @@ -699,13 +704,14 @@ def test_create_custom_metadata_fields_succeeds_with_type_single_select(self): """ URL.API_BASE_URL = "http://test.com" url = "{}/v1/customMetadataFields".format(URL.API_BASE_URL) - headers = {"Content-Type": "application/json"} + headers = {} headers.update(create_headers_for_test()) responses.add( responses.POST, url, status=201, headers=headers, + content_type="application/json", body="""{ "id": "62dfcdb21b02a58936f14c97", "name": "test", @@ -729,7 +735,7 @@ def test_create_custom_metadata_fields_succeeds_with_type_single_select(self): mock_response_metadata = { "headers": { - "Content-Type": "text/plain, application/json", + "Content-Type": "application/json", "Accept-Encoding": "gzip, deflate", "Authorization": "Basic ZmFrZTEyMjo=", }, @@ -775,13 +781,14 @@ def test_create_custom_metadata_fields_succeeds_with_type_multi_select(self): """ URL.API_BASE_URL = "http://test.com" url = "{}/v1/customMetadataFields".format(URL.API_BASE_URL) - headers = {"Content-Type": "application/json"} + headers = {} headers.update(create_headers_for_test()) responses.add( responses.POST, url, status=201, headers=headers, + content_type="application/json", body="""{ "id": "62dfcf001b02a58936f17808", "name": "test", @@ -809,7 +816,7 @@ def test_create_custom_metadata_fields_succeeds_with_type_multi_select(self): mock_response_metadata = { "headers": { - "Content-Type": "text/plain, application/json", + "Content-Type": "application/json", "Accept-Encoding": "gzip, deflate", "Authorization": "Basic ZmFrZTEyMjo=", }, @@ -857,12 +864,13 @@ def test_update_custom_metadata_fields_succeeds(self): """ URL.API_BASE_URL = "http://test.com" url = "{}/v1/customMetadataFields/{}".format(URL.API_BASE_URL, self.field_id) - headers = {"Content-Type": "application/json"} + headers = {} headers.update(create_headers_for_test()) responses.add( responses.PATCH, url, headers=headers, + content_type="application/json", body="""{ "id": "62a9d5f6db485107347bb7f2", "name": "test", @@ -892,7 +900,7 @@ def test_update_custom_metadata_fields_succeeds(self): }, "httpStatusCode": 200, "headers": { - "Content-Type": "text/plain, application/json", + "Content-Type": "application/json", "Accept-Encoding": "gzip, deflate", "Authorization": "Basic ZmFrZTEyMjo=", }, diff --git a/tests/test_files_ops.py b/tests/test_files_ops.py index 613406e..ed7d660 100644 --- a/tests/test_files_ops.py +++ b/tests/test_files_ops.py @@ -1155,7 +1155,7 @@ def test_bulk_file_delete_succeeds(self): URL.API_BASE_URL = "http://test.com" url = URL.API_BASE_URL + "/v1/files" + URL.BULK_FILE_DELETE - headers = {"Content-Type": "application/json"} + headers = {} headers.update(get_auth_headers_for_test()) responses.add( @@ -1163,6 +1163,7 @@ def test_bulk_file_delete_succeeds(self): url, body='{"successfullyDeletedFileIds": ["fake_123", "fake_222"]}', headers=headers, + content_type="application/json", ) resp = self.client.bulk_file_delete(self.bulk_delete_ids) @@ -1171,7 +1172,7 @@ def test_bulk_file_delete_succeeds(self): "raw": {"successfullyDeletedFileIds": ["fake_123", "fake_222"]}, "httpStatusCode": 200, "headers": { - "Content-Type": "text/plain, application/json", + "Content-Type": "application/json", "Authorization": "Basic ZmFrZTEyMjo=", }, } @@ -1196,7 +1197,7 @@ def test_bulk_file_delete_succeeds_and_recieves_extra_non_breaking_changes_from_ URL.API_BASE_URL = "http://test.com" url = URL.API_BASE_URL + "/v1/files" + URL.BULK_FILE_DELETE - headers = {"Content-Type": "application/json"} + headers = {} headers.update(get_auth_headers_for_test()) responses.add( @@ -1204,6 +1205,7 @@ def test_bulk_file_delete_succeeds_and_recieves_extra_non_breaking_changes_from_ url, body='{"successfullyDeletedFileIds": ["fake_123"],"nonDeletedFields":["fake_222"]}', headers=headers, + content_type="application/json", ) resp = self.client.bulk_file_delete(self.bulk_delete_ids) @@ -1212,7 +1214,7 @@ def test_bulk_file_delete_succeeds_and_recieves_extra_non_breaking_changes_from_ "raw": {"successfullyDeletedFileIds": ["fake_123"],"nonDeletedFields":["fake_222"]}, "httpStatusCode": 200, "headers": { - "Content-Type": "text/plain, application/json", + "Content-Type": "application/json", "Authorization": "Basic ZmFrZTEyMjo=", }, } @@ -1235,7 +1237,7 @@ def test_bulk_file_delete_fails_with_404_exception(self) -> None: URL.API_BASE_URL = "http://test.com" url = URL.API_BASE_URL + "/v1/files" + URL.BULK_FILE_DELETE - headers = {"Content-Type": "application/json"} + headers = {} headers.update(get_auth_headers_for_test()) try: responses.add( @@ -1267,7 +1269,7 @@ def test_file_delete_fails_with_400_exception(self): URL.API_BASE_URL = "http://test.com" url = "{}/v1/files/{}".format(URL.API_BASE_URL, self.file_id) - headers = {"Content-Type": "application/json"} + headers = {} headers.update(get_auth_headers_for_test()) try: responses.add( @@ -1295,16 +1297,16 @@ def test_file_delete_succeeds(self): """ URL.API_BASE_URL = "http://test.com" url = "{}/v1/files/{}".format(URL.API_BASE_URL, self.file_id) - headers = {"Content-Type": "application/json"} + headers = {} headers.update(get_auth_headers_for_test()) - responses.add(responses.DELETE, url, body="{}", status=204, headers=headers) + responses.add(responses.DELETE, url , status=204, headers=headers, content_type="application/json") resp = self.client.delete_file(self.file_id) mock_response_metadata = { "headers": { - "Content-Type": "text/plain, application/json", + "Content-Type": "application/json", "Authorization": "Basic ZmFrZTEyMjo=", }, "httpStatusCode": 204, @@ -1654,11 +1656,12 @@ def test_update_file_details_succeeds_with_id(self): """ URL.API_BASE_URL = "http://test.com" url = "{}/v1/files/{}/details/".format(URL.API_BASE_URL, self.file_id) - headers = {"Content-Type": "application/json"} + headers = {} headers.update(get_auth_headers_for_test()) responses.add( responses.PATCH, url, + content_type="application/json", body="""{ "type": "file", "name": "default-image.jpg", @@ -1750,7 +1753,7 @@ def test_update_file_details_succeeds_with_id(self): ) mock_response_metadata = { "headers": { - "Content-Type": "text/plain, application/json", + "Content-Type": "application/json", "Authorization": "Basic ZmFrZTEyMjo=", }, "http_status_code": 200, @@ -1815,11 +1818,12 @@ def test_update_file_publish_status_succeeds_(self): """ URL.API_BASE_URL = "http://test.com" url = "{}/v1/files/{}/details/".format(URL.API_BASE_URL, self.file_id) - headers = {"Content-Type": "application/json"} + headers = {} headers.update(get_auth_headers_for_test()) responses.add( responses.PATCH, url, + content_type="application/json", body="""{ "type": "file", "name": "default-image.jpg", @@ -1889,7 +1893,7 @@ def test_update_file_publish_status_succeeds_(self): ) mock_response_metadata = { "headers": { - "Content-Type": "text/plain, application/json", + "Content-Type": "application/json", "Authorization": "Basic ZmFrZTEyMjo=", }, "http_status_code": 200, @@ -2028,11 +2032,12 @@ def test_get_file_versions_succeeds_with_id(self): URL.API_BASE_URL = "http://test.com" url = "{}/v1/files/{}/versions".format(URL.API_BASE_URL, self.file_id) - headers = {"Content-Type": "application/json"} + headers = {} headers.update(get_auth_headers_for_test()) responses.add( responses.GET, url, + content_type="application/json", body="""[{ "type": "file", "name": "new_car.jpg", @@ -2228,7 +2233,7 @@ def test_get_file_versions_succeeds_with_id(self): ], "http_status_code": 200, "headers": { - "Content-Type": "text/plain, application/json", + "Content-Type": "application/json", "Authorization": "Basic ZmFrZTEyMjo=", }, } @@ -2295,7 +2300,7 @@ def test_get_file_version_details_succeeds_with_id(self): URL.API_BASE_URL, self.file_id, self.version_id ) - headers = {"Content-Type": "application/json"} + headers = {} headers.update(get_auth_headers_for_test()) responses.add( responses.GET, @@ -2334,11 +2339,12 @@ def test_get_file_version_details_succeeds_with_id(self): "mime": "image/jpeg" }""", headers=headers, + content_type="application/json", ) resp = self.client.get_file_version_details(self.file_id, self.version_id) mock_response_metadata = { "headers": { - "Content-Type": "text/plain, application/json", + "Content-Type": "application/json", "Authorization": "Basic ZmFrZTEyMjo=", }, "http_status_code": 200, @@ -2464,14 +2470,14 @@ def test_delete_file_version_succeeds(self) -> None: url = "{}/v1/files/{}/versions/{}".format( URL.API_BASE_URL, self.file_id, self.version_id ) - headers = {"Content-Type": "application/json"} + headers = {} headers.update(create_headers_for_test()) - responses.add(responses.DELETE, url, status=204, headers=headers, body="{}") + responses.add(responses.DELETE, url, status=204, headers=headers, content_type="application/json") resp = self.client.delete_file_version(self.file_id, self.version_id) mock_response_metadata = { "headers": { - "Content-Type": "text/plain, application/json", + "Content-Type": "application/json", "Accept-Encoding": "gzip, deflate", "Authorization": "Basic ZmFrZTEyMjo=", }, @@ -2500,7 +2506,7 @@ def test_copy_file_fails_with_404(self) -> None: URL.API_BASE_URL = "http://test.com" url = "{}/v1/files/copy".format(URL.API_BASE_URL) - headers = {"Content-Type": "application/json"} + headers = {} headers.update(create_headers_for_test()) responses.add( responses.POST, @@ -2532,9 +2538,9 @@ def test_copy_file_succeeds(self) -> None: URL.API_BASE_URL = "http://test.com" url = "{}/v1/files/copy".format(URL.API_BASE_URL) - headers = {"Content-Type": "application/json"} + headers = {} headers.update(create_headers_for_test()) - responses.add(responses.POST, url, status=204, headers=headers, body="{}") + responses.add(responses.POST, url, status=204, headers=headers, content_type="application/json") resp = self.client.copy_file( options=CopyFileRequestOptions( @@ -2546,7 +2552,7 @@ def test_copy_file_succeeds(self) -> None: mock_response_metadata = { "headers": { - "Content-Type": "text/plain, application/json", + "Content-Type": "application/json", "Accept-Encoding": "gzip, deflate", "Authorization": "Basic ZmFrZTEyMjo=", }, @@ -2579,9 +2585,9 @@ def test_copy_file_succeeds_without_include_file_versions(self) -> None: URL.API_BASE_URL = "http://test.com" url = "{}/v1/files/copy".format(URL.API_BASE_URL) - headers = {"Content-Type": "application/json"} + headers = {} headers.update(create_headers_for_test()) - responses.add(responses.POST, url, status=204, headers=headers, body="{}") + responses.add(responses.POST, url, status=204, headers=headers, content_type="application/json") resp = self.client.copy_file( options=CopyFileRequestOptions( @@ -2592,7 +2598,7 @@ def test_copy_file_succeeds_without_include_file_versions(self) -> None: mock_response_metadata = { "headers": { - "Content-Type": "text/plain, application/json", + "Content-Type": "application/json", "Accept-Encoding": "gzip, deflate", "Authorization": "Basic ZmFrZTEyMjo=", }, @@ -2630,7 +2636,7 @@ def test_move_file_fails_with_404(self) -> None: URL.API_BASE_URL = "http://test.com" url = "{}/v1/files/move".format(URL.API_BASE_URL) - headers = {"Content-Type": "application/json"} + headers = {} headers.update(create_headers_for_test()) responses.add( responses.POST, @@ -2661,9 +2667,9 @@ def test_move_file_succeeds(self) -> None: URL.API_BASE_URL = "http://test.com" url = "{}/v1/files/move".format(URL.API_BASE_URL) - headers = {"Content-Type": "application/json"} + headers = {} headers.update(create_headers_for_test()) - responses.add(responses.POST, url, status=204, headers=headers, body="{}") + responses.add(responses.POST, url, status=204, headers=headers, content_type="application/json") resp = self.client.move_file( options=MoveFileRequestOptions( @@ -2673,7 +2679,7 @@ def test_move_file_succeeds(self) -> None: ) mock_response_metadata = { "headers": { - "Content-Type": "text/plain, application/json", + "Content-Type": "application/json", "Accept-Encoding": "gzip, deflate", "Authorization": "Basic ZmFrZTEyMjo=", }, @@ -2711,7 +2717,7 @@ def test_rename_file_fails_with_409(self) -> None: URL.API_BASE_URL = "http://test.com" url = "{}/v1/files/rename".format(URL.API_BASE_URL) - headers = {"Content-Type": "application/json"} + headers = {} headers.update(create_headers_for_test()) try: responses.add( @@ -2745,13 +2751,14 @@ def test_rename_file_succeeds_with_purge_cache_false(self) -> None: URL.API_BASE_URL = "http://test.com" url = "{}/v1/files/rename".format(URL.API_BASE_URL) - headers = {"Content-Type": "application/json"} + headers = {} headers.update(create_headers_for_test()) responses.add( responses.PUT, url, headers=headers, body="{}", + content_type="application/json", ) resp = self.client.rename_file( options=RenameFileRequestOptions( @@ -2763,7 +2770,7 @@ def test_rename_file_succeeds_with_purge_cache_false(self) -> None: mock_response_metadata = { "headers": { - "Content-Type": "text/plain, application/json", + "Content-Type": "application/json", "Accept-Encoding": "gzip, deflate", "Authorization": "Basic ZmFrZTEyMjo=", }, @@ -2797,13 +2804,14 @@ def test_rename_file_succeeds_with_purge_cache(self) -> None: URL.API_BASE_URL = "http://test.com" url = "{}/v1/files/rename".format(URL.API_BASE_URL) - headers = {"Content-Type": "application/json"} + headers = {} headers.update(create_headers_for_test()) responses.add( responses.PUT, url, headers=headers, body='{"purgeRequestId": "62de3e986f68334a5a3339fb"}', + content_type="application/json", ) resp = self.client.rename_file( options=RenameFileRequestOptions( @@ -2815,7 +2823,7 @@ def test_rename_file_succeeds_with_purge_cache(self) -> None: mock_response_metadata = { "headers": { - "Content-Type": "text/plain, application/json", + "Content-Type": "application/json", "Accept-Encoding": "gzip, deflate", "Authorization": "Basic ZmFrZTEyMjo=", }, @@ -2849,9 +2857,9 @@ def test_rename_file_succeeds(self) -> None: URL.API_BASE_URL = "http://test.com" url = "{}/v1/files/rename".format(URL.API_BASE_URL) - headers = {"Content-Type": "application/json"} + headers = {} headers.update(create_headers_for_test()) - responses.add(responses.PUT, url, headers=headers, body="{}") + responses.add(responses.PUT, url, headers=headers, body="{}", content_type="application/json") resp = self.client.rename_file( options=RenameFileRequestOptions( file_path=self.file_path, new_file_name=self.new_file_name @@ -2859,7 +2867,7 @@ def test_rename_file_succeeds(self) -> None: ) mock_response_metadata = { "headers": { - "Content-Type": "text/plain, application/json", + "Content-Type": "application/json", "Accept-Encoding": "gzip, deflate", "Authorization": "Basic ZmFrZTEyMjo=", }, @@ -2921,12 +2929,13 @@ def test_restore_file_version_succeeds(self) -> None: url = "{}/v1/files/{}/versions/{}/restore".format( URL.API_BASE_URL, self.file_id, self.version_id ) - headers = {"Content-Type": "application/json"} + headers = {} headers.update(create_headers_for_test()) responses.add( responses.PUT, url, headers=headers, + content_type="application/json", body="""{ "fileId": "fileId", "type": "file", @@ -2966,7 +2975,7 @@ def test_restore_file_version_succeeds(self) -> None: mock_response_metadata = { "headers": { - "Content-Type": "text/plain, application/json", + "Content-Type": "application/json", "Accept-Encoding": "gzip, deflate", "Authorization": "Basic ZmFrZTEyMjo=", }, @@ -3009,7 +3018,7 @@ def test_restore_file_version_succeeds(self) -> None: def test_get_metadata_with_non_breaking_changes_in_response(self): URL.API_BASE_URL = "http://test.com" url = "{}/v1/files/{}/metadata".format(URL.API_BASE_URL, self.file_id) - headers = {"Content-Type": "application/json"} + headers = {} headers.update(create_headers_for_test()) responses.add( responses.GET, diff --git a/tests/test_folder_ops.py b/tests/test_folder_ops.py index 5a5255b..f955b71 100644 --- a/tests/test_folder_ops.py +++ b/tests/test_folder_ops.py @@ -154,7 +154,6 @@ def test_delete_folder_succeeds(self): responses.DELETE, url, status=204, - body="{}", ) resp = self.client.delete_folder( options=DeleteFolderRequestOptions(folder_path="/folderName") diff --git a/tests/test_tags_ops.py b/tests/test_tags_ops.py index b2816a1..a7945cd 100644 --- a/tests/test_tags_ops.py +++ b/tests/test_tags_ops.py @@ -59,13 +59,14 @@ def test_add_tags_succeeds(self): """ URL.API_BASE_URL = "http://test.com" url = "{}/v1/files/addTags".format(URL.API_BASE_URL) - headers = {"Content-Type": "application/json"} + headers = {} headers.update(get_auth_headers_for_test()) responses.add( responses.POST, url, body='{"successfullyUpdatedFileIds": ["fake_123"]}', headers=headers, + content_type="application/json", ) resp = self.client.add_tags( @@ -73,7 +74,7 @@ def test_add_tags_succeeds(self): ) mock_response_metadata = { "headers": { - "Content-Type": "text/plain, application/json", + "Content-Type": "application/json", "Authorization": "Basic ZmFrZTEyMjo=", }, "httpStatusCode": 200, @@ -103,7 +104,7 @@ def test_add_tags_fails_with_404_exception(self) -> None: URL.API_BASE_URL = "http://test.com" url = "{}/v1/files/addTags".format(URL.API_BASE_URL) - headers = {"Content-Type": "application/json"} + headers = {} headers.update(get_auth_headers_for_test()) try: responses.add( @@ -156,13 +157,14 @@ def test_remove_tags_succeeds(self): """ URL.API_BASE_URL = "http://test.com" url = "{}/v1/files/removeTags".format(URL.API_BASE_URL) - headers = {"Content-Type": "application/json"} + headers = {} headers.update(get_auth_headers_for_test()) responses.add( responses.POST, url, body='{"successfullyUpdatedFileIds": ["fake_123"]}', headers=headers, + content_type="application/json", ) resp = self.client.remove_tags( @@ -170,7 +172,7 @@ def test_remove_tags_succeeds(self): ) mock_response_metadata = { "headers": { - "Content-Type": "text/plain, application/json", + "Content-Type": "application/json", "Authorization": "Basic ZmFrZTEyMjo=", }, "httpStatusCode": 200, @@ -200,7 +202,7 @@ def test_remove_tags_fails_with_404_exception(self) -> None: URL.API_BASE_URL = "http://test.com" url = "{}/v1/files/removeTags".format(URL.API_BASE_URL) - headers = {"Content-Type": "application/json"} + headers = {} headers.update(get_auth_headers_for_test()) try: responses.add( @@ -266,13 +268,14 @@ def test_remove_ai_tags_succeeds(self): """ URL.API_BASE_URL = "http://test.com" url = "{}/v1/files/removeAITags".format(URL.API_BASE_URL) - headers = {"Content-Type": "application/json"} + headers = {} headers.update(get_auth_headers_for_test()) responses.add( responses.POST, url, body='{"successfullyUpdatedFileIds": ["fake_123"]}', headers=headers, + content_type="application/json", ) resp = self.client.remove_ai_tags( @@ -280,7 +283,7 @@ def test_remove_ai_tags_succeeds(self): ) mock_response_metadata = { "headers": { - "Content-Type": "text/plain, application/json", + "Content-Type": "application/json", "Authorization": "Basic ZmFrZTEyMjo=", }, "httpStatusCode": 200, @@ -310,7 +313,7 @@ def test_remove_ai_tags_fails_with_404_exception(self) -> None: URL.API_BASE_URL = "http://test.com" url = "{}/v1/files/removeAITags".format(URL.API_BASE_URL) - headers = {"Content-Type": "application/json"} + headers = {} headers.update(get_auth_headers_for_test()) try: responses.add( diff --git a/tox.ini b/tox.ini index b67c350..ad884c3 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py36, py37, py38, py39, py310 +envlist = py36, py37, py38, py39, py310, py311, py312, py313 skipsdist = True [testenv]