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 --- tests/test_constructor.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/test_constructor.py (limited to 'tests/test_constructor.py') 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 From 80b1ce61c91d173829dc4b130a2b5b4fbec76424 Mon Sep 17 00:00:00 2001 From: codl Date: Mon, 27 Nov 2017 17:12:46 +0100 Subject: move test credential files to /tests/ i didnt even realise i put them there whoops --- tests/test_constructor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/test_constructor.py') diff --git a/tests/test_constructor.py b/tests/test_constructor.py index 720f58d..fac3763 100644 --- a/tests/test_constructor.py +++ b/tests/test_constructor.py @@ -4,8 +4,8 @@ from mastodon.Mastodon import MastodonIllegalArgumentError def test_constructor_from_filenames(): api = Mastodon( - 'client.credentials', - access_token = 'access.credentials') + 'tests/client.credentials', + access_token = 'tests/access.credentials') assert api.client_id == 'foo' assert api.client_secret == 'bar' assert api.access_token == 'baz' -- cgit v1.2.3 From e8d10795621730ffdab5be67c913d68e5d9abe07 Mon Sep 17 00:00:00 2001 From: codl Date: Mon, 27 Nov 2017 17:47:15 +0100 Subject: constructor tests: create credential files at runtime --- tests/test_constructor.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'tests/test_constructor.py') diff --git a/tests/test_constructor.py b/tests/test_constructor.py index fac3763..a599df6 100644 --- a/tests/test_constructor.py +++ b/tests/test_constructor.py @@ -2,10 +2,14 @@ import pytest from mastodon import Mastodon from mastodon.Mastodon import MastodonIllegalArgumentError -def test_constructor_from_filenames(): +def test_constructor_from_filenames(tmpdir): + client = tmpdir.join('client') + client.write_text('foo\nbar\n', 'UTF-8') + access = tmpdir.join('access') + access.write_text('baz\n', 'UTF-8') api = Mastodon( - 'tests/client.credentials', - access_token = 'tests/access.credentials') + str(client), + access_token = str(access)) assert api.client_id == 'foo' assert api.client_secret == 'bar' assert api.access_token == 'baz' -- cgit v1.2.3 From 8c9dcbe8710a425abee860affbd8951cf19609e1 Mon Sep 17 00:00:00 2001 From: codl Date: Mon, 27 Nov 2017 20:51:12 +0100 Subject: shouting!!!!!! ahhh python 2 is bad --- tests/test_constructor.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/test_constructor.py') diff --git a/tests/test_constructor.py b/tests/test_constructor.py index a599df6..cdeb962 100644 --- a/tests/test_constructor.py +++ b/tests/test_constructor.py @@ -4,12 +4,12 @@ from mastodon.Mastodon import MastodonIllegalArgumentError def test_constructor_from_filenames(tmpdir): client = tmpdir.join('client') - client.write_text('foo\nbar\n', 'UTF-8') + client.write_text(u'foo\nbar\n', 'UTF-8') access = tmpdir.join('access') - access.write_text('baz\n', 'UTF-8') + access.write_text(u'baz\n', 'UTF-8') api = Mastodon( str(client), - access_token = str(access)) + access_token=str(access)) assert api.client_id == 'foo' assert api.client_secret == 'bar' assert api.access_token == 'baz' -- cgit v1.2.3