Commit Graph

75 Commits

Author SHA1 Message Date
medmunds
f95d5d66dc Avoid weak ref to local signal receiver in webhook tests.
Webhook tests define a local signal receiver function,
so connect it using the `weak=False` option to set
a good example.

(This isn't technically needed in the tests: the test receivers
are only connected while their definitions are still in scope,
so they couldn't possibly be garbage collected. But it doesn't
hurt, and it's good practice in case the test code gets copied.)

Also update the webhook docs to have a direct link to
Django's "listening to signals" info.
2016-02-04 12:14:01 -08:00
medmunds
9c938c8e85 Fix webhook tests for pypy
(Disconnect signal receivers after
we're done with them, to avoid
confusion between test cases.)
2016-02-03 19:42:01 -08:00
medmunds
79eaac42c4 Handle Mandrill sync event webhooks
Fixes #108
2016-02-03 19:29:26 -08:00
medmunds
aa46fadb48 Clean up global MANDRILL_SETTINGS
* Clean up Djrill backend __init__
* Fold MANDRILL_SUBACCOUNT into
  global_settings logic
* Add some missing override tests
* Update docs
2015-12-02 15:58:23 -08:00
medmunds
b8cdc6ce82 Cleanup Djrill exceptions
* Add common base DjrillException

* Simplify backend by moving logic
  to describe errors into base DjrillException

* Add NotSerializableForMandrillError
  for JSON serialization errors
2015-12-02 10:52:20 -08:00
medmunds
221530ae11 Fix tests on python 3 2015-12-01 13:57:45 -08:00
medmunds
d14b87c910 Raise error for invalid/rejected recipients
Raise new MandrillRecipientsRefused exception
when Mandrill returns 'reject' or 'invalid' status
for *all* recipients of a message.

(Similar to Django's SMTP email backend raising
SMTPRecipientsRefused.)

Add setting MANDRILL_IGNORE_RECIPIENT_STATUS
to override the new exception.

Trap JSON parsing errors in Mandrill API response,
and raise MandrillAPIError for them. (Helps with #93.)

Closes #80.
Closes #81.
2015-12-01 13:26:21 -08:00
medmunds
8433e6d660 Clean up all imports
* Use relative imports within djrill package
* Standardize ordering
* Remove absolute_import (it's standard in all
  python versions we now support)
2015-11-30 17:33:08 -08:00
medmunds
3a6e0ebb30 Clean up session sharing
* Test cases
* Fix premature session.close when caller
  is managing email backend connection
* Ensure session closed correct in exceptions
* Changelog

(Also fixes bug where JSON serialization errors
didn't respect fail_silently.)
2015-11-30 16:50:58 -08:00
medmunds
4089a35500 Drop legacy tests and deprecations 2015-11-29 14:45:08 -08:00
medmunds
942a6df8c3 Drop unintended json date encoding 2015-11-29 14:42:12 -08:00
medmunds
699216ba00 Drop legacy DjrillBackendHTTPError exception 2015-11-29 12:55:16 -08:00
medmunds
209f9573ff Drop legacy DjrillMessage class 2015-11-29 12:37:00 -08:00
medmunds
42848e0eed Integration tests handle 'queued' response
Rapid-fire pelting from our Travis tests sometimes
causes the Mandrill API to queue a "send" call, rather
than deal with it immediately. If that occurs, we
generally have to just ignore that test (in that test run).
2015-09-25 14:48:32 -07:00
William Hector
7179734a08 Allow global_merge_vars to be merged in with the per message dict, with keys in the latter taking precedent.
Update the docs accordingly.
2015-07-14 05:57:12 +01:00
William Hector
883b23362c Allow Mandrill specific options to be set globally in the settings file.
This is useful to set options such as tracking_domain etc per instance when using subaccounts with Mandrill.
2015-07-12 01:19:59 +01:00
William Hector
bac85511b5 Use requests.session to pool requests when mass sending mail
Tests modified to patch the ression post and close session upon error.
RE: http://stackoverflow.com/q/30982717/647002
2015-07-11 22:12:14 +01:00
medmunds
da260de1a0 Drop support for Django 1.3, Python 2.6 and 3.2.
* Shrink the Travis test matrix
* Remove a lot of backported test code
* Update requirements in setup.py
* Update docs

Closes #79
2015-05-14 11:39:57 -07:00
medmunds
99ac099081 Remove DjrillAdminSite
Closes #78
2015-05-14 11:00:52 -07:00
medmunds
6d94e94736 Live API tests
Addresses #41.
(Still need to add a Mandrill test key to the Travis config.)
2015-05-13 16:27:38 -07:00
medmunds
00ddd2f4f6 Improve MandrillAPIError.__str__
* Include formatted response from Mandrill API (if any)
* Clean up recipient address(es)
2015-05-13 15:43:54 -07:00
medmunds
8db86a8274 Fix RuntimeError on sys.modules in reset_warning_registry
Django 1.8's reset_warning_registry (which we backport)
was generating `RuntimeError: dictionary changed size
during iteration` in Travis tests under Python 3.x.

Likely a thread-safety issue on sys.modules.values().
See https://code.djangoproject.com/ticket/21049
for fix applied elsewhere in Django.
2015-05-12 18:42:12 -07:00
medmunds
fd75c4b24d Deprecate DjrillBackendHTTPError 2015-05-12 18:27:29 -07:00
medmunds
8d274e7b16 Deprecate DjrillMessage 2015-05-12 16:14:58 -07:00
medmunds
80895316f1 Deprecate DjrillAdminSite 2015-05-12 15:56:30 -07:00
medmunds
cc56b96efa Improve and document JSON serialization for Mandrill API
* Add some context to exceptions on unserializable
  values (addresses #89).
* Document need to format merge data
  (into something JSON-serializable).
* Add RemovedInDjrill2 DeprecationWarning.
* Deprecate blanket date/datetime serialization.
2015-05-12 13:29:52 -07:00
medmunds
52de627af1 Clean up test warnings for Django 1.8
* Django 1.8 requires TEMPLATES setting (for admin tests)
* Ignore cycle tag deprecation warnings

One remaining PendingDeprecationWarning: "the imp module is
deprecated in favour of importlib" is coming from six, and has a fix
waiting to land: https://bitbucket.org/gutworth/six/issue/112
2015-05-11 18:09:56 -07:00
medmunds
6891b0de91 Fix tests on Python 2.6 2015-02-25 21:13:16 -08:00
medmunds
bbc2e06091 Support Django 1.8 reply_to param. 2015-02-25 16:30:02 -08:00
medmunds
8ab36d2cd0 Django 1.8 alpha 1 support
* Test on Python 2.7, 3.4, pypy.
* Call super.setUpClass in DjrillAdminTests.
  https://docs.djangoproject.com/en/dev/releases/1.8/#overriding-setupclass-teardownclass-in-test-cases

Also clear up some new PendingDeprecationWarnings, where
the changes can easily remain compatible back to Django 1.3:

* Remove deprecated django.conf.urls.patterns.
  (And match Django recommendations in our docs.)
  https://docs.djangoproject.com/en/dev/releases/1.8/#django-conf-urls-patterns
* Remove deprecated SimpleTestCase.urls.
  (We've already back-ported @override_settings
  for testing older Django versions.)
  https://docs.djangoproject.com/en/dev/releases/1.8/#django-test-simpletestcase-urls
2015-01-16 16:17:31 -08:00
medmunds
76e29c0845 Support merge_language option.
Closes #84.
2015-01-16 13:48:39 -08:00
medmunds
1c4ee989f7 Fix "the JSON object must be str, not 'bytes'" on python3.
Closes #82.

* Test mock API responses (with actual content) in admin tests.
  (This exposes failure case, at least under Python 3.4/Django 1.6.)
* Parse json from Response.text, rather than raw Response.content
  bytes, in admin views.
2015-01-16 13:36:00 -08:00
medmunds
11961b57e5 Use real Response object in DjrillBackendMockAPITestCase tests.
(Improves testing accuracy around API response encoding.)

* Add `six` as test dependency (six.BytesIO, six.b)
* Change MockResponse content to bytes (because HTTP responses
  are bytes, not strings)
2015-01-16 13:18:17 -08:00
Patrick Kimber
0063fde2e5 if missing 'from_email', then 'log_message' will fail to build 2014-08-04 15:32:24 +01:00
medmunds
780d4f98f7 use_template_subject and use_template_from
Change "clear_subject" and "clear_from" to clarify expected usage.
Update docs.
Acknowledge contribution.
2014-05-28 21:09:28 -07:00
medmunds
78ff0af229 Merge branch 'feature/use-mandrill-template-defaults' of git://github.com/nikolay-saskovets/Djrill into nikolay-saskovets-feature/use-mandrill-template-defaults 2014-05-28 20:42:36 -07:00
nikolay.saskovets
3eb4582449 fix test 2014-05-16 07:57:53 -04:00
nikolay.saskovets
0e27a62f3c prepare for PR to mainstream (tests, docs, ...) 2014-05-16 07:37:51 -04:00
winhamwr
f2a08894fa Fixed python 3.2 compatibility. 2014-04-23 18:37:46 -04:00
winhamwr
70dc022f77 Handle unicode attachment content in both python 2.X and python3. 2014-04-23 16:59:48 -04:00
winhamwr
4e0a0cca71 Added failing test showing that unicode attachments cause an error 2014-04-23 15:52:05 -04:00
medmunds
8815601b65 Use override_settings rather than mucking with settings in tests
Second attempt to address possible test sequencing issue around tests that alter settings. (Failures in Travis tests not reproducible locally.)

Back-ports override_settings from Django 1.4 for compatibility with Django 1.3.
2014-04-20 16:04:31 -07:00
medmunds
ea2499f92f Fix possible test-sequencing issue in DjrillMandrillSubaccountTests 2014-04-20 15:03:49 -07:00
medmunds
ba2302ae56 Subaccounts: Document setting; verify message option overrides global setting 2014-04-20 12:57:08 -07:00
Sameer Al-Sakran
3c7a69873f fix tests + add base send test 2014-04-14 11:45:24 -07:00
Sameer Al-Sakran
cd8c2b8760 add subaccount support to djrill 2014-04-11 13:15:09 -07:00
medmunds
d7c06bb576 Better handling for cc and bcc recipients.
Fixes #59.
2014-01-25 12:35:23 -08:00
medmunds
1e44392b13 Allow all extra message headers in send.
Mandrill has relaxed previous API restrictions on headers.
Fixes #58.
2014-01-25 11:58:12 -08:00
Eric Hennings
3a6f3ec4c4 Fix tests broken for python 3.0 (no u’strings’) 2014-01-06 08:33:36 -08:00
Eric Hennings
e1c78ec197 Add the Mandrill send API response to EmailMessage as a property, mandrill_response, when a message is sent. For errors, set mandrill_response to None. Add tests & docs. 2013-12-22 14:12:57 -08:00