diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3be8879..db668a2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -53,7 +53,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest] - python: [3.5, 3.6, 3.7, 3.8, 3.9.0-rc.1, pypy3] + python: [3.6, 3.7, 3.8, 3.9.0-rc.1, pypy3] exclude: # pytest bug on PyPy3 # https://github.com/Stranger6667/postmarker/pull/187/checks?check_run_id=1046220597 diff --git a/README.rst b/README.rst index 405fd0e..422564a 100644 --- a/README.rst +++ b/README.rst @@ -90,7 +90,7 @@ Or you can look at the docs/ directory in the repository. Python support ============== -Postmarker supports Python 3.5 - 3.9 and PyPy3. +Postmarker supports Python 3.6 - 3.9 and PyPy3. Thanks ====== diff --git a/docs/changelog.rst b/docs/changelog.rst index f099a3c..aac0f1e 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -6,6 +6,16 @@ Changelog `Unreleased`_ ------------- +Fixed +~~~~~ + +- Make ``TemplateID`` not required if ``TemplateAlias`` is specified. `#179`_ + +Removed +~~~~~~~ + +- Support for Python 3.5. + `0.16.0`_ - 2020-11-10 ---------------------- @@ -422,6 +432,7 @@ Fixed .. _#184: https://github.com/Stranger6667/postmarker/pull/184 .. _#183: https://github.com/Stranger6667/postmarker/pull/183 .. _#181: https://github.com/Stranger6667/postmarker/pull/181 +.. _#179: https://github.com/Stranger6667/postmarker/issues/179 .. _#170: https://github.com/Stranger6667/postmarker/issues/170 .. _#168: https://github.com/Stranger6667/postmarker/issues/168 .. _#163: https://github.com/Stranger6667/postmarker/issues/163 diff --git a/setup.py b/setup.py index 9b01af7..4f20be5 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,6 @@ "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", diff --git a/src/postmarker/models/emails.py b/src/postmarker/models/emails.py index f6209d7..f2f2313 100644 --- a/src/postmarker/models/emails.py +++ b/src/postmarker/models/emails.py @@ -214,6 +214,11 @@ def send(self): class EmailTemplate(BaseEmail): + def __init__(self, **kwargs): + if kwargs.get("TemplateId") is None and kwargs.get("TemplateAlias") is None: + raise ValueError("You need to specify either TemplateId or TemplateAlias") + super().__init__(**kwargs) + def send(self): return self._manager._send_with_template(**self.as_dict()) @@ -352,7 +357,8 @@ def send( def send_with_template( self, - TemplateId, + *, + TemplateId=None, TemplateModel, From, To, @@ -443,7 +449,8 @@ def Email( def EmailTemplate( self, - TemplateId, + *, + TemplateId=None, TemplateModel, From, To, diff --git a/test/models/test_emails.py b/test/models/test_emails.py index 404dbba..eaac287 100644 --- a/test/models/test_emails.py +++ b/test/models/test_emails.py @@ -206,6 +206,24 @@ def test_send_with_template(self, postmark): "To": "receiver@example.com", } + def test_template_with_alias_only(self, postmark): + # It should be possible to specify `TemplateAlias` and not `TemplateId` + postmark.emails.EmailTemplate( + TemplateAlias="foo", + TemplateModel={}, + From="sender@example.com", + To="receiver@example.com", + ) + + def test_send_with_template_without_alias_and_id(self, postmark): + # If there is no `TemplateAlias` and `TemplateId` then it is an error + with pytest.raises(ValueError): + postmark.emails.send_with_template( + TemplateModel={}, + From="sender@example.com", + To="receiver@example.com", + ) + class TestBatchSend: def test_email_instance(self, postmark, email, postmark_request):