From 566dce1cc78df9fe3ea6a6122c83270758b285ab Mon Sep 17 00:00:00 2001 From: Douglas Cerna Date: Wed, 31 Jan 2024 09:49:15 -0600 Subject: [PATCH] Remove vcrpy --- fixtures/vcr_cassettes/all_aips.yaml | 33 ---- fixtures/vcr_cassettes/all_aips_500.yaml | 41 ----- fixtures/vcr_cassettes/all_aips_504.yaml | 20 -- fixtures/vcr_cassettes/all_aips_bad_auth.yaml | 22 --- .../vcr_cassettes/all_aips_uploaded_only.yaml | 21 --- fixtures/vcr_cassettes/fixity_500.yaml | 24 --- fixtures/vcr_cassettes/fixity_bad_auth.yaml | 22 --- fixtures/vcr_cassettes/fixity_fail.yaml | 30 --- fixtures/vcr_cassettes/fixity_non_200.yaml | 24 --- fixtures/vcr_cassettes/fixity_success.yaml | 21 --- .../vcr_cassettes/post_failed_report.yaml | 42 ----- .../vcr_cassettes/post_failed_report_404.yaml | 45 ----- .../vcr_cassettes/post_failed_report_500.yaml | 42 ----- .../vcr_cassettes/post_prescan_report.yaml | 26 --- .../post_prescan_report_404.yaml | 29 --- .../post_prescan_report_500.yaml | 26 --- fixtures/vcr_cassettes/single_aip.yaml | 25 --- fixtures/vcr_cassettes/single_aip_404.yaml | 19 -- fixtures/vcr_cassettes/single_aip_500.yaml | 43 ----- fixtures/vcr_cassettes/single_aip_504.yaml | 20 -- .../vcr_cassettes/single_aip_bad_auth.yaml | 22 --- pyproject.toml | 1 - requirements-dev.txt | 38 ++-- requirements.txt | 10 +- tests/test_reporting.py | 39 ++-- tests/test_storage_service.py | 173 ++++++++++++++---- 26 files changed, 185 insertions(+), 673 deletions(-) delete mode 100644 fixtures/vcr_cassettes/all_aips.yaml delete mode 100644 fixtures/vcr_cassettes/all_aips_500.yaml delete mode 100644 fixtures/vcr_cassettes/all_aips_504.yaml delete mode 100644 fixtures/vcr_cassettes/all_aips_bad_auth.yaml delete mode 100644 fixtures/vcr_cassettes/all_aips_uploaded_only.yaml delete mode 100644 fixtures/vcr_cassettes/fixity_500.yaml delete mode 100644 fixtures/vcr_cassettes/fixity_bad_auth.yaml delete mode 100644 fixtures/vcr_cassettes/fixity_fail.yaml delete mode 100644 fixtures/vcr_cassettes/fixity_non_200.yaml delete mode 100644 fixtures/vcr_cassettes/fixity_success.yaml delete mode 100644 fixtures/vcr_cassettes/post_failed_report.yaml delete mode 100644 fixtures/vcr_cassettes/post_failed_report_404.yaml delete mode 100644 fixtures/vcr_cassettes/post_failed_report_500.yaml delete mode 100644 fixtures/vcr_cassettes/post_prescan_report.yaml delete mode 100644 fixtures/vcr_cassettes/post_prescan_report_404.yaml delete mode 100644 fixtures/vcr_cassettes/post_prescan_report_500.yaml delete mode 100644 fixtures/vcr_cassettes/single_aip.yaml delete mode 100644 fixtures/vcr_cassettes/single_aip_404.yaml delete mode 100644 fixtures/vcr_cassettes/single_aip_500.yaml delete mode 100644 fixtures/vcr_cassettes/single_aip_504.yaml delete mode 100644 fixtures/vcr_cassettes/single_aip_bad_auth.yaml diff --git a/fixtures/vcr_cassettes/all_aips.yaml b/fixtures/vcr_cassettes/all_aips.yaml deleted file mode 100644 index 55a7961..0000000 --- a/fixtures/vcr_cassettes/all_aips.yaml +++ /dev/null @@ -1,33 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: ['*/*'] - Accept-Encoding: ['gzip, deflate, compress'] - User-Agent: [python-requests/2.2.1 CPython/2.7.3 Linux/3.2.0-61-generic] - method: GET - uri: http://localhost:8000/api/v2/file/?username=test&api_key=dfe83300db5f05f63157f772820bb028bd4d0e27 - response: - body: {string: !!python/unicode '{"meta": {"limit": 20, "next": null, "offset": - 0, "previous": null, "total_count": 2}, "objects": [{"current_full_path": - "/var/archivematica/sharedDirectory/www/AIPsStore/a7f2/a05b/0fdf/42f1/a46c/4522/a831/cf17/Unicode-a7f2a05b-0fdf-42f1-a46c-4522a831cf17.7z", - "current_location": "/api/v2/location/0b82f734-763a-453c-979d-0a14cf0a250c/", - "current_path": "a7f2/a05b/0fdf/42f1/a46c/4522/a831/cf17/Unicode-a7f2a05b-0fdf-42f1-a46c-4522a831cf17.7z", - "origin_pipeline": "/api/v2/pipeline/b1cb2ba4-bf69-49a7-8aee-e472321d4dc7/", - "package_type": "AIP", "resource_uri": "/api/v2/file/a7f2a05b-0fdf-42f1-a46c-4522a831cf17/", - "size": 3506333, "status": "UPLOADED", "uuid": "a7f2a05b-0fdf-42f1-a46c-4522a831cf17"}, - {"current_full_path": "/var/archivematica/sharedDirectory/www/AIPsStore/c8eb/b75e/6b7a/46dd/a360/91d3/753d/7b72/Images-c8ebb75e-6b7a-46dd-a360-91d3753d7b72.7z", - "current_location": "/api/v2/location/0b82f734-763a-453c-979d-0a14cf0a250c/", - "current_path": "c8eb/b75e/6b7a/46dd/a360/91d3/753d/7b72/Images-c8ebb75e-6b7a-46dd-a360-91d3753d7b72.7z", - "origin_pipeline": "/api/v2/pipeline/b1cb2ba4-bf69-49a7-8aee-e472321d4dc7/", - "package_type": "AIP", "resource_uri": "/api/v2/file/c8ebb75e-6b7a-46dd-a360-91d3753d7b72/", - "size": 29439867, "status": "UPLOADED", "uuid": "c8ebb75e-6b7a-46dd-a360-91d3753d7b72"}]}'} - headers: - cache-control: [no-cache] - content-type: [application/json] - date: ['Thu, 15 May 2014 21:11:11 GMT'] - server: [WSGIServer/0.1 Python/2.7.3] - vary: ['Accept, Cookie'] - x-frame-options: [SAMEORIGIN] - status: {code: 200, message: OK} -version: 1 diff --git a/fixtures/vcr_cassettes/all_aips_500.yaml b/fixtures/vcr_cassettes/all_aips_500.yaml deleted file mode 100644 index 2b3e550..0000000 --- a/fixtures/vcr_cassettes/all_aips_500.yaml +++ /dev/null @@ -1,41 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: ['*/*'] - Accept-Encoding: ['gzip, deflate, compress'] - User-Agent: [python-requests/2.2.1 CPython/2.7.3 Linux/3.2.0-61-generic] - method: GET - uri: http://localhost:8000/api/v2/file/?username=test&api_key=dfe83300db5f05f63157f772820bb028bd4d0e27 - response: - body: {string: !!python/unicode '{"error_message": "no such column: locations_package.misc_attributes", - "traceback": "Traceback (most recent call last):\n\n File \"/home/mistydemeo/Envs/storage-service/local/lib/python2.7/site-packages/tastypie/resources.py\", - line 217, in wrapper\n response = callback(request, *args, **kwargs)\n\n File - \"/home/mistydemeo/Envs/storage-service/local/lib/python2.7/site-packages/tastypie/resources.py\", - line 459, in dispatch_list\n return self.dispatch(''list'', request, **kwargs)\n\n File - \"/home/mistydemeo/Envs/storage-service/local/lib/python2.7/site-packages/tastypie/resources.py\", - line 491, in dispatch\n response = method(request, **kwargs)\n\n File - \"/home/mistydemeo/Envs/storage-service/local/lib/python2.7/site-packages/tastypie/resources.py\", - line 1308, in get_list\n for obj in to_be_serialized[self._meta.collection_name]:\n\n File - \"/home/mistydemeo/Envs/storage-service/local/lib/python2.7/site-packages/django/db/models/query.py\", - line 139, in _result_iter\n self._fill_cache()\n\n File \"/home/mistydemeo/Envs/storage-service/local/lib/python2.7/site-packages/django/db/models/query.py\", - line 941, in _fill_cache\n self._result_cache.append(next(self._iter))\n\n File - \"/home/mistydemeo/Envs/storage-service/local/lib/python2.7/site-packages/django/db/models/query.py\", - line 317, in iterator\n for row in compiler.results_iter():\n\n File \"/home/mistydemeo/Envs/storage-service/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py\", - line 775, in results_iter\n for rows in self.execute_sql(MULTI):\n\n File - \"/home/mistydemeo/Envs/storage-service/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py\", - line 840, in execute_sql\n cursor.execute(sql, params)\n\n File \"/home/mistydemeo/Envs/storage-service/local/lib/python2.7/site-packages/django/db/backends/util.py\", - line 41, in execute\n return self.cursor.execute(sql, params)\n\n File - \"/home/mistydemeo/Envs/storage-service/local/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py\", - line 366, in execute\n six.reraise(utils.DatabaseError, utils.DatabaseError(*tuple(e.args)), - sys.exc_info()[2])\n\n File \"/home/mistydemeo/Envs/storage-service/local/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py\", - line 362, in execute\n return Database.Cursor.execute(self, query, params)\n\nDatabaseError: - no such column: locations_package.misc_attributes\n"}'} - headers: - content-type: [application/json] - date: ['Thu, 15 May 2014 21:24:51 GMT'] - server: [WSGIServer/0.1 Python/2.7.3] - vary: [Cookie] - x-frame-options: [SAMEORIGIN] - status: {code: 500, message: INTERNAL SERVER ERROR} -version: 1 diff --git a/fixtures/vcr_cassettes/all_aips_504.yaml b/fixtures/vcr_cassettes/all_aips_504.yaml deleted file mode 100644 index b59b924..0000000 --- a/fixtures/vcr_cassettes/all_aips_504.yaml +++ /dev/null @@ -1,20 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: ['*/*'] - Accept-Encoding: ['gzip, deflate, compress'] - User-Agent: [python-requests/2.2.1 CPython/2.7.7 Darwin/13.2.0] - method: GET - uri: http://localhost:8000/api/v2/file/?username=test&api_key=dfe83300db5f05f63157f772820bb028bd4d0e27 - response: - body: {string: !!python/unicode "\r\n504 Gateway Time-out\r\n\r\n

504 Gateway Time-out

\r\n
nginx/1.1.19
\r\n\r\n\r\n"} - headers: - connection: [keep-alive] - content-length: ['183'] - content-type: [text/html] - date: ['Tue, 10 Jun 2014 18:01:49 GMT'] - server: [nginx/1.1.19] - status: {code: 504, message: Gateway Time-out} -version: 1 diff --git a/fixtures/vcr_cassettes/all_aips_bad_auth.yaml b/fixtures/vcr_cassettes/all_aips_bad_auth.yaml deleted file mode 100644 index 03810ed..0000000 --- a/fixtures/vcr_cassettes/all_aips_bad_auth.yaml +++ /dev/null @@ -1,22 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: ['*/*'] - Accept-Encoding: ['gzip, deflate, compress'] - User-Agent: [python-requests/2.2.1 CPython/3.5.1 Linux/4.5.4-1-ARCH] - method: GET - uri: http://localhost:8000/api/v2/file/?username=test&api_key=bad_key - response: - body: {string: ''} - headers: - Connection: [keep-alive] - Content-Type: [text/html; charset=utf-8] - Date: ['Fri, 27 May 2016 18:10:40 GMT'] - Server: [nginx] - Transfer-Encoding: [chunked] - Vary: [Cookie] - WWW-Authenticate: [Basic Realm="django-tastypie"] - X-Frame-Options: [SAMEORIGIN] - status: {code: 401, message: UNAUTHORIZED} -version: 1 diff --git a/fixtures/vcr_cassettes/all_aips_uploaded_only.yaml b/fixtures/vcr_cassettes/all_aips_uploaded_only.yaml deleted file mode 100644 index e5d50a0..0000000 --- a/fixtures/vcr_cassettes/all_aips_uploaded_only.yaml +++ /dev/null @@ -1,21 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: ['*/*'] - Accept-Encoding: ['gzip, deflate, compress'] - User-Agent: [python-requests/2.2.1 CPython/2.7.8 Darwin/13.2.0] - method: GET - uri: http://localhost:8000/api/v2/file/?username=test&api_key=dfe83300db5f05f63157f772820bb028bd4d0e27 - response: - body: {string: !!python/unicode '{"meta": {"limit": 20, "next": null, "offset": - 0, "previous": null, "total_count": 0}, "objects": []}'} - headers: - cache-control: [no-cache] - content-type: [application/json] - date: ['Thu, 03 Jul 2014 22:09:56 GMT'] - server: [WSGIServer/0.1 Python/2.7.3] - vary: ['Accept, Cookie'] - x-frame-options: [SAMEORIGIN] - status: {code: 200, message: OK} -version: 1 diff --git a/fixtures/vcr_cassettes/fixity_500.yaml b/fixtures/vcr_cassettes/fixity_500.yaml deleted file mode 100644 index 5863721..0000000 --- a/fixtures/vcr_cassettes/fixity_500.yaml +++ /dev/null @@ -1,24 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: ['*/*'] - Accept-Encoding: ['gzip, deflate, compress'] - User-Agent: [python-requests/2.2.1 CPython/2.7.3 Linux/3.2.0-61-generic] - method: GET - uri: http://localhost:8000/api/v2/file/a7f2a05b-0fdf-42f1-a46c-4522a831cf17/check_fixity/?username=test&api_key=dfe83300db5f05f63157f772820bb028bd4d0e27 - response: - body: {string: !!python/unicode '{"error_message": "global name ''foo'' is not - defined", "traceback": "Traceback (most recent call last):\n\n File \"/home/mistydemeo/Envs/storage-service/local/lib/python2.7/site-packages/tastypie/resources.py\", - line 217, in wrapper\n response = callback(request, *args, **kwargs)\n\n File - \"/home/mistydemeo/artefactual/archivematica-storage-service/storage_service/locations/api/resources.py\", - line 515, in check_fixity_request\n foo\n\nNameError: global name ''foo'' - is not defined\n"}'} - headers: - content-type: [application/json] - date: ['Thu, 15 May 2014 22:05:38 GMT'] - server: [WSGIServer/0.1 Python/2.7.3] - vary: [Cookie] - x-frame-options: [SAMEORIGIN] - status: {code: 500, message: INTERNAL SERVER ERROR} -version: 1 diff --git a/fixtures/vcr_cassettes/fixity_bad_auth.yaml b/fixtures/vcr_cassettes/fixity_bad_auth.yaml deleted file mode 100644 index 17c4be4..0000000 --- a/fixtures/vcr_cassettes/fixity_bad_auth.yaml +++ /dev/null @@ -1,22 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: ['*/*'] - Accept-Encoding: ['gzip, deflate, compress'] - User-Agent: [python-requests/2.2.1 CPython/3.5.1 Linux/4.5.4-1-ARCH] - method: GET - uri: http://localhost:8000/api/v2/file/a7f2a05b-0fdf-42f1-a46c-4522a831cf17/check_fixity/?username=test&api_key=bad_key - response: - body: {string: ''} - headers: - Connection: [keep-alive] - Content-Type: [text/html; charset=utf-8] - Date: ['Fri, 27 May 2016 18:10:40 GMT'] - Server: [nginx] - Transfer-Encoding: [chunked] - Vary: [Cookie] - WWW-Authenticate: [Basic Realm="django-tastypie"] - X-Frame-Options: [SAMEORIGIN] - status: {code: 401, message: UNAUTHORIZED} -version: 1 diff --git a/fixtures/vcr_cassettes/fixity_fail.yaml b/fixtures/vcr_cassettes/fixity_fail.yaml deleted file mode 100644 index d1bfda6..0000000 --- a/fixtures/vcr_cassettes/fixity_fail.yaml +++ /dev/null @@ -1,30 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: ['*/*'] - Accept-Encoding: ['gzip, deflate, compress'] - User-Agent: [python-requests/2.2.1 CPython/2.7.3 Linux/3.2.0-61-generic] - method: GET - uri: http://localhost:8000/api/v2/file/c8ebb75e-6b7a-46dd-a360-91d3753d7b72/check_fixity/?username=test&api_key=dfe83300db5f05f63157f772820bb028bd4d0e27 - response: - body: {string: !!python/unicode '{"failures": {"files": {"untracked": [], "changed": - [{"expected": "db80c8ddbb5aff1e0b0ef8b1f92fa7f8d67452e9e5360506aa1037750e436946e4f30f75158b2ca0811fdcef87b500ee1b45a21106d49a07780f813d26f3fc1a", - "path": "data/objects/oakland03.jp2", "message": "data/objects/oakland03.jp2 - checksum validation failed (alg=sha512 expected=db80c8ddbb5aff1e0b0ef8b1f92fa7f8d67452e9e5360506aa1037750e436946e4f30f75158b2ca0811fdcef87b500ee1b45a21106d49a07780f813d26f3fc1a - found=cb80c8ddbb5aff1e0b0ef8b1f92fa7f8d67452e9e5360506aa1037750e436946e4f30f75158b2ca0811fdcef87b500ee1b45a21106d49a07780f813d26f3fc1a)", - "actual": "cb80c8ddbb5aff1e0b0ef8b1f92fa7f8d67452e9e5360506aa1037750e436946e4f30f75158b2ca0811fdcef87b500ee1b45a21106d49a07780f813d26f3fc1a", - "hash_type": "sha512"}, {"expected": "0c5c9c11bd076ace318fdbf5188b281e", "path": - "manifest-sha512.txt", "message": "manifest-sha512.txt checksum validation - failed (alg=md5 expected=0c5c9c11bd076ace318fdbf5188b281e found=56b9263f9ab5df84ac1bdcdb965be1b2)", - "actual": "56b9263f9ab5df84ac1bdcdb965be1b2", "hash_type": "md5"}], "missing": - []}}, "message": "invalid bag", "success": false}'} - headers: - cache-control: [no-cache] - content-type: [application/json] - date: ['Thu, 15 May 2014 23:42:42 GMT'] - server: [WSGIServer/0.1 Python/2.7.3] - vary: ['Accept, Cookie'] - x-frame-options: [SAMEORIGIN] - status: {code: 200, message: OK} -version: 1 diff --git a/fixtures/vcr_cassettes/fixity_non_200.yaml b/fixtures/vcr_cassettes/fixity_non_200.yaml deleted file mode 100644 index 47cb369..0000000 --- a/fixtures/vcr_cassettes/fixity_non_200.yaml +++ /dev/null @@ -1,24 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: ['*/*'] - Accept-Encoding: ['gzip, deflate, compress'] - User-Agent: [python-requests/2.2.1 CPython/2.7.3 Linux/3.2.0-61-generic] - method: GET - uri: http://localhost:8000/api/v2/file/a7f2a05b-0fdf-42f1-a46c-4522a831cf17/check_fixity/?username=test&api_key=dfe83300db5f05f63157f772820bb028bd4d0e27 - response: - body: {string: !!python/unicode '{"error_message": "global name ''foo'' is not - defined", "traceback": "Traceback (most recent call last):\n\n File \"/home/mistydemeo/Envs/storage-service/local/lib/python2.7/site-packages/tastypie/resources.py\", - line 217, in wrapper\n response = callback(request, *args, **kwargs)\n\n File - \"/home/mistydemeo/artefactual/archivematica-storage-service/storage_service/locations/api/resources.py\", - line 515, in check_fixity_request\n foo\n\nNameError: global name ''foo'' - is not defined\n"}'} - headers: - content-type: [application/json] - date: ['Thu, 15 May 2014 22:05:38 GMT'] - server: [WSGIServer/0.1 Python/2.7.3] - vary: [Cookie] - x-frame-options: [SAMEORIGIN] - status: {code: 504, message: INTERNAL SERVER ERROR} -version: 1 diff --git a/fixtures/vcr_cassettes/fixity_success.yaml b/fixtures/vcr_cassettes/fixity_success.yaml deleted file mode 100644 index 026be91..0000000 --- a/fixtures/vcr_cassettes/fixity_success.yaml +++ /dev/null @@ -1,21 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: ['*/*'] - Accept-Encoding: ['gzip, deflate, compress'] - User-Agent: [python-requests/2.2.1 CPython/2.7.3 Linux/3.2.0-61-generic] - method: GET - uri: http://localhost:8000/api/v2/file/c8ebb75e-6b7a-46dd-a360-91d3753d7b72/check_fixity/?username=test&api_key=dfe83300db5f05f63157f772820bb028bd4d0e27 - response: - body: {string: !!python/unicode '{"failures": {"files": {"untracked": [], "changed": - [], "missing": []}}, "message": "", "success": true}'} - headers: - cache-control: [no-cache] - content-type: [application/json] - date: ['Thu, 15 May 2014 23:40:14 GMT'] - server: [WSGIServer/0.1 Python/2.7.3] - vary: ['Accept, Cookie'] - x-frame-options: [SAMEORIGIN] - status: {code: 200, message: OK} -version: 1 diff --git a/fixtures/vcr_cassettes/post_failed_report.yaml b/fixtures/vcr_cassettes/post_failed_report.yaml deleted file mode 100644 index 44aa1e6..0000000 --- a/fixtures/vcr_cassettes/post_failed_report.yaml +++ /dev/null @@ -1,42 +0,0 @@ -interactions: -- request: - body: "{\n \"success\": false,\n \"message\": \"invalid bag\",\n \"failures\": - {\n \"files\": {\n \"missing\": [\n {\n \"message\": - \"data/objects/no_such_file exists in manifest but not found on filesystem\",\n - \ \"path\": \"data/objects/no_such_file\"\n }\n ],\n \"changed\": - [\n {\n \"hash_type\": \"md5\",\n \"actual\": \"38a7fce00127fe8a9415fd7cb9af0499\",\n - \ \"message\": \"manifest-sha512.txt checksum validation failed (alg=md5 - expected=87c03839071596c9948b60bb7d90dc69 found=38a7fce00127fe8a9415fd7cb9af0499)\",\n - \ \"path\": \"manifest-sha512.txt\",\n \"expected\": \"87c03839071596c9948b60bb7d90dc69\"\n - \ },\n {\n \"hash_type\": \"sha512\",\n \"actual\": - \"1325e2a0299104e309a725b09e2880962158ac682ef04ff91d3686aac7dd5784ada8b74135020b87a5e464b1b2d307d9da50f47aac78b4e53f89a7108255d076\",\n - \ \"message\": \"data/objects/smaufrai.bmp checksum validation failed - (alg=sha512 expected=2325e2a0299104e309a725b09e2880962158ac682ef04ff91d3686aac7dd5784ada8b74135020b87a5e464b1b2d307d9da50f47aac78b4e53f89a7108255d076 - found=1325e2a0299104e309a725b09e2880962158ac682ef04ff91d3686aac7dd5784ada8b74135020b87a5e464b1b2d307d9da50f47aac78b4e53f89a7108255d076)\",\n - \ \"path\": \"data/objects/smaufrai.bmp\",\n \"expected\": - \"2325e2a0299104e309a725b09e2880962158ac682ef04ff91d3686aac7dd5784ada8b74135020b87a5e464b1b2d307d9da50f47aac78b4e53f89a7108255d076\"\n - \ }\n ],\n \"untracked\": []\n }\n },\n \"started\": 1400022946,\n - \ \"finished\": 1400023208\n}\n" - headers: - Accept: ['*/*'] - Accept-Encoding: ['gzip, deflate, compress'] - Content-Length: ['1520'] - Content-Type: [application/json] - User-Agent: [python-requests/2.2.1 CPython/2.7.6 Darwin/13.2.0] - method: POST - uri: http://localhost:8003/api/fixity/ed42aadc-d854-46c6-b455-cd384eef1618 - response: - body: {string: !!python/unicode '{"id":"394"}'} - headers: - cache-control: ['no-store, no-cache, must-revalidate, post-check=0, pre-check=0'] - connection: [keep-alive] - content-type: [application/json; charset=utf-8] - date: ['Fri, 16 May 2014 23:58:15 GMT'] - expires: ['Thu, 19 Nov 1981 08:52:00 GMT'] - pragma: [no-cache] - server: [nginx] - set-cookie: [symfony=coa0ivb41jibovn8euf6m79f92; path=/] - transfer-encoding: [chunked] - x-powered-by: [PHP/5.5.10-1+deb.sury.org~precise+1] - status: {code: 201, message: Created} -version: 1 diff --git a/fixtures/vcr_cassettes/post_failed_report_404.yaml b/fixtures/vcr_cassettes/post_failed_report_404.yaml deleted file mode 100644 index f3ea9c3..0000000 --- a/fixtures/vcr_cassettes/post_failed_report_404.yaml +++ /dev/null @@ -1,45 +0,0 @@ -interactions: -- request: - body: "{\n \"success\": false,\n \"message\": \"invalid bag\",\n \"failures\": - {\n \"files\": {\n \"missing\": [\n {\n \"message\": - \"data/objects/no_such_file exists in manifest but not found on filesystem\",\n - \ \"path\": \"data/objects/no_such_file\"\n }\n ],\n \"changed\": - [\n {\n \"hash_type\": \"md5\",\n \"actual\": \"38a7fce00127fe8a9415fd7cb9af0499\",\n - \ \"message\": \"manifest-sha512.txt checksum validation failed (alg=md5 - expected=87c03839071596c9948b60bb7d90dc69 found=38a7fce00127fe8a9415fd7cb9af0499)\",\n - \ \"path\": \"manifest-sha512.txt\",\n \"expected\": \"87c03839071596c9948b60bb7d90dc69\"\n - \ },\n {\n \"hash_type\": \"sha512\",\n \"actual\": - \"1325e2a0299104e309a725b09e2880962158ac682ef04ff91d3686aac7dd5784ada8b74135020b87a5e464b1b2d307d9da50f47aac78b4e53f89a7108255d076\",\n - \ \"message\": \"data/objects/smaufrai.bmp checksum validation failed - (alg=sha512 expected=2325e2a0299104e309a725b09e2880962158ac682ef04ff91d3686aac7dd5784ada8b74135020b87a5e464b1b2d307d9da50f47aac78b4e53f89a7108255d076 - found=1325e2a0299104e309a725b09e2880962158ac682ef04ff91d3686aac7dd5784ada8b74135020b87a5e464b1b2d307d9da50f47aac78b4e53f89a7108255d076)\",\n - \ \"path\": \"data/objects/smaufrai.bmp\",\n \"expected\": - \"2325e2a0299104e309a725b09e2880962158ac682ef04ff91d3686aac7dd5784ada8b74135020b87a5e464b1b2d307d9da50f47aac78b4e53f89a7108255d076\"\n - \ }\n ],\n \"untracked\": []\n }\n },\n \"started\": 1400022946,\n - \ \"finished\": 1400023208\n}\n" - headers: - Accept: ['*/*'] - Accept-Encoding: ['gzip, deflate, compress'] - Content-Length: ['1520'] - Content-Type: [application/json] - User-Agent: [python-requests/2.2.1 CPython/2.7.6 Darwin/13.2.0] - method: POST - uri: http://localhost:8003/api/fixity/ed42aadc-d854-46c6-b455-cd384eef1618 - response: - body: - string: !!binary | - H4sIAAAAAAAAA6tWykxRslIytjRXqgUAUtwk4gwAAAA= - headers: - cache-control: ['no-store, no-cache, must-revalidate, post-check=0, pre-check=0'] - connection: [keep-alive] - content-encoding: [gzip] - content-type: [application/json; charset=utf-8] - date: ['Fri, 30 May 2014 21:46:07 GMT'] - expires: ['Thu, 19 Nov 1981 08:52:00 GMT'] - pragma: [no-cache] - server: [nginx] - set-cookie: [symfony=uhvnr9tlpjfiv6i4i4i7tb1qs2; path=/] - transfer-encoding: [chunked] - x-powered-by: [PHP/5.5.10-1+deb.sury.org~precise+1] - status: {code: 404, message: Not Found} -version: 1 diff --git a/fixtures/vcr_cassettes/post_failed_report_500.yaml b/fixtures/vcr_cassettes/post_failed_report_500.yaml deleted file mode 100644 index db747bb..0000000 --- a/fixtures/vcr_cassettes/post_failed_report_500.yaml +++ /dev/null @@ -1,42 +0,0 @@ -interactions: -- request: - body: "{\n \"success\": false,\n \"message\": \"invalid bag\",\n \"failures\": - {\n \"files\": {\n \"missing\": [\n {\n \"message\": - \"data/objects/no_such_file exists in manifest but not found on filesystem\",\n - \ \"path\": \"data/objects/no_such_file\"\n }\n ],\n \"changed\": - [\n {\n \"hash_type\": \"md5\",\n \"actual\": \"38a7fce00127fe8a9415fd7cb9af0499\",\n - \ \"message\": \"manifest-sha512.txt checksum validation failed (alg=md5 - expected=87c03839071596c9948b60bb7d90dc69 found=38a7fce00127fe8a9415fd7cb9af0499)\",\n - \ \"path\": \"manifest-sha512.txt\",\n \"expected\": \"87c03839071596c9948b60bb7d90dc69\"\n - \ },\n {\n \"hash_type\": \"sha512\",\n \"actual\": - \"1325e2a0299104e309a725b09e2880962158ac682ef04ff91d3686aac7dd5784ada8b74135020b87a5e464b1b2d307d9da50f47aac78b4e53f89a7108255d076\",\n - \ \"message\": \"data/objects/smaufrai.bmp checksum validation failed - (alg=sha512 expected=2325e2a0299104e309a725b09e2880962158ac682ef04ff91d3686aac7dd5784ada8b74135020b87a5e464b1b2d307d9da50f47aac78b4e53f89a7108255d076 - found=1325e2a0299104e309a725b09e2880962158ac682ef04ff91d3686aac7dd5784ada8b74135020b87a5e464b1b2d307d9da50f47aac78b4e53f89a7108255d076)\",\n - \ \"path\": \"data/objects/smaufrai.bmp\",\n \"expected\": - \"2325e2a0299104e309a725b09e2880962158ac682ef04ff91d3686aac7dd5784ada8b74135020b87a5e464b1b2d307d9da50f47aac78b4e53f89a7108255d076\"\n - \ }\n ],\n \"untracked\": []\n }\n },\n \"started\": 1400022946,\n - \ \"finished\": 1400023208\n}\n" - headers: - Accept: ['*/*'] - Accept-Encoding: ['gzip, deflate, compress'] - Content-Length: ['1520'] - Content-Type: [application/json] - User-Agent: [python-requests/2.2.1 CPython/2.7.6 Darwin/13.2.0] - method: POST - uri: http://localhost:8003/api/fixity/ed42aadc-d854-46c6-b455-cd384eef1618 - response: - body: {string: !!python/unicode '{"id":"394"}'} - headers: - cache-control: ['no-store, no-cache, must-revalidate, post-check=0, pre-check=0'] - connection: [keep-alive] - content-type: [application/json; charset=utf-8] - date: ['Fri, 16 May 2014 23:58:15 GMT'] - expires: ['Thu, 19 Nov 1981 08:52:00 GMT'] - pragma: [no-cache] - server: [nginx] - set-cookie: [symfony=coa0ivb41jibovn8euf6m79f92; path=/] - transfer-encoding: [chunked] - x-powered-by: [PHP/5.5.10-1+deb.sury.org~precise+1] - status: {code: 500, message: INTERNAL SERVER ERROR} -version: 1 diff --git a/fixtures/vcr_cassettes/post_prescan_report.yaml b/fixtures/vcr_cassettes/post_prescan_report.yaml deleted file mode 100644 index 23a59d4..0000000 --- a/fixtures/vcr_cassettes/post_prescan_report.yaml +++ /dev/null @@ -1,26 +0,0 @@ -interactions: -- request: - body: '{"start_time": 1400026546}' - headers: - Accept: ['*/*'] - Accept-Encoding: ['gzip, deflate, compress'] - Content-Length: ['26'] - Content-Type: [application/json] - User-Agent: [python-requests/2.2.1 CPython/2.7.6 Darwin/13.2.0] - method: POST - uri: http://localhost:8003/api/fixity/be1074fe-217b-46e0-afec-400ea1a2eb36 - response: - body: {string: !!python/unicode '{"id":"395"}'} - headers: - cache-control: ['no-store, no-cache, must-revalidate, post-check=0, pre-check=0'] - connection: [keep-alive] - content-type: [application/json; charset=utf-8] - date: ['Fri, 30 May 2014 21:24:05 GMT'] - expires: ['Thu, 19 Nov 1981 08:52:00 GMT'] - pragma: [no-cache] - server: [nginx] - set-cookie: [symfony=upd2vdje0asf1ajb62u9av5c53; path=/] - transfer-encoding: [chunked] - x-powered-by: [PHP/5.5.10-1+deb.sury.org~precise+1] - status: {code: 201, message: Created} -version: 1 diff --git a/fixtures/vcr_cassettes/post_prescan_report_404.yaml b/fixtures/vcr_cassettes/post_prescan_report_404.yaml deleted file mode 100644 index a7fec10..0000000 --- a/fixtures/vcr_cassettes/post_prescan_report_404.yaml +++ /dev/null @@ -1,29 +0,0 @@ -interactions: -- request: - body: '{"start_time": 1400026546}' - headers: - Accept: ['*/*'] - Accept-Encoding: ['gzip, deflate, compress'] - Content-Length: ['26'] - Content-Type: [application/json] - User-Agent: [python-requests/2.2.1 CPython/2.7.6 Darwin/13.2.0] - method: POST - uri: http://localhost:8003/api/fixity/90cf0850-f5d2-4023-95e2-0e2b7a1e1b8e - response: - body: - string: !!binary | - H4sIAAAAAAAAA6tWykxRslIytrRQqgUAb5t46QwAAAA= - headers: - cache-control: ['no-store, no-cache, must-revalidate, post-check=0, pre-check=0'] - connection: [keep-alive] - content-encoding: [gzip] - content-type: [application/json; charset=utf-8] - date: ['Fri, 30 May 2014 21:46:33 GMT'] - expires: ['Thu, 19 Nov 1981 08:52:00 GMT'] - pragma: [no-cache] - server: [nginx] - set-cookie: [symfony=6roafepl51oosibvcsrqi2bd54; path=/] - transfer-encoding: [chunked] - x-powered-by: [PHP/5.5.10-1+deb.sury.org~precise+1] - status: {code: 404, message: Not Found} -version: 1 diff --git a/fixtures/vcr_cassettes/post_prescan_report_500.yaml b/fixtures/vcr_cassettes/post_prescan_report_500.yaml deleted file mode 100644 index a25914f..0000000 --- a/fixtures/vcr_cassettes/post_prescan_report_500.yaml +++ /dev/null @@ -1,26 +0,0 @@ -interactions: -- request: - body: '{"start_time": 1400026546}' - headers: - Accept: ['*/*'] - Accept-Encoding: ['gzip, deflate, compress'] - Content-Length: ['26'] - Content-Type: [application/json] - User-Agent: [python-requests/2.2.1 CPython/2.7.6 Darwin/13.2.0] - method: POST - uri: http://localhost:8003/api/fixity/90cf0850-f5d2-4023-95e2-0e2b7a1e1b8e - response: - body: {string: !!python/unicode '{"id":"396"}'} - headers: - cache-control: ['no-store, no-cache, must-revalidate, post-check=0, pre-check=0'] - connection: [keep-alive] - content-type: [application/json; charset=utf-8] - date: ['Fri, 30 May 2014 21:34:16 GMT'] - expires: ['Thu, 19 Nov 1981 08:52:00 GMT'] - pragma: [no-cache] - server: [nginx] - set-cookie: [symfony=satff9f2c30449i2no38lu9nq4; path=/] - transfer-encoding: [chunked] - x-powered-by: [PHP/5.5.10-1+deb.sury.org~precise+1] - status: {code: 500, message: INTERNAL SERVER ERROR} -version: 1 diff --git a/fixtures/vcr_cassettes/single_aip.yaml b/fixtures/vcr_cassettes/single_aip.yaml deleted file mode 100644 index 95eb394..0000000 --- a/fixtures/vcr_cassettes/single_aip.yaml +++ /dev/null @@ -1,25 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: ['*/*'] - Accept-Encoding: ['gzip, deflate, compress'] - User-Agent: [python-requests/2.2.1 CPython/2.7.3 Linux/3.2.0-61-generic] - method: GET - uri: http://localhost:8000/api/v2/file/a7f2a05b-0fdf-42f1-a46c-4522a831cf17/?username=test&api_key=dfe83300db5f05f63157f772820bb028bd4d0e27 - response: - body: {string: !!python/unicode '{"current_full_path": "/var/archivematica/sharedDirectory/www/AIPsStore/a7f2/a05b/0fdf/42f1/a46c/4522/a831/cf17/Unicode-a7f2a05b-0fdf-42f1-a46c-4522a831cf17.7z", - "current_location": "/api/v2/location/0b82f734-763a-453c-979d-0a14cf0a250c/", - "current_path": "a7f2/a05b/0fdf/42f1/a46c/4522/a831/cf17/Unicode-a7f2a05b-0fdf-42f1-a46c-4522a831cf17.7z", - "origin_pipeline": "/api/v2/pipeline/b1cb2ba4-bf69-49a7-8aee-e472321d4dc7/", - "package_type": "AIP", "resource_uri": "/api/v2/file/a7f2a05b-0fdf-42f1-a46c-4522a831cf17/", - "size": 3506333, "status": "UPLOADED", "uuid": "a7f2a05b-0fdf-42f1-a46c-4522a831cf17"}'} - headers: - cache-control: [no-cache] - content-type: [application/json] - date: ['Thu, 15 May 2014 20:56:29 GMT'] - server: [WSGIServer/0.1 Python/2.7.3] - vary: ['Accept, Cookie'] - x-frame-options: [SAMEORIGIN] - status: {code: 200, message: OK} -version: 1 diff --git a/fixtures/vcr_cassettes/single_aip_404.yaml b/fixtures/vcr_cassettes/single_aip_404.yaml deleted file mode 100644 index a5ee03f..0000000 --- a/fixtures/vcr_cassettes/single_aip_404.yaml +++ /dev/null @@ -1,19 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: ['*/*'] - Accept-Encoding: ['gzip, deflate, compress'] - User-Agent: [python-requests/2.2.1 CPython/2.7.3 Linux/3.2.0-61-generic] - method: GET - uri: http://localhost:8000/api/v2/file/ba31d9b8-5baa-4d62-839e-cf71497d4acf/?username=test&api_key=dfe83300db5f05f63157f772820bb028bd4d0e27 - response: - body: {string: !!python/unicode ''} - headers: - content-type: [text/html; charset=utf-8] - date: ['Thu, 15 May 2014 21:51:10 GMT'] - server: [WSGIServer/0.1 Python/2.7.3] - vary: ['Accept, Cookie'] - x-frame-options: [SAMEORIGIN] - status: {code: 404, message: NOT FOUND} -version: 1 diff --git a/fixtures/vcr_cassettes/single_aip_500.yaml b/fixtures/vcr_cassettes/single_aip_500.yaml deleted file mode 100644 index c1b661e..0000000 --- a/fixtures/vcr_cassettes/single_aip_500.yaml +++ /dev/null @@ -1,43 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: ['*/*'] - Accept-Encoding: ['gzip, deflate, compress'] - User-Agent: [python-requests/2.2.1 CPython/2.7.3 Linux/3.2.0-61-generic] - method: GET - uri: http://localhost:8000/api/v2/file/a7f2a05b-0fdf-42f1-a46c-4522a831cf17/?username=test&api_key=dfe83300db5f05f63157f772820bb028bd4d0e27 - response: - body: {string: !!python/unicode '{"error_message": "no such column: locations_package.misc_attributes", - "traceback": "Traceback (most recent call last):\n\n File \"/home/mistydemeo/Envs/storage-service/local/lib/python2.7/site-packages/tastypie/resources.py\", - line 217, in wrapper\n response = callback(request, *args, **kwargs)\n\n File - \"/home/mistydemeo/Envs/storage-service/local/lib/python2.7/site-packages/tastypie/resources.py\", - line 468, in dispatch_detail\n return self.dispatch(''detail'', request, - **kwargs)\n\n File \"/home/mistydemeo/Envs/storage-service/local/lib/python2.7/site-packages/tastypie/resources.py\", - line 491, in dispatch\n response = method(request, **kwargs)\n\n File - \"/home/mistydemeo/Envs/storage-service/local/lib/python2.7/site-packages/tastypie/resources.py\", - line 1328, in get_detail\n obj = self.cached_obj_get(bundle=basic_bundle, - **self.remove_api_resource_names(kwargs))\n\n File \"/home/mistydemeo/Envs/storage-service/local/lib/python2.7/site-packages/tastypie/resources.py\", - line 1146, in cached_obj_get\n cached_bundle = self.obj_get(bundle=bundle, - **kwargs)\n\n File \"/home/mistydemeo/Envs/storage-service/local/lib/python2.7/site-packages/tastypie/resources.py\", - line 2128, in obj_get\n if len(object_list) <= 0:\n\n File \"/home/mistydemeo/Envs/storage-service/local/lib/python2.7/site-packages/django/db/models/query.py\", - line 106, in __len__\n self._result_cache = list(self.iterator())\n\n File - \"/home/mistydemeo/Envs/storage-service/local/lib/python2.7/site-packages/django/db/models/query.py\", - line 317, in iterator\n for row in compiler.results_iter():\n\n File \"/home/mistydemeo/Envs/storage-service/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py\", - line 775, in results_iter\n for rows in self.execute_sql(MULTI):\n\n File - \"/home/mistydemeo/Envs/storage-service/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py\", - line 840, in execute_sql\n cursor.execute(sql, params)\n\n File \"/home/mistydemeo/Envs/storage-service/local/lib/python2.7/site-packages/django/db/backends/util.py\", - line 41, in execute\n return self.cursor.execute(sql, params)\n\n File - \"/home/mistydemeo/Envs/storage-service/local/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py\", - line 366, in execute\n six.reraise(utils.DatabaseError, utils.DatabaseError(*tuple(e.args)), - sys.exc_info()[2])\n\n File \"/home/mistydemeo/Envs/storage-service/local/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py\", - line 362, in execute\n return Database.Cursor.execute(self, query, params)\n\nDatabaseError: - no such column: locations_package.misc_attributes\n"}'} - headers: - content-type: [application/json] - date: ['Thu, 15 May 2014 21:43:12 GMT'] - server: [WSGIServer/0.1 Python/2.7.3] - vary: [Cookie] - x-frame-options: [SAMEORIGIN] - status: {code: 500, message: INTERNAL SERVER ERROR} -version: 1 diff --git a/fixtures/vcr_cassettes/single_aip_504.yaml b/fixtures/vcr_cassettes/single_aip_504.yaml deleted file mode 100644 index 8e3dcdc..0000000 --- a/fixtures/vcr_cassettes/single_aip_504.yaml +++ /dev/null @@ -1,20 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: ['*/*'] - Accept-Encoding: ['gzip, deflate, compress'] - User-Agent: [python-requests/2.2.1 CPython/2.7.7 Darwin/13.2.0] - method: GET - uri: http://localhost:8000/api/v2/file/a7f2a05b-0fdf-42f1-a46c-4522a831cf17/?username=test&api_key=dfe83300db5f05f63157f772820bb028bd4d0e27 - response: - body: {string: !!python/unicode "\r\n504 Gateway Time-out\r\n\r\n

504 Gateway Time-out

\r\n
nginx/1.1.19
\r\n\r\n\r\n"} - headers: - connection: [keep-alive] - content-length: ['183'] - content-type: [text/html] - date: ['Tue, 10 Jun 2014 18:00:29 GMT'] - server: [nginx/1.1.19] - status: {code: 504, message: Gateway Time-out} -version: 1 diff --git a/fixtures/vcr_cassettes/single_aip_bad_auth.yaml b/fixtures/vcr_cassettes/single_aip_bad_auth.yaml deleted file mode 100644 index 62adcd6..0000000 --- a/fixtures/vcr_cassettes/single_aip_bad_auth.yaml +++ /dev/null @@ -1,22 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: ['*/*'] - Accept-Encoding: ['gzip, deflate, compress'] - User-Agent: [python-requests/2.2.1 CPython/3.5.1 Linux/4.5.4-1-ARCH] - method: GET - uri: http://localhost:8000/api/v2/file/a7f2a05b-0fdf-42f1-a46c-4522a831cf17/?username=test&api_key=bad_key - response: - body: {string: ''} - headers: - Connection: [keep-alive] - Content-Type: [text/html; charset=utf-8] - Date: ['Fri, 27 May 2016 18:10:39 GMT'] - Server: [nginx] - Transfer-Encoding: [chunked] - Vary: [Cookie] - WWW-Authenticate: [Basic Realm="django-tastypie"] - X-Frame-Options: [SAMEORIGIN] - status: {code: 401, message: UNAUTHORIZED} -version: 1 diff --git a/pyproject.toml b/pyproject.toml index 6eac28d..477a828 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -61,7 +61,6 @@ dev = [ "pip-tools", "pytest-cov", "pytest", - "vcrpy", ] [tool.setuptools.dynamic] diff --git a/requirements-dev.txt b/requirements-dev.txt index 711ccfc..e318cd5 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -6,30 +6,26 @@ # build==1.0.3 # via pip-tools -certifi==2023.7.22 +certifi==2023.11.17 # via requests charset-normalizer==3.3.2 # via requests click==8.1.7 # via pip-tools -coverage[toml]==7.3.2 +coverage[toml]==7.3.3 # via # fixity (pyproject.toml) # pytest-cov -exceptiongroup==1.1.3 +exceptiongroup==1.2.0 # via pytest -greenlet==3.0.1 +greenlet==3.0.2 # via sqlalchemy -idna==3.4 - # via - # requests - # yarl -importlib-metadata==6.8.0 +idna==3.6 + # via requests +importlib-metadata==7.0.0 # via build iniconfig==2.0.0 # via pytest -multidict==6.0.4 - # via yarl packaging==23.2 # via # build @@ -46,8 +42,6 @@ pytest==7.4.3 # pytest-cov pytest-cov==4.1.0 # via fixity (pyproject.toml) -pyyaml==6.0.1 - # via vcrpy requests==2.31.0 # via fixity (pyproject.toml) sqlalchemy==2.0.23 @@ -59,25 +53,17 @@ tomli==2.0.1 # pip-tools # pyproject-hooks # pytest -typing-extensions==4.8.0 +typing-extensions==4.9.0 # via sqlalchemy -urllib3==1.26.18 - # via - # requests - # vcrpy -vcrpy==5.1.0 - # via fixity (pyproject.toml) -wheel==0.41.3 +urllib3==2.1.0 + # via requests +wheel==0.42.0 # via pip-tools -wrapt==1.15.0 - # via vcrpy -yarl==1.9.2 - # via vcrpy zipp==3.17.0 # via importlib-metadata # The following packages are considered to be unsafe in a requirements file: pip==23.3.1 # via pip-tools -setuptools==68.2.2 +setuptools==69.0.2 # via pip-tools diff --git a/requirements.txt b/requirements.txt index ccb9231..f1d1b26 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,19 +4,19 @@ # # pip-compile --allow-unsafe --output-file=requirements.txt pyproject.toml # -certifi==2023.7.22 +certifi==2023.11.17 # via requests charset-normalizer==3.3.2 # via requests -greenlet==3.0.1 +greenlet==3.0.2 # via sqlalchemy -idna==3.4 +idna==3.6 # via requests requests==2.31.0 # via fixity (pyproject.toml) sqlalchemy==2.0.23 # via fixity (pyproject.toml) -typing-extensions==4.8.0 +typing-extensions==4.9.0 # via sqlalchemy -urllib3==2.0.7 +urllib3==2.1.0 # via requests diff --git a/tests/test_reporting.py b/tests/test_reporting.py index b3dc8f1..4ac5e42 100644 --- a/tests/test_reporting.py +++ b/tests/test_reporting.py @@ -1,8 +1,9 @@ import os from datetime import datetime +from unittest import mock import pytest -import vcr +import requests from fixity import reporting from fixity.models import AIP @@ -21,8 +22,10 @@ def json_string(filename): return jsonfile.read() -@vcr.use_cassette("fixtures/vcr_cassettes/post_prescan_report.yaml") -def test_posting_prescan_report(): +@mock.patch( + "requests.post", side_effect=[mock.Mock(status_code=201, spec=requests.Response)] +) +def test_posting_prescan_report(_post): aip = "be1074fe-217b-46e0-afec-400ea1a2eb36" start_time = datetime.fromtimestamp(1400022946) result = reporting.post_pre_scan_report(aip, start_time, REPORT_URL) @@ -34,16 +37,20 @@ def test_posting_prescan_report_raises_on_invalid_uuid(): reporting.post_pre_scan_report("foo", None, None) -@vcr.use_cassette("fixtures/vcr_cassettes/post_prescan_report_500.yaml") -def test_posting_prescan_report_raises_on_500(): +@mock.patch( + "requests.post", side_effect=[mock.Mock(status_code=500, spec=requests.Response)] +) +def test_posting_prescan_report_raises_on_500(_post): with pytest.raises(reporting.ReportServiceException): aip = "90cf0850-f5d2-4023-95e2-0e2b7a1e1b8e" start_time = datetime.fromtimestamp(1400022946) reporting.post_pre_scan_report(aip, start_time, REPORT_URL) -@vcr.use_cassette("fixtures/vcr_cassettes/post_prescan_report_404.yaml") -def test_posting_prescan_report_raises_on_404(): +@mock.patch( + "requests.post", side_effect=[mock.Mock(status_code=404, spec=requests.Response)] +) +def test_posting_prescan_report_raises_on_404(_post): with pytest.raises(reporting.ReportServiceException): aip = "90cf0850-f5d2-4023-95e2-0e2b7a1e1b8e" start_time = datetime.fromtimestamp(1400022946) @@ -57,8 +64,10 @@ def test_posting_prescan_report_raises_when_unable_to_connect(): reporting.post_pre_scan_report(aip, start_time, "http://foo") -@vcr.use_cassette("fixtures/vcr_cassettes/post_failed_report.yaml") -def test_posting_success_report(): +@mock.patch( + "requests.post", side_effect=[mock.Mock(status_code=201, spec=requests.Response)] +) +def test_posting_success_report(_post): json_report = json_string("test_failed_report.json") aip = AIP(uuid="ed42aadc-d854-46c6-b455-cd384eef1618") report = Report( @@ -77,8 +86,10 @@ def test_posting_success_report_raises_on_invalid_uuid(): reporting.post_success_report("foo", None, None) -@vcr.use_cassette("fixtures/vcr_cassettes/post_failed_report_500.yaml") -def test_posting_success_report_raises_on_500(): +@mock.patch( + "requests.post", side_effect=[mock.Mock(status_code=500, spec=requests.Response)] +) +def test_posting_success_report_raises_on_500(_post): with pytest.raises(reporting.ReportServiceException): json_report = json_string("test_failed_report.json") aip = AIP(uuid="ed42aadc-d854-46c6-b455-cd384eef1618") @@ -93,8 +104,10 @@ def test_posting_success_report_raises_on_500(): reporting.post_success_report(aip.uuid, report, REPORT_URL) -@vcr.use_cassette("fixtures/vcr_cassettes/post_failed_report_404.yaml") -def test_posting_success_report_raises_on_404(): +@mock.patch( + "requests.post", side_effect=[mock.Mock(status_code=404, spec=requests.Response)] +) +def test_posting_success_report_raises_on_404(_post): with pytest.raises(reporting.ReportServiceException): json_report = json_string("test_failed_report.json") aip = AIP(uuid="ed42aadc-d854-46c6-b455-cd384eef1618") diff --git a/tests/test_storage_service.py b/tests/test_storage_service.py index 16cc4a7..c48e850 100644 --- a/tests/test_storage_service.py +++ b/tests/test_storage_service.py @@ -1,7 +1,8 @@ import json +from unittest import mock import pytest -import vcr +import requests from fixity import storage_service from fixity.models import Session @@ -17,8 +18,21 @@ # Single AIP -@vcr.use_cassette("fixtures/vcr_cassettes/single_aip.yaml") -def test_get_single_aip(): +@mock.patch( + "requests.get", + side_effect=[ + mock.Mock( + **{ + "status_code": 200, + "json.return_value": { + "uuid": "a7f2a05b-0fdf-42f1-a46c-4522a831cf17", + }, + }, + spec=requests.Response, + ) + ], +) +def test_get_single_aip(_get): aip_uuid = "a7f2a05b-0fdf-42f1-a46c-4522a831cf17" aip = storage_service.get_single_aip( aip_uuid, STORAGE_SERVICE_URL, STORAGE_SERVICE_USER, STORAGE_SERVICE_KEY @@ -27,8 +41,10 @@ def test_get_single_aip(): assert aip["uuid"] == aip_uuid -@vcr.use_cassette("fixtures/vcr_cassettes/single_aip_404.yaml") -def test_single_aip_raises_on_404(): +@mock.patch( + "requests.get", side_effect=[mock.Mock(status_code=404, spec=requests.Response)] +) +def test_single_aip_raises_on_404(_get): with pytest.raises(storage_service.StorageServiceError) as ex: storage_service.get_single_aip( "ba31d9b8-5baa-4d62-839e-cf71497d4acf", @@ -41,8 +57,10 @@ def test_single_aip_raises_on_404(): assert ex.value.report is None -@vcr.use_cassette("fixtures/vcr_cassettes/single_aip_500.yaml") -def test_single_aip_raises_on_500(): +@mock.patch( + "requests.get", side_effect=[mock.Mock(status_code=500, spec=requests.Response)] +) +def test_single_aip_raises_on_500(_get): with pytest.raises(storage_service.StorageServiceError) as ex: storage_service.get_single_aip( "a7f2a05b-0fdf-42f1-a46c-4522a831cf17", @@ -55,8 +73,10 @@ def test_single_aip_raises_on_500(): assert ex.value.report is None -@vcr.use_cassette("fixtures/vcr_cassettes/single_aip_504.yaml") -def test_single_aip_raises_on_504(): +@mock.patch( + "requests.get", side_effect=[mock.Mock(status_code=504, spec=requests.Response)] +) +def test_single_aip_raises_on_504(_get): with pytest.raises(storage_service.StorageServiceError) as ex: storage_service.get_single_aip( "a7f2a05b-0fdf-42f1-a46c-4522a831cf17", @@ -89,8 +109,10 @@ def test_single_aip_raises_with_invalid_url(): assert any(msg in str(ex.value) for msg in error_msgs) -@vcr.use_cassette("fixtures/vcr_cassettes/single_aip_bad_auth.yaml") -def test_single_aip_raises_with_invalid_auth(): +@mock.patch( + "requests.get", side_effect=[mock.Mock(status_code=401, spec=requests.Response)] +) +def test_single_aip_raises_with_invalid_auth(_get): with pytest.raises(storage_service.StorageServiceError) as ex: storage_service.get_single_aip( "a7f2a05b-0fdf-42f1-a46c-4522a831cf17", @@ -105,8 +127,33 @@ def test_single_aip_raises_with_invalid_auth(): # All AIPs -@vcr.use_cassette("fixtures/vcr_cassettes/all_aips.yaml") -def test_get_all_aips(): +@mock.patch( + "requests.get", + side_effect=[ + mock.Mock( + **{ + "status_code": 200, + "json.return_value": { + "meta": {"next": None}, + "objects": [ + { + "package_type": "AIP", + "status": "UPLOADED", + "uuid": "a7f2a05b-0fdf-42f1-a46c-4522a831cf17", + }, + { + "package_type": "AIP", + "status": "UPLOADED", + "uuid": "c8ebb75e-6b7a-46dd-a360-91d3753d7b72", + }, + ], + }, + }, + spec=requests.Response, + ) + ], +) +def test_get_all_aips(_get): aip_uuids = ( "a7f2a05b-0fdf-42f1-a46c-4522a831cf17", "c8ebb75e-6b7a-46dd-a360-91d3753d7b72", @@ -121,8 +168,19 @@ def test_get_all_aips(): assert aip["uuid"] in aip_uuids -@vcr.use_cassette("fixtures/vcr_cassettes/all_aips_uploaded_only.yaml") -def test_get_all_aips_gets_uploaded_aips_only(): +@mock.patch( + "requests.get", + side_effect=[ + mock.Mock( + **{ + "status_code": 200, + "json.return_value": {"meta": {"next": None}, "objects": []}, + }, + spec=requests.Response, + ) + ], +) +def test_get_all_aips_gets_uploaded_aips_only(_get): aips = storage_service.get_all_aips( STORAGE_SERVICE_URL, STORAGE_SERVICE_USER, STORAGE_SERVICE_KEY ) @@ -130,8 +188,10 @@ def test_get_all_aips_gets_uploaded_aips_only(): assert len(non_uploaded) == 0 -@vcr.use_cassette("fixtures/vcr_cassettes/all_aips_500.yaml") -def test_get_all_aips_raises_on_500(): +@mock.patch( + "requests.get", side_effect=[mock.Mock(status_code=500, spec=requests.Response)] +) +def test_get_all_aips_raises_on_500(_get): with pytest.raises(storage_service.StorageServiceError) as ex: storage_service.get_all_aips( STORAGE_SERVICE_URL, STORAGE_SERVICE_USER, STORAGE_SERVICE_KEY @@ -141,8 +201,10 @@ def test_get_all_aips_raises_on_500(): assert ex.value.report is None -@vcr.use_cassette("fixtures/vcr_cassettes/all_aips_504.yaml") -def test_get_all_aips_raises_on_504(): +@mock.patch( + "requests.get", side_effect=[mock.Mock(status_code=504, spec=requests.Response)] +) +def test_get_all_aips_raises_on_504(_get): with pytest.raises(storage_service.StorageServiceError) as ex: storage_service.get_all_aips( STORAGE_SERVICE_URL, STORAGE_SERVICE_USER, STORAGE_SERVICE_KEY @@ -162,8 +224,10 @@ def test_get_all_aips_raises_with_invalid_url(): assert any(msg in str(ex.value) for msg in error_msgs) -@vcr.use_cassette("fixtures/vcr_cassettes/all_aips_bad_auth.yaml") -def test_get_all_aips_raises_with_bad_auth(): +@mock.patch( + "requests.get", side_effect=[mock.Mock(status_code=401, spec=requests.Response)] +) +def test_get_all_aips_raises_with_bad_auth(_get): with pytest.raises(storage_service.StorageServiceError) as ex: storage_service.get_all_aips( STORAGE_SERVICE_URL, STORAGE_SERVICE_USER, "bad_key" @@ -175,8 +239,25 @@ def test_get_all_aips_raises_with_bad_auth(): # Fixity scan -@vcr.use_cassette("fixtures/vcr_cassettes/fixity_success.yaml") -def test_successful_fixity_scan(): +@mock.patch( + "requests.get", + side_effect=[ + mock.Mock( + **{ + "status_code": 200, + "json.return_value": { + "failures": { + "files": {"untracked": [], "changed": [], "missing": []} + }, + "message": "", + "success": True, + }, + }, + spec=requests.Response, + ) + ], +) +def test_successful_fixity_scan(_get): success, report = storage_service.scan_aip( "c8ebb75e-6b7a-46dd-a360-91d3753d7b72", STORAGE_SERVICE_URL, @@ -193,8 +274,32 @@ def test_successful_fixity_scan(): assert len(parsed_report["failures"]["files"][category]) == 0 -@vcr.use_cassette("fixtures/vcr_cassettes/fixity_fail.yaml") -def test_failed_fixity_scan(): +@mock.patch( + "requests.get", + side_effect=[ + mock.Mock( + **{ + "status_code": 200, + "json.return_value": { + "failures": { + "files": { + "untracked": [], + "changed": [ + {"path": "data/objects/oakland03.jp2"}, + {"path": "manifest-sha512.txt"}, + ], + "missing": [], + } + }, + "message": "invalid bag", + "success": False, + }, + }, + spec=requests.Response, + ) + ], +) +def test_failed_fixity_scan(_get): success, report = storage_service.scan_aip( "c8ebb75e-6b7a-46dd-a360-91d3753d7b72", STORAGE_SERVICE_URL, @@ -215,8 +320,10 @@ def test_failed_fixity_scan(): assert len(parsed_report["failures"]["files"][category]) == 0 -@vcr.use_cassette("fixtures/vcr_cassettes/fixity_500.yaml") -def test_fixity_scan_raises_on_500(): +@mock.patch( + "requests.get", side_effect=[mock.Mock(status_code=500, spec=requests.Response)] +) +def test_fixity_scan_raises_on_500(_get): with pytest.raises(storage_service.StorageServiceError) as ex: storage_service.scan_aip( "a7f2a05b-0fdf-42f1-a46c-4522a831cf17", @@ -229,8 +336,10 @@ def test_fixity_scan_raises_on_500(): assert "internal error" in str(ex.value) -@vcr.use_cassette("fixtures/vcr_cassettes/fixity_non_200.yaml") -def test_fixity_scan_raises_on_non_200(): +@mock.patch( + "requests.get", side_effect=[mock.Mock(status_code=504, spec=requests.Response)] +) +def test_fixity_scan_raises_on_non_200(_get): with pytest.raises(storage_service.StorageServiceError) as ex: storage_service.scan_aip( "a7f2a05b-0fdf-42f1-a46c-4522a831cf17", @@ -261,8 +370,10 @@ def test_fixity_scan_raises_on_invalid_url(): assert any(msg in str(ex.value) for msg in error_msgs) -@vcr.use_cassette("fixtures/vcr_cassettes/fixity_bad_auth.yaml") -def test_fixity_scan_raises_with_bad_auth(): +@mock.patch( + "requests.get", side_effect=[mock.Mock(status_code=401, spec=requests.Response)] +) +def test_fixity_scan_raises_with_bad_auth(_get): with pytest.raises(storage_service.StorageServiceError) as ex: storage_service.scan_aip( "a7f2a05b-0fdf-42f1-a46c-4522a831cf17",