Commit Graph

179 Commits

Author SHA1 Message Date
Waseem Daher 99edd920c5 tests: Make sure that our subscriptions list properly returns the invite-only bit.
(imported from commit c060c6b350d335d5e94c07314fcfe7c766f2efcd)
2013-02-05 17:24:29 -05:00
Waseem Daher af45236968 tests: Cause existing tests to pass after change to gather_subscriptions.
(imported from commit 3524a5d69d9228810ae863fdea9a9f007a1ca7db)
2013-02-05 17:24:29 -05:00
Luke Faraone ac0dbd0864 Return in_home_view in gather_subscriptions.
This enables us to do client-side filtering on messages by the value of
this setting.

(imported from commit e69a7772dc90c67cb91ea8f630f5b78c902e8fa8)
2013-02-05 15:34:37 -05:00
Luke Faraone e8afaa8b8e Return a dictionary in subscriptions/list instead of a tuple.
This will give us flexibility in the future to add new properties to the
list.

In order to support that, we now do a list comprehension rather than just
returning the gather_subscriptions list in get_stream_colors.

(imported from commit a3c0f749a3320f647440f800105942434da08111)
2013-02-05 15:34:37 -05:00
Luke Faraone 3d25fbce49 Replace calls to json_error to raise JsonableError.
Returning json_error inside an inner function call will result in the error
getting lost.

(imported from commit fd7754b15f7b62fd6e4197fd72ae03d6996a93da)
2013-02-05 15:34:36 -05:00
Luke Faraone 2d4ef59f68 Fix InviteOnlyStreamTest to call public API
Previously we made calls to the JSON api, which means that the API key
was being ignored.

(imported from commit 46d8d0e5ac7926e824f300fd846ec42bc939e2c0)
2013-02-05 15:34:36 -05:00
Leo Franchi 054420fc38 Match .co.uk before .co in linkification
(imported from commit 2461cb4d49eef15431dde30dda646b25dc860a7b)
2013-02-05 13:04:45 -05:00
Jessica McKellar 5221885035 tests: add tests for get_subscribers.
(imported from commit 25ff513dcba72ad04487e6bfd9227457f8e3cc16)
2013-02-05 10:12:04 -05:00
Jessica McKellar a1506779ca tests: Add missing logins in InviteOnlyStreamTest.
This test case was supposed to be making requests as 2 different
users, but was not logging in as each of them and thus used the wrong
credentials.

(imported from commit 0dfdc86fcb385d3d2a721181b2f8075bc39ad723)
2013-02-05 10:12:04 -05:00
Jessica McKellar 1e8b378cd9 tests: update backend tests to reflect subscription page changes.
(imported from commit 29ebd68ce85dda55a658426e35886481833d1c9d)
2013-02-05 10:01:45 -05:00
Leo Franchi 6d30793a02 Add tests for XSS and emails
(imported from commit 9441f65218fa5b102658d0dd48b88fdf826eeef2)
2013-02-01 18:42:27 -05:00
Leo Franchi ea2e816c4c Add tests for auto linkify
(imported from commit 395fc679ffa835f48044fce1e9c1f818581c23c3)
2013-02-01 16:14:29 -05:00
Keegan McAllister 98a7d31374 Add tests for the bold / italic syntax
(imported from commit aaaf87e88d2db8e201d9f98b4e7411cfc56d50c2)
2013-01-31 16:28:57 -05:00
Leo Franchi c7214a7a2c Add test for almost-but-not-quite fence
(imported from commit 26378ffbf33b3d82fe3b1dc5b5afcbc8ffc4ebbb)
2013-01-29 18:02:47 -05:00
Jacob Hurwitz 7c59d41006 Added unit tests for several more methods:
-json/subscriptions/exists
-json/subscriptions/list
-json/subscriptions/add
-json/subscriptions/remove

(imported from commit 95eb5421ac586bea59f749411b54661689946915)
2013-01-29 15:56:16 -05:00
Jacob Hurwitz 09e86903df assertEquals is deprecated in favor of assertEqual
See http://docs.python.org/2/library/unittest.html for details.

(imported from commit 049a4a7e994ff20b8b4fa3b526f197d63118f4c3)
2013-01-29 15:56:16 -05:00
Leo Franchi b157560369 Remove last tests.py dependency on views.py
(imported from commit d667fbfdeb7ec0cf115354cf9a54fd3cdd801b73)
2013-01-28 17:33:08 -05:00
Leo Franchi e249326510 Convert tests to using json api rather than views
(imported from commit 2a997b93e88156e44d47277387641db1ef3b587a)
2013-01-28 16:59:25 -05:00
Leo Franchi 9cc2945c9e Add unit tests for hanging ulists bugdown
(imported from commit 7e225b54d4ab26e4d7cb734fcdbdbe74b7288dd5)
2013-01-25 17:13:13 -05:00
Leo Franchi ba7dcc320c Remove ``` support from code fence
Supporting ``` as a code fence marker complicates the auto-fence
closing, and as per a discussion with Keegan on code-review@, it
is not worth the extra complexity.

(imported from commit 405afb95c4295a02f4677181456caf9d49913ac4)
2013-01-25 17:12:49 -05:00
Leo Franchi 187e8cfa88 Add markdown tests for auto code block ending
(imported from commit 905ce149fd5d601733c2a7e748636c7a66904fbc)
2013-01-25 17:02:57 -05:00
Leo Franchi 556295dd28 Add unit tests for new invite-only streams
(imported from commit 89f19b85a97d4f9a35988d7c7eb29984719523e5)
2013-01-24 17:34:22 -05:00
Tim Abbott 2740f930fe Fix PublicURLTest to actually test for public URLs.
Previously it was just testing that sending a GET request to our
POST-only URLs returned a 400 error.

(imported from commit a510734271385046bbf29166b38c0ecbd104d2da)
2013-01-24 10:58:51 -05:00
Leo Franchi 2c64bf9c89 Add a test for api_get_public_streams
(imported from commit c2409962e61add9f33982f992350bff6051617a9)
2013-01-23 10:46:41 -05:00
Leo Franchi 0e0e5f63bd Add a test class for api_get_profile
(imported from commit e8e06cb14066b4c53b6830a015da84e92c444a62)
2013-01-23 10:46:41 -05:00
Tim Abbott b6345e6c3d tests: Remove incorrect default 'last' value of '1'.
(imported from commit b2cfce7e7197b69d7d7c6c3253c21d0f8d341a98)
2013-01-17 16:18:53 -05:00
Keegan McAllister 67a83e4ef5 tests: Remove inconsistent use of keyword args with InviteUserTest.invite
(imported from commit 5d19da3800ae3c4c63ce22b5cc907f768bf55da9)
2013-01-14 15:58:45 -05:00
Keegan McAllister 38f2498015 tests: Remove set literal in InviteUserTest.test_invalid_stream
This isn't valid syntax in Python 2.6.

(imported from commit 0dc8ef72a27f1c9d559b59d4243948818d1cb75a)
2013-01-14 15:57:54 -05:00
Luke Faraone fc3fecb1af Add test cases for invite functionality.
This involved splitting off into a separate function the second step of
the two-step registration process.

(imported from commit bd1ec9b5abb15d29b0585873daaa54a8d4e26556)
2013-01-14 10:25:27 -05:00
Tim Abbott 1a82741650 Move action functions from models.py to zephyr/lib/actions.py.
(imported from commit 9d577dd53ce7d4c9faf6cc8a56129d684a50811b)
2013-01-11 16:11:03 -05:00
Tim Abbott 77b7c1ead3 Explicitly error out when running tests improperly.
(imported from commit 8224aef3e327010f8ffdcf4dc966a1ccdbb8714c)
2013-01-10 16:59:36 -05:00
Tim Abbott 52589ca6fb Fix running "./manage.py test zephyr --settings=humbug.test_settings"
Previously it wouldn't work due to using the wrong port numbers.

This commit also has the side effect of fixing the fact that our
frontend tests would send real emails and log events to the real
message log.

(imported from commit f2cf400e6061c089627acba2759d588981ecf5bb)
2013-01-10 16:59:36 -05:00
Tim Abbott 39501e5a78 Make the Django-based test suite much faster.
So, I got annoyed that our test suite was taking forever to run:

real	2m13.443s
user	1m32.630s
sys	0m3.748s

Some quick profiling determined that the test suite is spending all of
its time loading the fixtures files (zephyr/fixtures/messages.json)
that it loads for each test case (3s to load that for each test case).
To improve this situation, I cut out from the test database used by
the test suite most of the users, subscriptions, etc. that aren't
being used directly by the test cases.  The impact is a quite
significant speedup:

real	0m15.176s
user	0m9.161s
sys	0m0.508s

We're still spending over a quarter of a second per test, which isn't
great -- but this is at least no longer unbearable.

This commit doesn't make any changes to the populate_db output if you
don't pass the new --test-suite option.

(imported from commit 2334ba5399b33edab3d29ff269fde4ea77ccd48e)
2013-01-08 17:23:55 -05:00
Tim Abbott 83abc08315 Move tornado views to their own file.
(imported from commit e0d9182cbc89a16eedd2846fa17cfba482510565)
2013-01-08 16:53:53 -05:00
Keegan McAllister 50d229fe11 Accept '{}' to mean 'no narrowing', for old mobile clients
(imported from commit 879f6ef846f2a8980a0574372324d8dc8d22c8ed)
2013-01-08 12:18:31 -05:00
Keegan McAllister 3af2bf345a Reinstate server-side narrow filtering
(imported from commit 40f63324a8dff404b504b06bddf303b8c1ad5780)
2013-01-08 12:18:31 -05:00
Keegan McAllister 16de6e43fe tests.py: Add assert_json_error_contains
(imported from commit 5a241af5071b6e711b56f84f56a1ed1f7e7dc262)
2013-01-08 12:18:31 -05:00
Tim Abbott e2292d38b1 Add tests for mirroring of private messages.
(imported from commit 8599d233c98f48a205618f52752a6ce466100d9e)
2013-01-07 15:06:28 -05:00
Jacob Hurwitz 73a8988df3 Fix tests which were sensitive to ordering of parameters
(imported from commit 87948bb8805a41382ba51152329b33b4f2f03937)
2013-01-03 17:22:21 -05:00
Tyler Hallada 7f06681efa Revert "Add "test" to names of test methods so they run"
This reverts commit a590bf6b8ee733893d3410ecb5eebe54141c48ea. This commit broke
the test suite because it was not tested after rebasing with Keegan's changes
to the tests.

(imported from commit 7248a55328609973c5303be6c85eeb5fbfc1475e)
2013-01-03 16:05:40 -05:00
Tyler Hallada 2cffb7e09b Add test for missing params to ChangeSettingsTest
And add "test_" to the beginning of successful_change_settings.

(imported from commit f5c04517ae3b2140b0b3f7d5012a7044ef601cf0)
2013-01-02 18:46:09 -05:00
Tyler Hallada f276ad2dce Add ChangeSettingsTest to test json_change_settings
(imported from commit 7e83dad9be4ffdfcb3631da6c63b18d85c5714eb)
2013-01-02 18:46:09 -05:00
Tyler Hallada dabdbc8c71 Add "test" to names of test methods so they run
GetOldMessagesTest had test methods that weren't included in the test suite
generated by Runner because they did not have "test" in their names. A few
bugs in these methods that were overlooked because of this were also fixed.

(imported from commit a590bf6b8ee733893d3410ecb5eebe54141c48ea)
2013-01-02 18:46:09 -05:00
Keegan McAllister ec1e16f6be tests: Better asserts for better failure messages
(imported from commit 18a485c6edf4c2d7d85098950b29c82c7f5ead42)
2013-01-02 16:10:25 -05:00
Keegan McAllister 15384d473b tests: Fix some tests that weren't running
(imported from commit f0b9462aac53e38495b9d2848923265adc98b246)
2013-01-02 16:10:25 -05:00
Zev Benjamin 4a28359092 Use to_non_negative_int in an additional place
(imported from commit 2e44cdc927499b0f0fd655ebfe00a864a55ae20a)
2012-12-20 14:26:36 -05:00
Zev Benjamin bf5ce4783d Move @has_request_variables error responses to middleware
This will now allow us to use @has_request_variables on helper
functions.

(imported from commit 799d71477654eac7fd8192cfc5bb88b78053532d)
2012-12-20 14:26:36 -05:00
Jeff Arnold db6f03d46d Make the back button work when narrowed
(imported from commit be922b06e7b53ec21751e67a490bb518333c3e6c)
2012-12-19 14:46:31 -05:00
Jessica McKellar 2f1f1fa6be Add tests for /json/get_old_messages.
(imported from commit 36a076af79635a11d9d48439bd92dfa694ed9df6)
2012-12-11 16:07:09 -05:00
Jessica McKellar c9c94c6696 Add unit tests for subscription color requests.
(imported from commit 6eeeefcfe75b78d36cd94c4d02ca3a1f1a3df3ac)
2012-12-03 12:46:27 -05:00
Keegan McAllister 9e5c86b783 Remove unimplemented test case
"Fixes" #274.

(imported from commit 2c2a64a70ecf11c2119fbb695cba05011cf78f8a)
2012-11-28 15:28:14 -05:00
Keegan McAllister 07ff10e308 Fix / prune tests of get_updates
The assertion-checking callbacks were never called before.  Now they will at
least get called when the view invokes handler.finish() before returning, i.e.
the return_messages_immediately case.

I fixed up the assertion-checking callback for one of the test cases.  For the
other two it wasn't clear what to do -- one has been known-broken for a long
time -- so I just removed them.

"Fixes" #277 in as much as that test case is gone now.

(imported from commit 82d1db26f36f82f24aa5b7ff9e5aa65ce24c9a8f)
2012-11-28 15:28:14 -05:00
Keegan McAllister b5dccbfa87 Return a special value to initiate longpolling
Fixes #261.

(imported from commit dd0312c3574c9ca924ab76edcb2fb6c03085be32)
2012-11-28 15:28:14 -05:00
Zev Benjamin da2c079503 Use Django's built-in @require_POST decorator
Theirs returns an actual 405

(imported from commit 31be790b0f53d7b63d7d3cd85972b16add3d8c74)
2012-11-26 11:52:50 -05:00
Tim Abbott 6026c80de6 API: Add unsubscribe function.
(imported from commit 6dc55e9030770500770ce3921a4e77499d64f2d6)
2012-11-16 17:06:01 -05:00
Tim Abbott afc62a8e16 [manual] Uniformize the subscriptions API method names.
This requires a zephyr_mirror deployment when it is pushed to prod.

(imported from commit 6543441fb264b518f8705d7989d068a1d50ce5d6)
2012-11-16 17:06:01 -05:00
Keegan McAllister 2a619a0054 tests.py: Allow skipping generate-fixtures with --skip-generate
(imported from commit ca3de89fc5cd71e3a60b173275edf7cf74d65cdf)
2012-11-16 15:33:38 -05:00
Keegan McAllister a2750943e3 Use a custom Django test suite runner
This allows us to define new command-line arguments for 'manage.py test'.

(imported from commit 11cf24694a54a3b717256903b7582ddec9a85587)
2012-11-16 15:33:38 -05:00
Tim Abbott 411a7f6b4f [manual] send_message: Rename recipient/stream fields to 'to'.
This commit changes APIs and requires and update of all zephyr
mirroring bots to deploy properly.

(imported from commit 2672d2d07269379f7a865644aaeb6796d54183e1)
2012-11-15 15:30:06 -05:00
Zev Benjamin 4497ef1493 Basic API tests
These tests don't have the same coverage as the json test on the
theory that the backend is shared by the two views and that
differences are mostly on the way into the backend functions.

(imported from commit ddd21135565122dae8cbe90846d1aee7e4a2f56e)
2012-11-15 13:42:17 -05:00
Zev Benjamin 195bdb07c9 Unify huddles and personals into private messages on the send path
Personals are now just private messages between two people (which
sometimes manifests as a private message with one recipient).  The
new message type on the send path is 'private'.  Note that the receive
path still has 'personal' and 'huddle' message types.

(imported from commit 97a438ef5c0b3db4eb3e6db674ea38a081265dd3)
2012-11-13 15:40:53 -05:00
Keegan McAllister 31496e9189 Generalize Tornado-related settings
(imported from commit 76a1338a87e1a6663aa7602a499e2d769814bf08)
2012-11-13 10:59:02 -05:00
Tim Abbott 30b43ebee2 Uniformize /json/ and /api/ URLs to end with no trailing slash.
(imported from commit c35b30bcc43982db3a2f774ea69269e5424a6159)
2012-11-09 14:30:10 -05:00
Zev Benjamin 565edc3c5a Fix tests failing due to changes in error message text
(imported from commit 1b0a869d427b33a0e8fcec4e2aa083bd94eee640)
2012-11-09 14:21:06 -05:00
Tim Abbott 831316c6a6 Fix tests failing due to new activity tracking.
(imported from commit 9c7ddfd4ad40cd2dfd38ac41537e058e02797085)
2012-11-09 14:16:52 -05:00
Keegan McAllister 3b8dbbc7d7 Use django.utils.timezone.now consistently
(imported from commit f223d9c1f6c77012db342b8be7aaed964b9f18c6)
2012-11-07 18:51:33 -05:00
Keegan McAllister 0d538d91ac test: Fail if generate-fixtures fails
(imported from commit b13167ad04837cfeb64989ff43fec2e6ae890a33)
2012-11-07 17:46:46 -05:00
Jessica McKellar 9eb86df03a tests: Unbreak registration, which was missing the new TOS field.
Also remove unused fields.

The registration tests should be revamped for our new multi-stage
signup, but for now just get the test suite passing completely.

(imported from commit 481f420cf99341e44e71942ae563e3f9a1270d3e)
2012-11-05 10:32:42 -05:00
Keegan McAllister ac6a74bd73 test_public_urls: Fix docstring
(imported from commit 18bf6595386ca65e0a928c9e0b60e8e0a46f77e2)
2012-11-02 14:57:38 -04:00
Keegan McAllister cb9cdf22c3 tests: Correct documentation on test_message_to_nonexistent_stream
(imported from commit 76176083c1a0494856a3507214e2cfc3844d1fc1)
2012-11-01 12:08:38 -04:00
Tim Abbott 30aab26ccd Fix test_missing_last_received to match current behavior.
(imported from commit 101b08d740ddf46d100c9763f2b78b86e2b07a00)
2012-10-30 16:59:25 -04:00
Tim Abbott 70f21f9d8e Fix 'Stream does not exist' test.
(imported from commit d4f0f3deaa3cc4b9cab67c90b87aa8bff2e72653)
2012-10-30 16:59:25 -04:00
Keegan McAllister 7267ba9cd2 Fix test for /accounts/logout
(imported from commit 256929fc4d462832358c31c99bd470a23ffaba29)
2012-10-30 00:18:01 -04:00
Tim Abbott 8510f4e207 tests: Add a mocked session object for tornado tests.
(imported from commit 0431d4cbb2233b7136367ad33f04ed2cc219add2)
2012-10-29 14:54:18 -04:00
Tim Abbott 846469c39c [schema]: Rename userprofile to user_profile.
(imported from commit adfb6152b7ec32557e3465d961695eb870506d5a)
2012-10-22 18:55:45 -04:00
Tim Abbott 93616039bc Use the new client data model to deduplicate mirroring.
(imported from commit 6ac38534aea11b1e7f8f332e76251f9501f9ab3e)
2012-10-22 18:31:36 -04:00
Tim Abbott f26a614bb3 Fix Client handling in the test suite.
(imported from commit 56841a00052c3aa85f2eeb45133439a46f3caf82)
2012-10-22 13:23:16 -04:00
Keegan McAllister ea916951f4 Disable notify_new_message calls in testing and populate_db
(imported from commit 07a0fea4173e2e27a90ac5f111927f0000377764)
2012-10-17 18:23:01 -04:00
Keegan McAllister 648755ebbd tests: Use the new initial passwords
(imported from commit 1a84be999b12de62959d5f3a0261d7d946bbeb09)
2012-10-17 18:23:01 -04:00
Tim Abbott a9d4dd4ffb Test new API key URLs.
(imported from commit e4d41b73f905730cb8728862373265d2119cfa00)
2012-10-17 17:12:44 -04:00
Tim Abbott 7237b4a73e Fix sending to a stream with a space in its name.
Previously if you tried to send to "a b", we actually ended up trying
to send to "a%20b", since we were url-encoding the stream name and
then not properly decoding it.

(imported from commit 307d2999bd309e47fc654ae4422ab4372edde064)
2012-10-17 14:06:00 -04:00
Tim Abbott b5c1178ac7 test_public_urls doesn't work with Tornado urls.
(imported from commit fe56a80842ac7f34fc0af0f916ce26f94a4baca8)
2012-10-16 17:25:00 -04:00
Tim Abbott a859c10017 Don't redirect to a login page when responding to json messages.
Also update tests to actually check all our URLs.

(imported from commit 86de2027d140da6118e2f2f60c1c86511b16c141)
2012-10-16 16:38:39 -04:00
Tim Abbott 3e994c16b7 Rename/reorganize our urls to be more consistent.
(imported from commit ca3cc7ccd5d7da83a9c60968527378ee1118648e)
2012-10-16 15:56:06 -04:00
Zev Benjamin f5131356f4 Fix test broken by 0917d5c2ed1b156603ce53aaec88ecbe26f5f39c
(imported from commit 1efce3527c52722deb5ea5ece4aa2bca5e0665c5)
2012-10-12 14:30:23 -04:00
Keegan McAllister 9811bd5f8a Get UserProfile by email with a join, not two queries
(imported from commit 0698ebb88615cea54196181aeabe869ec466dbc1)
2012-10-11 14:05:53 -04:00
Tim Abbott ac3f4393ff Rename instance to subject.
(imported from commit 6b4693da03f106448c137cf81cf9801cac44f2b8)
2012-10-10 18:01:39 -04:00
Tim Abbott 10d6106e36 Rename class => stream in tests.py local variables.
(imported from commit 9fe439a71f49dc0d03d50844dc40d4db33050008)
2012-10-10 17:48:17 -04:00
Tim Abbott 08e832e093 Change send_message to accept a stream, not a class.
(imported from commit 0f58de2502bec227f5f33e44692d03f2f28d6f63)
2012-10-10 17:48:17 -04:00
Tim Abbott 44e9e4cebf Rename Recipient.CLASS to Recipient.STREAM.
(imported from commit a530194163f7260c73921137fa1ff671f14516f6)
2012-10-10 17:47:13 -04:00
Tim Abbott 8daff2e05e Rename ZephyrClass to Stream.
(imported from commit ae51b7a9e03f322dfe2dfccd250cbfc23adfe32e)
2012-10-10 17:47:12 -04:00
Luke Faraone c3a9d60741 Partially fix a test that wasn't actually setting a variable.
This still doesn't work for blocking reasons, but that's a TODO for later.

(imported from commit 8a1ebb5d0d964be95c9f458c254ef5767526bb24)
2012-10-04 15:59:15 -04:00
Tim Abbott c83efefcc7 Replace 'zephyr' => 'message' in test suite.
(imported from commit 550a4b1f3c45e3275181a04b3a892040ef508dc5)
2012-10-04 14:37:36 -04:00
Tim Abbott e59d7cae48 Rename the Zephyr log to the Message log.
(imported from commit 7dedfb76b6b78ea90a2bfd20788e251c9c29ef47)
2012-10-03 18:14:15 -04:00
Tim Abbott 1ab81cff92 [schema] Rename Zephyr => Message in the schema.
(imported from commit 4f402f150c45d2097d6b16943935e6e370b4f8d8)
2012-10-03 18:14:15 -04:00
Tim Abbott 01bc4aaf28 Remove 'zephyr' from invalid message type error.
(imported from commit 360ffc5bfbb12f65af83093ee5a83ac7caa5c464)
2012-10-03 12:30:39 -04:00
Tim Abbott 7acfb5c71c Rename /zephyr/ to /send_message/.
(imported from commit 41c2ff67cfc514e53aff8648c36f545526e324ed)
2012-10-03 12:30:37 -04:00
Tim Abbott cca5f7b76a Rename do_send_zephyr to do_send_message.
(imported from commit df4dc741bf00a197ca5ab39373bc9a3eda379684)
2012-10-03 12:27:34 -04:00
Tim Abbott e79805847b Rename the 'new_zephyr' argument to the more descriptive 'content'.
(imported from commit b47e2c4823bbfbf2f94cbafb24ed5d78dfbe841b)
2012-10-02 17:29:55 -04:00
Luke Faraone 729d3ac602 Fix registration test, now exercise the email sending and verification code
(imported from commit 62979bbfec107ba53a9209c0fe115ce08ffd0e58)
2012-10-02 11:47:28 -04:00