From ee802d39d0873a15a26ebca9110a55bd27b696d7 Mon Sep 17 00:00:00 2001 From: codl Date: Mon, 27 Nov 2017 15:18:18 +0100 Subject: add tests for constructor --- access.credentials | 1 + client.credentials | 2 ++ tests/test_constructor.py | 21 +++++++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 access.credentials create mode 100644 client.credentials create mode 100644 tests/test_constructor.py diff --git a/access.credentials b/access.credentials new file mode 100644 index 0000000..7601807 --- /dev/null +++ b/access.credentials @@ -0,0 +1 @@ +baz diff --git a/client.credentials b/client.credentials new file mode 100644 index 0000000..3bd1f0e --- /dev/null +++ b/client.credentials @@ -0,0 +1,2 @@ +foo +bar diff --git a/tests/test_constructor.py b/tests/test_constructor.py new file mode 100644 index 0000000..720f58d --- /dev/null +++ b/tests/test_constructor.py @@ -0,0 +1,21 @@ +import pytest +from mastodon import Mastodon +from mastodon.Mastodon import MastodonIllegalArgumentError + +def test_constructor_from_filenames(): + api = Mastodon( + 'client.credentials', + access_token = 'access.credentials') + assert api.client_id == 'foo' + assert api.client_secret == 'bar' + assert api.access_token == 'baz' + +def test_constructor_illegal_ratelimit(): + with pytest.raises(MastodonIllegalArgumentError): + api = Mastodon( + 'foo', client_secret='bar', + ratelimit_method='baz') + +def test_constructor_missing_client_secret(): + with pytest.raises(MastodonIllegalArgumentError): + api = Mastodon('foo') -- cgit v1.2.3