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