From 1f36deb11950a627b52a587fc3ec30c37f9bb456 Mon Sep 17 00:00:00 2001 From: Lorenz Diener Date: Sat, 12 Oct 2019 22:05:35 +0200 Subject: Add, test and document profile directory API (fixes #188) --- tests/cassettes/test_directory.yaml | 29 +++++++++++++++++++++++++++++ tests/setup.sql | 6 ++++-- tests/test_instance.py | 9 ++++++++- 3 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 tests/cassettes/test_directory.yaml (limited to 'tests') diff --git a/tests/cassettes/test_directory.yaml b/tests/cassettes/test_directory.yaml new file mode 100644 index 0000000..6c478e3 --- /dev/null +++ b/tests/cassettes/test_directory.yaml @@ -0,0 +1,29 @@ +interactions: +- request: + body: null + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + User-Agent: [python-requests/2.18.4] + method: GET + uri: http://localhost:3000/api/v1/directory + response: + body: {string: '[{"id":"1234567890123457","username":"mastodonpy_test_2","acct":"mastodonpy_test_2","display_name":"","locked":true,"bot":false,"created_at":"2019-06-22T23:11:52.445Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test_2","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"last_status_at":null,"emojis":[],"fields":[]}]'} + headers: + Cache-Control: ['no-cache, no-store'] + Content-Type: [application/json; charset=utf-8] + Referrer-Policy: [strict-origin-when-cross-origin] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Download-Options: [noopen] + X-Frame-Options: [SAMEORIGIN] + X-Permitted-Cross-Domain-Policies: [none] + X-Request-Id: [fedf048d-8ed4-4185-bcb4-11384f0db697] + X-Runtime: ['0.141196'] + X-XSS-Protection: [1; mode=block] + content-length: ['597'] + status: {code: 200, message: OK} +version: 1 diff --git a/tests/setup.sql b/tests/setup.sql index 74b1d80..0230655 100644 --- a/tests/setup.sql +++ b/tests/setup.sql @@ -46,13 +46,15 @@ INSERT INTO accounts ( username, locked, created_at, - updated_at + updated_at, + discoverable ) VALUES ( 1234567890123457, 'mastodonpy_test_2', 't', now(), - now() + now(), + t ); INSERT INTO users ( diff --git a/tests/test_instance.py b/tests/test_instance.py index e7dee1f..2762ecb 100644 --- a/tests/test_instance.py +++ b/tests/test_instance.py @@ -43,8 +43,15 @@ 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() + assert directory + assert isinstance(directory, list) + assert len(directory) > 0 + + -- cgit v1.2.3