From 2b4008981055f990c23bf42bb65f856231436422 Mon Sep 17 00:00:00 2001 From: codl Date: Thu, 30 Nov 2017 01:29:20 +0100 Subject: add tests for domain block methods --- tests/cassettes/test_domain_block_unblock.yaml | 56 ++++++++++++++++++++++++++ tests/cassettes/test_domain_blocks.yaml | 27 +++++++++++++ tests/test_domain_blocks.py | 13 ++++++ 3 files changed, 96 insertions(+) create mode 100644 tests/cassettes/test_domain_block_unblock.yaml create mode 100644 tests/cassettes/test_domain_blocks.yaml create mode 100644 tests/test_domain_blocks.py (limited to 'tests') diff --git a/tests/cassettes/test_domain_block_unblock.yaml b/tests/cassettes/test_domain_block_unblock.yaml new file mode 100644 index 0000000..e60b12b --- /dev/null +++ b/tests/cassettes/test_domain_block_unblock.yaml @@ -0,0 +1,56 @@ +interactions: +- request: + body: domain=example.com + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + Content-Length: ['18'] + Content-Type: [application/x-www-form-urlencoded] + User-Agent: [python-requests/2.18.4] + method: POST + uri: http://localhost:3000/api/v1/domain_blocks + response: + body: {string: '{}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"fe7f6d5b13e22f37fb57de6e31e0ef11"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [cb5c8333-c6bd-41c3-bdfd-d6c974ea7d2b] + X-Runtime: ['0.059619'] + X-XSS-Protection: [1; mode=block] + content-length: ['2'] + status: {code: 200, message: OK} +- request: + body: domain=example.com + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + Content-Length: ['18'] + Content-Type: [application/x-www-form-urlencoded] + User-Agent: [python-requests/2.18.4] + method: DELETE + uri: http://localhost:3000/api/v1/domain_blocks + response: + body: {string: '{}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"fe7f6d5b13e22f37fb57de6e31e0ef11"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [56395cbf-814c-4e57-97fd-2c44592211aa] + X-Runtime: ['0.019281'] + X-XSS-Protection: [1; mode=block] + content-length: ['2'] + status: {code: 200, message: OK} +version: 1 diff --git a/tests/cassettes/test_domain_blocks.yaml b/tests/cassettes/test_domain_blocks.yaml new file mode 100644 index 0000000..2af5f05 --- /dev/null +++ b/tests/cassettes/test_domain_blocks.yaml @@ -0,0 +1,27 @@ +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/domain_blocks + response: + body: {string: '[]'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"4fdefc2aac1c40f3865259d9f3074aec"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [d7fec252-2898-46a1-a538-0e5ecda88fa8] + X-Runtime: ['0.032291'] + X-XSS-Protection: [1; mode=block] + content-length: ['2'] + status: {code: 200, message: OK} +version: 1 diff --git a/tests/test_domain_blocks.py b/tests/test_domain_blocks.py new file mode 100644 index 0000000..c96f7d6 --- /dev/null +++ b/tests/test_domain_blocks.py @@ -0,0 +1,13 @@ +import pytest + + +@pytest.mark.vcr() +def test_domain_blocks(api): + blocks = api.domain_blocks() + assert isinstance(blocks, list) + + +@pytest.mark.vcr() +def test_domain_block_unblock(api): + api.domain_block('example.com') + api.domain_unblock('example.com') -- cgit v1.2.3