aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLorenz Diener <[email protected]>2019-10-12 20:51:29 +0200
committerLorenz Diener <[email protected]>2019-10-12 20:51:29 +0200
commit2e5095f301c62c73f6b839bbbffeda14ab8cd797 (patch)
tree4eceb70b7cbdd3ebd24ab724b1e61cf5f168deee /tests
parente60a3f1892bb685fcbe6ebbc9ed10602c9549028 (diff)
downloadmastodon.py-2e5095f301c62c73f6b839bbbffeda14ab8cd797.tar.gz
Add, document and test nodeinfo api (fixes #199)
Diffstat (limited to 'tests')
-rw-r--r--tests/cassettes/test_nodeinfo.yaml81
-rw-r--r--tests/test_instance.py7
2 files changed, 88 insertions, 0 deletions
diff --git a/tests/cassettes/test_nodeinfo.yaml b/tests/cassettes/test_nodeinfo.yaml
new file mode 100644
index 0000000..38f8d01
--- /dev/null
+++ b/tests/cassettes/test_nodeinfo.yaml
@@ -0,0 +1,81 @@
1interactions:
2- request:
3 body: null
4 headers:
5 Accept: ['*/*']
6 Accept-Encoding: ['gzip, deflate']
7 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
8 Connection: [keep-alive]
9 User-Agent: [python-requests/2.18.4]
10 method: GET
11 uri: http://localhost:3000/.well-known/nodeinfo
12 response:
13 body: {string: '{"links":[{"rel":"http://nodeinfo.diaspora.software/ns/schema/2.0","href":"http://localhost/nodeinfo/2.0"}]}'}
14 headers:
15 Cache-Control: ['max-age=259200, public']
16 Content-Type: [application/json; charset=utf-8]
17 Date: ['Sat, 12 Oct 2019 18:50:31 GMT']
18 ETag: [W/"e1fd8a5cbe12d2ef42c3146d5319c8af"]
19 Referrer-Policy: [strict-origin-when-cross-origin]
20 Transfer-Encoding: [chunked]
21 Vary: ['Accept, Accept-Encoding, Origin']
22 X-Content-Type-Options: [nosniff]
23 X-Download-Options: [noopen]
24 X-Frame-Options: [SAMEORIGIN]
25 X-Permitted-Cross-Domain-Policies: [none]
26 X-Request-Id: [38a2a5fc-0a7e-44f1-bf4d-85c90c39b2bb]
27 X-Runtime: ['0.026451']
28 X-XSS-Protection: [1; mode=block]
29 content-length: ['108']
30 status: {code: 200, message: OK}
31- request:
32 body: null
33 headers:
34 Accept: ['*/*']
35 Accept-Encoding: ['gzip, deflate']
36 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
37 Connection: [keep-alive]
38 User-Agent: [python-requests/2.18.4]
39 method: GET
40 uri: http://localhost/nodeinfo/2.0
41 response:
42 body: {string: "<html>\r\n<head><title>404 Not Found</title></head>\r\n<body bgcolor=\"white\">\r\n<center><h1>404
43 Not Found</h1></center>\r\n<hr><center>nginx/1.14.0 (Ubuntu)</center>\r\n</body>\r\n</html>\r\n"}
44 headers:
45 Connection: [keep-alive]
46 Content-Type: [text/html]
47 Date: ['Sat, 12 Oct 2019 18:50:31 GMT']
48 Server: [nginx/1.14.0 (Ubuntu)]
49 Transfer-Encoding: [chunked]
50 content-length: ['178']
51 status: {code: 404, message: Not Found}
52- request:
53 body: null
54 headers:
55 Accept: ['*/*']
56 Accept-Encoding: ['gzip, deflate']
57 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
58 Connection: [keep-alive]
59 User-Agent: [python-requests/2.18.4]
60 method: GET
61 uri: http://localhost:3000/nodeinfo/2.0
62 response:
63 body: {string: '{"version":"2.0","software":{"name":"mastodon","version":"3.0.1"},"protocols":["activitypub"],"usage":{"users":{"total":3,"activeMonth":3,"activeHalfyear":3},"localPosts":32},"openRegistrations":true}'}
64 headers:
65 Cache-Control: ['max-age=1800, public']
66 Content-Type: [application/json; charset=utf-8]
67 Date: ['Sat, 12 Oct 2019 18:50:31 GMT']
68 ETag: [W/"a09a04c6f9dc121c4b70f446e88a2686"]
69 Referrer-Policy: [strict-origin-when-cross-origin]
70 Transfer-Encoding: [chunked]
71 Vary: ['Accept,Accept-Encoding']
72 X-Content-Type-Options: [nosniff]
73 X-Download-Options: [noopen]
74 X-Frame-Options: [SAMEORIGIN]
75 X-Permitted-Cross-Domain-Policies: [none]
76 X-Request-Id: [5d4c66c1-efad-4b9f-85b0-d67755adb967]
77 X-Runtime: ['0.020737']
78 X-XSS-Protection: [1; mode=block]
79 content-length: ['200']
80 status: {code: 200, message: OK}
81version: 1
diff --git a/tests/test_instance.py b/tests/test_instance.py
index a304585..343af18 100644
--- a/tests/test_instance.py
+++ b/tests/test_instance.py
@@ -36,3 +36,10 @@ def test_emoji(api):
36@pytest.mark.vcr() 36@pytest.mark.vcr()
37def test_health(api): 37def test_health(api):
38 assert api.instance_health() == True 38 assert api.instance_health() == True
39
40@pytest.mark.vcr()
41def test_nodeinfo(api):
42 nodeinfo = api.instance_nodeinfo()
43 assert nodeinfo
44 assert nodeinfo.version == '2.0'
45
Powered by cgit v1.2.3 (git 2.41.0)