From 4b60a0d3cfba50319d2a8a47458db9a89a1a4f12 Mon Sep 17 00:00:00 2001 From: codl Date: Mon, 27 Nov 2017 02:25:33 +0100 Subject: add tests for json hooks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit including a failing test for that thing i fixed earlier which isn't in this branch 😓 --- tests/test_hooks.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/test_hooks.py (limited to 'tests/test_hooks.py') diff --git a/tests/test_hooks.py b/tests/test_hooks.py new file mode 100644 index 0000000..fe242a6 --- /dev/null +++ b/tests/test_hooks.py @@ -0,0 +1,28 @@ +from .fixtures import * +from datetime import datetime + +@pytest.mark.vcr() +def test_id_hook(status): + assert isinstance(status['id'], int) + +@pytest.mark.vcr() +def test_id_hook_in_reply_to(mastodon, status): + reply = mastodon.status_post('Reply!', in_reply_to_id=status['id']) + try: + assert isinstance(reply['in_reply_to_id'], int) + assert isinstance(reply['in_reply_to_account_id'], int) + finally: + mastodon.status_delete(reply['id']) + +@pytest.mark.vcr() +def test_id_hook_within_reblog(mastodon, status): + reblog = mastodon.status_reblog(status['id']) + try: + assert isinstance(reblog['reblog']['id'], int) + finally: + mastodon.status_delete(reblog['id']) + + +@pytest.mark.vcr() +def test_date_hook(status): + assert isinstance(status['created_at'], datetime) -- cgit v1.2.3 From 765db0fc8149aad4c103244e013fdd128af8d3d2 Mon Sep 17 00:00:00 2001 From: codl Date: Mon, 27 Nov 2017 04:22:03 +0100 Subject: move fixtures.py to standardized location conftest.py --- tests/test_hooks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_hooks.py') diff --git a/tests/test_hooks.py b/tests/test_hooks.py index fe242a6..132021b 100644 --- a/tests/test_hooks.py +++ b/tests/test_hooks.py @@ -1,4 +1,4 @@ -from .fixtures import * +import pytest from datetime import datetime @pytest.mark.vcr() -- cgit v1.2.3 From 304145f4420180b23e0836a6d11fc0cec0e341bd Mon Sep 17 00:00:00 2001 From: codl Date: Mon, 27 Nov 2017 14:35:02 +0100 Subject: rename mastodon and mastodon_anonymous fixtures to api, api_anonymous it was starting to get confusing --- tests/test_hooks.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tests/test_hooks.py') diff --git a/tests/test_hooks.py b/tests/test_hooks.py index 132021b..b31343c 100644 --- a/tests/test_hooks.py +++ b/tests/test_hooks.py @@ -6,21 +6,21 @@ def test_id_hook(status): assert isinstance(status['id'], int) @pytest.mark.vcr() -def test_id_hook_in_reply_to(mastodon, status): - reply = mastodon.status_post('Reply!', in_reply_to_id=status['id']) +def test_id_hook_in_reply_to(api, status): + reply = api.status_post('Reply!', in_reply_to_id=status['id']) try: assert isinstance(reply['in_reply_to_id'], int) assert isinstance(reply['in_reply_to_account_id'], int) finally: - mastodon.status_delete(reply['id']) + api.status_delete(reply['id']) @pytest.mark.vcr() -def test_id_hook_within_reblog(mastodon, status): - reblog = mastodon.status_reblog(status['id']) +def test_id_hook_within_reblog(api, status): + reblog = api.status_reblog(status['id']) try: assert isinstance(reblog['reblog']['id'], int) finally: - mastodon.status_delete(reblog['id']) + api.status_delete(reblog['id']) @pytest.mark.vcr() -- cgit v1.2.3 From 508d1d2ddd157e02574db1138acda9f3f997f023 Mon Sep 17 00:00:00 2001 From: codl Date: Mon, 27 Nov 2017 20:42:54 +0100 Subject: hooks: mark failing test resolved in upstream as xfail --- tests/test_hooks.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests/test_hooks.py') diff --git a/tests/test_hooks.py b/tests/test_hooks.py index b31343c..905672d 100644 --- a/tests/test_hooks.py +++ b/tests/test_hooks.py @@ -1,10 +1,13 @@ import pytest from datetime import datetime + @pytest.mark.vcr() def test_id_hook(status): assert isinstance(status['id'], int) + +@pytest.mark.xfail(reason='fixed in upstream') @pytest.mark.vcr() def test_id_hook_in_reply_to(api, status): reply = api.status_post('Reply!', in_reply_to_id=status['id']) @@ -14,6 +17,7 @@ def test_id_hook_in_reply_to(api, status): finally: api.status_delete(reply['id']) + @pytest.mark.vcr() def test_id_hook_within_reblog(api, status): reblog = api.status_reblog(status['id']) -- cgit v1.2.3