From 7d51c0b17efe21f552f5d7f47b276810f9aa0280 Mon Sep 17 00:00:00 2001 From: codl Date: Wed, 29 Nov 2017 23:06:28 +0100 Subject: update test docs --- tests/README.markdown | 4 +-- tests/setup.sql | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/setup_app.sql | 84 --------------------------------------------------- 3 files changed, 86 insertions(+), 86 deletions(-) create mode 100644 tests/setup.sql delete mode 100644 tests/setup_app.sql diff --git a/tests/README.markdown b/tests/README.markdown index ad27a31..5d8d90e 100644 --- a/tests/README.markdown +++ b/tests/README.markdown @@ -24,9 +24,9 @@ This test suite uses [VCR.py][] to record requests to Mastodon and replay them i If you want to add or change tests, you will need a Mastodon development server running on `http://localhost:3000`, with the default `admin` user and default password. -It also needs a test OAuth app to be set up by applying the provided `setup_app.sql` to Mastodon's database: +It also needs a test OAuth app and an additional test user to be set up by applying the provided `setup.sql` to Mastodon's database: - psql -d mastodon_development < tests/setup_app.sql + psql -d mastodon_development < tests/setup.sql Tests that send requests to Mastodon should be marked as needing VCR with the `pytest.mark.vcr` decorator. diff --git a/tests/setup.sql b/tests/setup.sql new file mode 100644 index 0000000..81f1e18 --- /dev/null +++ b/tests/setup.sql @@ -0,0 +1,84 @@ +DELETE FROM oauth_access_tokens WHERE id = 6543210987654321; +DELETE FROM oauth_access_tokens WHERE id = 1234567890123456; +DELETE FROM oauth_applications WHERE id = 1234567890123456; +DELETE FROM users WHERE id = 1234567890123456; +DELETE FROM accounts WHERE id = 1234567890123456; + +INSERT INTO accounts ( + id, + username, + created_at, + updated_at +) VALUES ( + 1234567890123456, + 'mastodonpy_test', + now(), + now() +); + +INSERT INTO users ( + id, + email, + account_id, + created_at, + updated_at, + confirmed_at, + locale +) VALUES ( + 1234567890123456, + 'mastodonpy_test@localhost:3000', + 1234567890123456, + now(), + now(), + now(), + 'ja' -- japanese locale for unicode testing :p +); + + + +INSERT INTO oauth_applications ( + id, + name, + uid, + secret, + redirect_uri, + scopes, + owner_type, + owner_id, + created_at, + updated_at +) VALUES ( + 1234567890123456, + 'Mastodon.py test suite', + '__MASTODON_PY_TEST_CLIENT_ID', + '__MASTODON_PY_TEST_CLIENT_SECRET', + 'urn:ietf:wg:oauth:2.0:oob', + 'read write follow', + 'User', + 1234567890123456, + now(), + now() +); + +INSERT INTO oauth_access_tokens ( + id, + token, + scopes, + application_id, + resource_owner_id, + created_at +) VALUES ( + 1234567890123456, + '__MASTODON_PY_TEST_ACCESS_TOKEN', + 'read write follow', + 1234567890123456, + 1234567890123456, + now() +), ( + 6543210987654321, + '__MASTODON_PY_TEST_ACCESS_TOKEN_2', + 'read write follow', + 1234567890123456, + 1, + now() +); diff --git a/tests/setup_app.sql b/tests/setup_app.sql deleted file mode 100644 index 81f1e18..0000000 --- a/tests/setup_app.sql +++ /dev/null @@ -1,84 +0,0 @@ -DELETE FROM oauth_access_tokens WHERE id = 6543210987654321; -DELETE FROM oauth_access_tokens WHERE id = 1234567890123456; -DELETE FROM oauth_applications WHERE id = 1234567890123456; -DELETE FROM users WHERE id = 1234567890123456; -DELETE FROM accounts WHERE id = 1234567890123456; - -INSERT INTO accounts ( - id, - username, - created_at, - updated_at -) VALUES ( - 1234567890123456, - 'mastodonpy_test', - now(), - now() -); - -INSERT INTO users ( - id, - email, - account_id, - created_at, - updated_at, - confirmed_at, - locale -) VALUES ( - 1234567890123456, - 'mastodonpy_test@localhost:3000', - 1234567890123456, - now(), - now(), - now(), - 'ja' -- japanese locale for unicode testing :p -); - - - -INSERT INTO oauth_applications ( - id, - name, - uid, - secret, - redirect_uri, - scopes, - owner_type, - owner_id, - created_at, - updated_at -) VALUES ( - 1234567890123456, - 'Mastodon.py test suite', - '__MASTODON_PY_TEST_CLIENT_ID', - '__MASTODON_PY_TEST_CLIENT_SECRET', - 'urn:ietf:wg:oauth:2.0:oob', - 'read write follow', - 'User', - 1234567890123456, - now(), - now() -); - -INSERT INTO oauth_access_tokens ( - id, - token, - scopes, - application_id, - resource_owner_id, - created_at -) VALUES ( - 1234567890123456, - '__MASTODON_PY_TEST_ACCESS_TOKEN', - 'read write follow', - 1234567890123456, - 1234567890123456, - now() -), ( - 6543210987654321, - '__MASTODON_PY_TEST_ACCESS_TOKEN_2', - 'read write follow', - 1234567890123456, - 1, - now() -); -- cgit v1.2.3