aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLorenz Diener <[email protected]>2018-07-30 23:10:24 +0200
committerLorenz Diener <[email protected]>2018-07-30 23:10:24 +0200
commit8b06b53ed50e41411857181e4881e54823ed661b (patch)
tree8e7a744313bc9fa7a371cd5b0d2f80922229209f /tests
parent2d81e9b2cbd3e3c1abd3a472220c667e89b29f5e (diff)
downloadmastodon.py-8b06b53ed50e41411857181e4881e54823ed661b.tar.gz
Improve filter tests
Diffstat (limited to 'tests')
-rw-r--r--tests/cassettes/test_filter_update.yaml90
-rw-r--r--tests/test_filters.py9
2 files changed, 98 insertions, 1 deletions
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 @@
1interactions:
2- request:
3 body: whole_word=1&irreversible=0&phrase=anime&context%5B%5D=notifications
4 headers:
5 Accept: ['*/*']
6 Accept-Encoding: ['gzip, deflate']
7 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
8 Connection: [keep-alive]
9 Content-Length: ['68']
10 Content-Type: [application/x-www-form-urlencoded]
11 User-Agent: [python-requests/2.18.4]
12 method: POST
13 uri: http://localhost:3000/api/v1/filters
14 response:
15 body: {string: '{"id":27,"phrase":"anime","context":["notifications"],"whole_word":true,"expires_at":null,"irreversible":false}'}
16 headers:
17 Cache-Control: ['max-age=0, private, must-revalidate']
18 Content-Type: [application/json; charset=utf-8]
19 ETag: [W/"f0354e35a12345b991a60a6952b5f2f5"]
20 Referrer-Policy: [strict-origin-when-cross-origin]
21 Transfer-Encoding: [chunked]
22 Vary: ['Accept-Encoding, Origin']
23 X-Content-Type-Options: [nosniff]
24 X-Download-Options: [noopen]
25 X-Frame-Options: [SAMEORIGIN]
26 X-Permitted-Cross-Domain-Policies: [none]
27 X-Request-Id: [80b866be-fcf3-4310-9150-d1bd96f15872]
28 X-Runtime: ['0.040343']
29 X-XSS-Protection: [1; mode=block]
30 content-length: ['111']
31 status: {code: 200, message: OK}
32- request:
33 body: phrase=japanimation
34 headers:
35 Accept: ['*/*']
36 Accept-Encoding: ['gzip, deflate']
37 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
38 Connection: [keep-alive]
39 Content-Length: ['19']
40 Content-Type: [application/x-www-form-urlencoded]
41 User-Agent: [python-requests/2.18.4]
42 method: PUT
43 uri: http://localhost:3000/api/v1/filters/27
44 response:
45 body: {string: '{"id":27,"phrase":"japanimation","context":["notifications"],"whole_word":true,"expires_at":null,"irreversible":false}'}
46 headers:
47 Cache-Control: ['max-age=0, private, must-revalidate']
48 Content-Type: [application/json; charset=utf-8]
49 ETag: [W/"7303cdcc74a1770f54b1eae6044fadea"]
50 Referrer-Policy: [strict-origin-when-cross-origin]
51 Transfer-Encoding: [chunked]
52 Vary: ['Accept-Encoding, Origin']
53 X-Content-Type-Options: [nosniff]
54 X-Download-Options: [noopen]
55 X-Frame-Options: [SAMEORIGIN]
56 X-Permitted-Cross-Domain-Policies: [none]
57 X-Request-Id: [636839a6-6100-4a34-bd54-b5e00b607c78]
58 X-Runtime: ['0.031909']
59 X-XSS-Protection: [1; mode=block]
60 content-length: ['118']
61 status: {code: 200, message: OK}
62- request:
63 body: null
64 headers:
65 Accept: ['*/*']
66 Accept-Encoding: ['gzip, deflate']
67 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
68 Connection: [keep-alive]
69 User-Agent: [python-requests/2.18.4]
70 method: GET
71 uri: http://localhost:3000/api/v1/filters/27
72 response:
73 body: {string: '{"id":27,"phrase":"japanimation","context":["notifications"],"whole_word":true,"expires_at":null,"irreversible":false}'}
74 headers:
75 Cache-Control: ['max-age=0, private, must-revalidate']
76 Content-Type: [application/json; charset=utf-8]
77 ETag: [W/"7303cdcc74a1770f54b1eae6044fadea"]
78 Referrer-Policy: [strict-origin-when-cross-origin]
79 Transfer-Encoding: [chunked]
80 Vary: ['Accept-Encoding, Origin']
81 X-Content-Type-Options: [nosniff]
82 X-Download-Options: [noopen]
83 X-Frame-Options: [SAMEORIGIN]
84 X-Permitted-Cross-Domain-Policies: [none]
85 X-Request-Id: [cc34f6fa-12fa-45d5-930a-e24b682e43ca]
86 X-Runtime: ['0.027439']
87 X-XSS-Protection: [1; mode=block]
88 content-length: ['118']
89 status: {code: 200, message: OK}
90version: 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):
31 assert(keyword_filter == keyword_filter_2) 31 assert(keyword_filter == keyword_filter_2)
32 finally: 32 finally:
33 api.filter_delete(keyword_filter) 33 api.filter_delete(keyword_filter)
34 34
35@pytest.mark.vcr()
36def test_filter_update(api):
37 keyword_filter = api.filter_create("anime", ['notifications'], irreversible = False, whole_word = True, expires_in = None)
38 keyword_filter_2 = api.filter_update(keyword_filter, phrase = "japanimation")
39 keyword_filter = api.filter(keyword_filter.id)
40 assert(keyword_filter.phrase == "japanimation")
41
35@pytest.mark.vcr() 42@pytest.mark.vcr()
36def test_filter_serverside(api, api2): 43def test_filter_serverside(api, api2):
37 api.account_follow(api2.account_verify_credentials()) 44 api.account_follow(api2.account_verify_credentials())
Powered by cgit v1.2.3 (git 2.41.0)