From 00a96c5e9584bcd768d51372fbc4ccd866432771 Mon Sep 17 00:00:00 2001 From: halcy Date: Thu, 24 Nov 2022 22:56:49 +0200 Subject: Add trending APIs --- tests/cassettes/test_trending_links.yaml | 60 ++++++++++++++ tests/cassettes/test_trending_statuses.yaml | 60 ++++++++++++++ tests/cassettes/test_trending_tags.yaml | 118 ++++++++++++++++++++++++++++ tests/cassettes/test_trends.yaml | 60 -------------- tests/test_instance.py | 4 - tests/test_trends.py | 21 +++++ 6 files changed, 259 insertions(+), 64 deletions(-) create mode 100644 tests/cassettes/test_trending_links.yaml create mode 100644 tests/cassettes/test_trending_statuses.yaml create mode 100644 tests/cassettes/test_trending_tags.yaml delete mode 100644 tests/cassettes/test_trends.yaml create mode 100644 tests/test_trends.py (limited to 'tests') diff --git a/tests/cassettes/test_trending_links.yaml b/tests/cassettes/test_trending_links.yaml new file mode 100644 index 0000000..3d54b25 --- /dev/null +++ b/tests/cassettes/test_trending_links.yaml @@ -0,0 +1,60 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Authorization: + - Bearer __MASTODON_PY_TEST_ACCESS_TOKEN + Connection: + - keep-alive + User-Agent: + - tests/v311 + method: GET + uri: http://localhost:3000/api/v1/trends/links + response: + body: + string: '[]' + headers: + Cache-Control: + - no-store + Content-Security-Policy: + - 'base-uri ''none''; default-src ''none''; frame-ancestors ''none''; font-src + ''self'' http://localhost:3000; img-src ''self'' https: data: blob: http://localhost:3000; + style-src ''self'' http://localhost:3000 ''nonce-7UiLUEyJEVY9JgarYKBdCg==''; + media-src ''self'' https: data: http://localhost:3000; frame-src ''self'' + https:; manifest-src ''self'' http://localhost:3000; connect-src ''self'' + data: blob: http://localhost:3000 http://localhost:3000 ws://localhost:4000 + ws://localhost:3035 http://localhost:3035; script-src ''self'' ''unsafe-inline'' + ''unsafe-eval'' http://localhost:3000; child-src ''self'' blob: http://localhost:3000; + worker-src ''self'' blob: http://localhost:3000' + Content-Type: + - application/json; charset=utf-8 + ETag: + - W/"4f53cda18c2baa0c0354bb5f9a3ecbe5" + Referrer-Policy: + - strict-origin-when-cross-origin + Transfer-Encoding: + - chunked + Vary: + - Accept, Origin + X-Content-Type-Options: + - nosniff + X-Download-Options: + - noopen + X-Frame-Options: + - SAMEORIGIN + X-Permitted-Cross-Domain-Policies: + - none + X-Request-Id: + - 623f9c94-2540-4c4f-b0ae-1c3db0b9ca35 + X-Runtime: + - '0.016081' + X-XSS-Protection: + - 1; mode=block + status: + code: 200 + message: OK +version: 1 diff --git a/tests/cassettes/test_trending_statuses.yaml b/tests/cassettes/test_trending_statuses.yaml new file mode 100644 index 0000000..493555d --- /dev/null +++ b/tests/cassettes/test_trending_statuses.yaml @@ -0,0 +1,60 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Authorization: + - Bearer __MASTODON_PY_TEST_ACCESS_TOKEN + Connection: + - keep-alive + User-Agent: + - tests/v311 + method: GET + uri: http://localhost:3000/api/v1/trends/statuses + response: + body: + string: '[]' + headers: + Cache-Control: + - no-store + Content-Security-Policy: + - 'base-uri ''none''; default-src ''none''; frame-ancestors ''none''; font-src + ''self'' http://localhost:3000; img-src ''self'' https: data: blob: http://localhost:3000; + style-src ''self'' http://localhost:3000 ''nonce-Qp9U6bbMsEloa3BOJP+ApA==''; + media-src ''self'' https: data: http://localhost:3000; frame-src ''self'' + https:; manifest-src ''self'' http://localhost:3000; connect-src ''self'' + data: blob: http://localhost:3000 http://localhost:3000 ws://localhost:4000 + ws://localhost:3035 http://localhost:3035; script-src ''self'' ''unsafe-inline'' + ''unsafe-eval'' http://localhost:3000; child-src ''self'' blob: http://localhost:3000; + worker-src ''self'' blob: http://localhost:3000' + Content-Type: + - application/json; charset=utf-8 + ETag: + - W/"4f53cda18c2baa0c0354bb5f9a3ecbe5" + Referrer-Policy: + - strict-origin-when-cross-origin + Transfer-Encoding: + - chunked + Vary: + - Accept, Origin + X-Content-Type-Options: + - nosniff + X-Download-Options: + - noopen + X-Frame-Options: + - SAMEORIGIN + X-Permitted-Cross-Domain-Policies: + - none + X-Request-Id: + - 9b65a082-dbab-436e-9544-9d3ceae169b0 + X-Runtime: + - '0.022649' + X-XSS-Protection: + - 1; mode=block + status: + code: 200 + message: OK +version: 1 diff --git a/tests/cassettes/test_trending_tags.yaml b/tests/cassettes/test_trending_tags.yaml new file mode 100644 index 0000000..583aeda --- /dev/null +++ b/tests/cassettes/test_trending_tags.yaml @@ -0,0 +1,118 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Authorization: + - Bearer __MASTODON_PY_TEST_ACCESS_TOKEN + Connection: + - keep-alive + User-Agent: + - tests/v311 + method: GET + uri: http://localhost:3000/api/v1/trends/tags + response: + body: + string: '[]' + headers: + Cache-Control: + - no-store + Content-Security-Policy: + - 'base-uri ''none''; default-src ''none''; frame-ancestors ''none''; font-src + ''self'' http://localhost:3000; img-src ''self'' https: data: blob: http://localhost:3000; + style-src ''self'' http://localhost:3000 ''nonce-x84HIusoB0oMG/yq6Q4NDg==''; + media-src ''self'' https: data: http://localhost:3000; frame-src ''self'' + https:; manifest-src ''self'' http://localhost:3000; connect-src ''self'' + data: blob: http://localhost:3000 http://localhost:3000 ws://localhost:4000 + ws://localhost:3035 http://localhost:3035; script-src ''self'' ''unsafe-inline'' + ''unsafe-eval'' http://localhost:3000; child-src ''self'' blob: http://localhost:3000; + worker-src ''self'' blob: http://localhost:3000' + Content-Type: + - application/json; charset=utf-8 + ETag: + - W/"4f53cda18c2baa0c0354bb5f9a3ecbe5" + Referrer-Policy: + - strict-origin-when-cross-origin + Transfer-Encoding: + - chunked + Vary: + - Accept, Origin + X-Content-Type-Options: + - nosniff + X-Download-Options: + - noopen + X-Frame-Options: + - SAMEORIGIN + X-Permitted-Cross-Domain-Policies: + - none + X-Request-Id: + - e26034bb-bfdb-4f3a-bbef-9d2e51f88c14 + X-Runtime: + - '0.029510' + X-XSS-Protection: + - 1; mode=block + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Authorization: + - Bearer __MASTODON_PY_TEST_ACCESS_TOKEN + Connection: + - keep-alive + User-Agent: + - tests/v311 + method: GET + uri: http://localhost:3000/api/v1/trends/tags + response: + body: + string: '[]' + headers: + Cache-Control: + - no-store + Content-Security-Policy: + - 'base-uri ''none''; default-src ''none''; frame-ancestors ''none''; font-src + ''self'' http://localhost:3000; img-src ''self'' https: data: blob: http://localhost:3000; + style-src ''self'' http://localhost:3000 ''nonce-mRWh2zKUzi/z+WYqVSZD1g==''; + media-src ''self'' https: data: http://localhost:3000; frame-src ''self'' + https:; manifest-src ''self'' http://localhost:3000; connect-src ''self'' + data: blob: http://localhost:3000 http://localhost:3000 ws://localhost:4000 + ws://localhost:3035 http://localhost:3035; script-src ''self'' ''unsafe-inline'' + ''unsafe-eval'' http://localhost:3000; child-src ''self'' blob: http://localhost:3000; + worker-src ''self'' blob: http://localhost:3000' + Content-Type: + - application/json; charset=utf-8 + ETag: + - W/"4f53cda18c2baa0c0354bb5f9a3ecbe5" + Referrer-Policy: + - strict-origin-when-cross-origin + Transfer-Encoding: + - chunked + Vary: + - Accept, Origin + X-Content-Type-Options: + - nosniff + X-Download-Options: + - noopen + X-Frame-Options: + - SAMEORIGIN + X-Permitted-Cross-Domain-Policies: + - none + X-Request-Id: + - c1cc20bc-a0b0-4ffa-bd72-686a094e1da0 + X-Runtime: + - '0.015007' + X-XSS-Protection: + - 1; mode=block + status: + code: 200 + message: OK +version: 1 diff --git a/tests/cassettes/test_trends.yaml b/tests/cassettes/test_trends.yaml deleted file mode 100644 index 41cf4af..0000000 --- a/tests/cassettes/test_trends.yaml +++ /dev/null @@ -1,60 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Authorization: - - Bearer __MASTODON_PY_TEST_ACCESS_TOKEN - Connection: - - keep-alive - User-Agent: - - tests/v311 - method: GET - uri: http://localhost:3000/api/v1/trends - response: - body: - string: '[]' - headers: - Cache-Control: - - no-store - Content-Security-Policy: - - 'base-uri ''none''; default-src ''none''; frame-ancestors ''none''; font-src - ''self'' http://localhost:3000; img-src ''self'' https: data: blob: http://localhost:3000; - style-src ''self'' http://localhost:3000 ''nonce-wweJU6CNiZOq8p6GOgvKMg==''; - media-src ''self'' https: data: http://localhost:3000; frame-src ''self'' - https:; manifest-src ''self'' http://localhost:3000; connect-src ''self'' - data: blob: http://localhost:3000 http://localhost:3000 ws://localhost:4000 - ws://localhost:3035 http://localhost:3035; script-src ''self'' ''unsafe-inline'' - ''unsafe-eval'' http://localhost:3000; child-src ''self'' blob: http://localhost:3000; - worker-src ''self'' blob: http://localhost:3000' - Content-Type: - - application/json; charset=utf-8 - ETag: - - W/"4f53cda18c2baa0c0354bb5f9a3ecbe5" - Referrer-Policy: - - strict-origin-when-cross-origin - Transfer-Encoding: - - chunked - Vary: - - Accept, Origin - X-Content-Type-Options: - - nosniff - X-Download-Options: - - noopen - X-Frame-Options: - - SAMEORIGIN - X-Permitted-Cross-Domain-Policies: - - none - X-Request-Id: - - 04d49bc9-1ad7-48de-a189-e93e527942e0 - X-Runtime: - - '0.010606' - X-XSS-Protection: - - 1; mode=block - status: - code: 200 - message: OK -version: 1 diff --git a/tests/test_instance.py b/tests/test_instance.py index e25a686..99a3534 100644 --- a/tests/test_instance.py +++ b/tests/test_instance.py @@ -62,10 +62,6 @@ def test_nodeinfo(api): assert nodeinfo assert nodeinfo.version == '2.0' -@pytest.mark.vcr() -def test_trends(api): - assert isinstance(api.trends(), list) - @pytest.mark.vcr() def test_directory(api): directory = api.directory() diff --git a/tests/test_trends.py b/tests/test_trends.py new file mode 100644 index 0000000..67599d2 --- /dev/null +++ b/tests/test_trends.py @@ -0,0 +1,21 @@ +import pytest +import time +import vcr + + +@pytest.mark.vcr() +def test_trending_tags(api): + tags = api.trending_tags() + assert isinstance(tags, list) + tags = api.trends() + assert isinstance(tags, list) + +@pytest.mark.vcr() +def test_trending_statuses(api): + statuses = api.trending_statuses() + assert isinstance(statuses, list) + +@pytest.mark.vcr() +def test_trending_links(api): + links = api.trending_links() + assert isinstance(links, list) -- cgit v1.2.3