From 8b06b53ed50e41411857181e4881e54823ed661b Mon Sep 17 00:00:00 2001 From: Lorenz Diener Date: Mon, 30 Jul 2018 23:10:24 +0200 Subject: Improve filter tests --- tests/cassettes/test_filter_update.yaml | 90 +++++++++++++++++++++++++++++++++ tests/test_filters.py | 9 +++- 2 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 tests/cassettes/test_filter_update.yaml diff --git a/tests/cassettes/test_filter_update.yaml b/tests/cassettes/test_filter_update.yaml new file mode 100644 index 0000000..2e60073 --- /dev/null +++ b/tests/cassettes/test_filter_update.yaml @@ -0,0 +1,90 @@ +interactions: +- request: + body: whole_word=1&irreversible=0&phrase=anime&context%5B%5D=notifications + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + Content-Length: ['68'] + Content-Type: [application/x-www-form-urlencoded] + User-Agent: [python-requests/2.18.4] + method: POST + uri: http://localhost:3000/api/v1/filters + response: + body: {string: '{"id":27,"phrase":"anime","context":["notifications"],"whole_word":true,"expires_at":null,"irreversible":false}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"f0354e35a12345b991a60a6952b5f2f5"] + 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: [80b866be-fcf3-4310-9150-d1bd96f15872] + X-Runtime: ['0.040343'] + X-XSS-Protection: [1; mode=block] + content-length: ['111'] + status: {code: 200, message: OK} +- request: + body: phrase=japanimation + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + Content-Length: ['19'] + Content-Type: [application/x-www-form-urlencoded] + User-Agent: [python-requests/2.18.4] + method: PUT + uri: http://localhost:3000/api/v1/filters/27 + response: + body: {string: '{"id":27,"phrase":"japanimation","context":["notifications"],"whole_word":true,"expires_at":null,"irreversible":false}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"7303cdcc74a1770f54b1eae6044fadea"] + 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: [636839a6-6100-4a34-bd54-b5e00b607c78] + X-Runtime: ['0.031909'] + X-XSS-Protection: [1; mode=block] + content-length: ['118'] + 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: [python-requests/2.18.4] + method: GET + uri: http://localhost:3000/api/v1/filters/27 + response: + body: {string: '{"id":27,"phrase":"japanimation","context":["notifications"],"whole_word":true,"expires_at":null,"irreversible":false}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"7303cdcc74a1770f54b1eae6044fadea"] + 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: [cc34f6fa-12fa-45d5-930a-e24b682e43ca] + X-Runtime: ['0.027439'] + X-XSS-Protection: [1; mode=block] + content-length: ['118'] + status: {code: 200, message: OK} +version: 1 diff --git a/tests/test_filters.py b/tests/test_filters.py index dc39ddb..631cfd1 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -31,7 +31,14 @@ def test_filter_create(api): assert(keyword_filter == keyword_filter_2) finally: api.filter_delete(keyword_filter) - + +@pytest.mark.vcr() +def test_filter_update(api): + keyword_filter = api.filter_create("anime", ['notifications'], irreversible = False, whole_word = True, expires_in = None) + keyword_filter_2 = api.filter_update(keyword_filter, phrase = "japanimation") + keyword_filter = api.filter(keyword_filter.id) + assert(keyword_filter.phrase == "japanimation") + @pytest.mark.vcr() def test_filter_serverside(api, api2): api.account_follow(api2.account_verify_credentials()) -- cgit v1.2.3