Skip to content

Commit

Permalink
Fixing merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkingserious committed Apr 3, 2019
2 parents ae4b1fe + 265b984 commit 62ba6f1
Show file tree
Hide file tree
Showing 24 changed files with 382 additions and 70 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ All notable changes to this project will be documented in this file.
## [5.4.1] - 2018-06-26 ##
### Fixed
- [PR #585](https://github.com/sendgrid/sendgrid-python/pull/585): Fix typo in `mail_example.py`. Big thanks to [Anurag Anand](https://github.com/theanuraganand) for the PR!
- [PR #583](https://github.com/sendgrid/sendgrid-python/pull/585): Fix `Personalization.substitutions` setter. Trying to set substitutions directly rather than with add_substitution was causing an infinite regress. Big thanks to [Richard Nias](https://github.com/richardnias) for the PR!
- [PR #583](https://github.com/sendgrid/sendgrid-python/pull/583): Fix `Personalization.substitutions` setter. Trying to set substitutions directly rather than with add_substitution was causing an infinite regress. Big thanks to [Richard Nias](https://github.com/richardnias) for the PR!

## [5.4.0] - 2018-06-07 ##
### Added
Expand Down Expand Up @@ -54,7 +54,7 @@ All notable changes to this project will be documented in this file.
- [PR #430](https://github.com/sendgrid/sendgrid-python/pull/430): Attempt to sync before executing the shell command. Big thanks to [Aditya Narayan](https://github.com/aditnryn) for the PR!
- [PR #429](https://github.com/sendgrid/sendgrid-python/pull/429): Typos. Big thanks to [daluntw](https://github.com/daluntw) for the PR!
- [PR #492](https://github.com/sendgrid/sendgrid-python/pull/492):
Updated date-range in LICENSE file. Big thanks to [Dhruv Srivastava](https://github.com/dhruvhacks) for the PR!
Updated date-range in the LICENSE file. Big thanks to [Dhruv Srivastava](https://github.com/dhruvhacks) for the PR!
- [PR #482](https://github.com/sendgrid/sendgrid-python/pull/482): Typos. Big thanks to [Karan Samani](https://github.com/Kimi450) for the PR!
- [PR #504](https://github.com/sendgrid/sendgrid-python/pull/504): Fix .codeclimate.yml. Big thanks to [Matt Bernier](https://github.com/mbernier) for the PR!
- [PR #505](https://github.com/sendgrid/sendgrid-python/pull/505): Remove unnecessary GitHub PR templates. Big thanks to [Alex](https://github.com/pushkyn) for the PR!
Expand Down
24 changes: 12 additions & 12 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,36 @@

### Be Open
Members of the community are open to collaboration, whether it's on pull requests, code reviews, approvals, issues or otherwise. We're receptive to constructive comments and criticism, as the experiences and skill sets of all members contribute to the whole of our efforts. We're accepting of all who wish to take part in our activities, fostering an environment where anyone can participate, and everyone can make a difference.

### Be Considerate
Members of the community are considerate of their peers, which include other contributors and users of SendGrid. We're thoughtful when addressing the efforts of others, keeping in mind that often the labor was completed with the intent of the good of the community. We're attentive in our communications, whether in person or online, and we're tactful when approaching differing views.

### Be Respectful
Members of the community are respectful. We're respectful of others, their positions, their skills, their commitments and their efforts. We're respectful of the volunteer efforts that permeate the SendGrid community. We're respectful of the processes outlined in the community, and we work within them. When we disagree, we are courteous in raising our issues. Overall, we're good to each other. We contribute to this community not because we have to, but because we want to. If we remember that, these guidelines will come naturally.
## Additional Guidance
Members of the community are respectful. We're respectful of others, their positions, their skills, their commitments, and their efforts. We're respectful of the volunteer efforts that permeate the SendGrid community. We're respectful of the processes outlined in the community, and we work within them. When we disagree, we are courteous in raising our issues. Overall, we're good with each other. We contribute to this community not because we have to, but because we want to. If we remember that, these guidelines will come naturally.

## Additional Guidance

### Disclose Potential Conflicts of Interest
Community discussions often involve interested parties. We expect participants to be aware when they are conflicted due to employment or other projects they are involved in and disclose those interests to other project members. When in doubt, over-disclose. Perceived conflicts of interest are important to address so that the community’s decisions are credible even when unpopular, difficult or favorable to the interests of one group over another.

### Interpretation
This Code is not exhaustive or complete. It is not a rulebook; it serves to distill our common understanding of a collaborative, shared environment and goals. We expect it to be followed in spirit as much as in the letter. When in doubt, try to abide by [SendGrid’s cultural values](https://sendgrid.com/blog/employee-engagement-the-4h-way) defined by our “4H’s”: Happy, Hungry, Humble and Honest.

### Enforcement
Most members of the SendGrid community always comply with this Code, not because of the existence of this Code, but because they have long experience participating in open source communities where the conduct described above is normal and expected. However, failure to observe this Code may be grounds for suspension, reporting the user for abuse or changing permissions for outside contributors.

## If you have concerns about someone’s conduct
**Initiate Direct Contact** - It is always appropriate to email a community member (if contact information is available), mention that you think their behavior was out of line, and (if necessary) point them to this Code.

**Discuss Publicly** - Discussing publicly is always acceptable. Note, though, that approaching the person directly may be better, as it tends to make them less defensive, and it respects the time of other community members, so you probably want to try direct contact first.

**Contact the Moderators** - You can reach the SendGrid moderators by emailing [email protected].

## Submission to SendGrid Repositories
Finally, just a reminder, changes to the SendGrid repositories will only be accepted upon completion of the [SendGrid Contributor Agreement](https://cla.sendgrid.com).

## Attribution

SendGrid thanks the following, on which it draws for content and inspiration:

* [Python Community Code of Conduct](https://www.python.org/psf/codeofconduct)
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ Hello! Thank you for choosing to help contribute to one of the SendGrid open sou
- [Code Reviews](#code-reviews)

<a name="roadmap"></a>
We use [Milestones](https://github.com/sendgrid/sendgrid-python/milestones) to help define current roadmaps, please feel free to grab an issue from the current milestone. Please indicate that you have begun work on it to avoid collisions. Once a PR is made, community reviews, comments, suggestions and additional PRs are welcomed and encouraged.
We use [Milestones](https://github.com/sendgrid/sendgrid-python/milestones) to help define current roadmaps, please feel free to grab an issue from the current milestone. Please indicate that you have begun work on it to avoid collisions. Once a PR is made, community reviews, comments, suggestions, and additional PRs are welcomed and encouraged.

<a name="cla"></a>
## CLAs and CCLAs

Before you get started, SendGrid requires that a SendGrid Contributor License Agreement (CLA) be filled out by every contributor to a SendGrid open source project.

Our goal with the CLA is to clarify the rights of our contributors and reduce other risks arising from inappropriate contributions. The CLA also clarifies the rights SendGrid holds in each contribution and helps to avoid misunderstandings over what rights each contributor is required to grant to SendGrid when making a contribution. In this way the CLA encourages broad participation by our open source community and helps us build strong open source projects, free from any individual contributor withholding or revoking rights to any contribution.
Our goal with the CLA is to clarify the rights of our contributors and reduce other risks arising from inappropriate contributions. The CLA also clarifies the rights SendGrid holds in each contribution and helps to avoid misunderstandings over what rights each contributor is required to grant to SendGrid when making a contribution. In this way, the CLA encourages broad participation by our open source community and helps us build strong open source projects, free from any individual contributor withholding or revoking rights to any contribution.

SendGrid does not merge a pull request made against a SendGrid open source project until that pull request is associated with a signed CLA. Copies of the CLA are available [here](https://gist.github.com/SendGridDX/98b42c0a5d500058357b80278fde3be8#file-sendgrid_cla).

Expand Down Expand Up @@ -217,7 +217,7 @@ Please run your code through:
git pull upstream <dev-branch>
```

3. Create a new topic branch (off the main project development branch) to
3. Create a new topic branch (of the main project development branch) to
contain your feature, change, or fix:

```bash
Expand Down
1 change: 0 additions & 1 deletion USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5034,4 +5034,3 @@ print(response.status_code)
print(response.body)
print(response.headers)
```

4 changes: 4 additions & 0 deletions docker-test/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@ fi

cd sendgrid-python
python3.6 setup.py install
<<<<<<< HEAD
pip install pyyaml six werkzeug flask python_http_client
=======
pip install pyyaml six werkzeug flask python-http-client pytest
>>>>>>> master
exec $SHELL
4 changes: 3 additions & 1 deletion docker/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Supported tags and respective `Dockerfile` links
- `v5.4.1`, `latest` [(Dockerfile)](https://github.com/sendgrid/sendgrid-python/blob/master/docker/Dockerfile)
- `v5.6.0`, `latest` [(Dockerfile)](https://github.com/sendgrid/sendgrid-python/blob/master/docker/Dockerfile)
- `v5.5.0`
- `v5.4.1`
- `v5.4.0`
- `v5.3.0`
- `v5.2.1`
Expand Down
1 change: 1 addition & 0 deletions docker/env/python-dev/sendgrid-python
Submodule sendgrid-python added at 28cf42
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import json
import os
import urllib2
from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import *
from sendgrid import *


# NOTE: you will need move this file to the root
# directory of this project to execute properly.
Expand All @@ -28,6 +26,84 @@ def build_hello_email():
except SendGridException as e:
print(e.message)

<<<<<<< HEAD:examples/helpers/mail/mail_example.py
=======
for cc_addr in personalization['cc_list']:
mock_personalization.add_to(cc_addr)

for bcc_addr in personalization['bcc_list']:
mock_personalization.add_bcc(bcc_addr)

for header in personalization['headers']:
mock_personalization.add_header(header)

for substitution in personalization['substitutions']:
mock_personalization.add_substitution(substitution)

for arg in personalization['custom_args']:
mock_personalization.add_custom_arg(arg)

mock_personalization.subject = personalization['subject']
mock_personalization.send_at = personalization['send_at']
return mock_personalization


def get_mock_personalization_dict():
"""Get a dict of personalization mock."""
mock_pers = dict()

mock_pers['to_list'] = [Email("[email protected]",
"Example User"),
Email("[email protected]",
"Example User")]

mock_pers['cc_list'] = [Email("[email protected]",
"Example User"),
Email("[email protected]",
"Example User")]

mock_pers['bcc_list'] = [Email("[email protected]"),
Email("[email protected]")]

mock_pers['subject'] = ("Hello World from the Personalized "
"SendGrid Python Library")

mock_pers['headers'] = [Header("X-Test", "test"),
Header("X-Mock", "true")]

mock_pers['substitutions'] = [Substitution("%name%", "Example User"),
Substitution("%city%", "Denver")]

mock_pers['custom_args'] = [CustomArg("user_id", "343"),
CustomArg("type", "marketing")]

mock_pers['send_at'] = 1443636843
return mock_pers


def build_attachment1():
"""Build attachment mock. Make sure your content is base64 encoded before passing into attachment.content.
Another example: https://github.com/sendgrid/sendgrid-python/blob/master/use_cases/attachment.md"""
attachment = Attachment()
attachment.content = ("TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNl"
"Y3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQ3JhcyBwdW12")
attachment.type = "application/pdf"
attachment.filename = "balance_001.pdf"
attachment.disposition = "attachment"
attachment.content_id = "Balance Sheet"
return attachment


def build_attachment2():
"""Build attachment mock."""
attachment = Attachment()
attachment.content = "BwdW"
attachment.type = "image/png"
attachment.filename = "banner.png"
attachment.disposition = "inline"
attachment.content_id = "Banner"
return attachment
>>>>>>> master:examples/helpers/mail_example.py

def build_kitchen_sink():
"""All settings set"""
Expand Down Expand Up @@ -261,5 +337,40 @@ def send_kitchen_sink():
## this will actually send an email
# send_hello_email()

<<<<<<< HEAD:examples/helpers/mail/mail_example.py
## this will only send an email if you set SandBox Mode to False
# send_kitchen_sink()
=======
# this will only send an email if you set SandBox Mode to False
send_kitchen_sink()


def transactional_template_usage():
# Assumes you set your environment variable:
# https://github.com/sendgrid/sendgrid-python/blob/master/TROUBLESHOOTING.md#environment-variables-and-your-sendgrid-api-key

"""
Sample usage of dynamic (handlebars) transactional templates.
To make this work, you should have dynamic template created within your
SendGrid account. For this particular example, template may be like::
<p>Hello, {{name}}! Your current balance is {{balance}}<p>
"""
mail = Mail()
mail.from_email = Email('[email protected]')
mail.template_id = 'd-your-dynamic-template-uid'
p = Personalization()
p.add_to(Email('[email protected]'))
p.dynamic_template_data = {
'name': 'Bob',
'balance': 42
}
mail.add_personalization(p)

sg = SendGridAPIClient()
response = sg.client.mail.send.post(request_body=mail.get())
print(response.status_code)
print(response.headers)
print(response.body)
>>>>>>> master:examples/helpers/mail_example.py
File renamed without changes.
2 changes: 1 addition & 1 deletion sendgrid/helpers/mail/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Please complete the [installation steps](https://github.com/sendgrid/sendgrid-py
## Usage

- For the most common use cases, please see [these examples](https://github.com/sendgrid/sendgrid-python/tree/master/use_cases)
-The comple v3 API Documentation can be found [here](https://sendgrid.com/docs/API_Reference/api_v3.html)
-The comple v3 API Documentation can be found [here](https://sendgrid.com/docs/API_Reference/api_v3.html)
1 change: 1 addition & 0 deletions sendgrid/helpers/mail/content.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .validators import ValidateApiKey



class Content(object):
"""Content to be included in your email.
Expand Down
2 changes: 1 addition & 1 deletion sendgrid/sendgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This library allows you to quickly and easily use the SendGrid Web API v3 via
Python.
For more information on this library, see the README on Github.
For more information on this library, see the README on GitHub.
http://github.com/sendgrid/sendgrid-python
For more information on the SendGrid v3 API, see the v3 docs:
http://sendgrid.com/docs/API_Reference/api_v3.html
Expand Down
59 changes: 35 additions & 24 deletions test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,48 @@ def setUp(self):
def test_initialization(self):
endpoint = '/inbound'
port = 5000
debug_mode = True
keys = ['from',
'attachments',
'headers',
'text',
'envelope',
'to',
'html',
'sender_ip',
'attachment-info',
'subject',
'dkim',
'SPF',
'charsets',
'content-ids',
'spam_report',
'spam_score',
'email']
keys = [
'from',
'attachments',
'headers',
'text',
'envelope',
'to',
'html',
'sender_ip',
'attachment-info',
'subject',
'dkim',
'SPF',
'charsets',
'content-ids',
'spam_report',
'spam_score',
'email',
]
host = 'http://127.0.0.1:5000/inbound'
self.assertTrue(debug_mode, self.config.debug_mode)
self.assertTrue(endpoint, self.config.endpoint)
self.assertTrue(host, self.config.host)
self.assertTrue(port, self.config.port)

self.assertTrue(self.config.debug_mode)
self.assertEqual(self.config.endpoint, endpoint)
self.assertEqual(self.config.host, host)
self.assertEqual(self.config.port, port)
for key in keys:
self.assertIn(key, self.config.keys)

def test_init_environment(self):
def test_init_environment_should_set_env_from_dotenv(self):
config_file = sendgrid.helpers.inbound.config.__file__
env_file_path = '{0}/.env'.format(os.path.abspath(os.path.dirname(config_file)))
with open(env_file_path, 'w') as f:
f.write('RANDOM_VARIABLE=RANDOM_VALUE')
Config()
os.remove(env_file_path)
self.assertEqual('RANDOM_VALUE', os.environ['RANDOM_VARIABLE'])
self.assertEqual(os.environ['RANDOM_VARIABLE'], 'RANDOM_VALUE')

def test_init_environment_should_not_set_env_if_format_is_invalid(self):
config_file = sendgrid.helpers.inbound.config.__file__
env_file_path = os.path.abspath(os.path.dirname(config_file)) + '/.env'
with open(env_file_path, 'w') as f:
f.write('RANDOM_VARIABLE=RANDOM_VALUE=ANOTHER_RANDOM_VALUE')
Config()
os.remove(env_file_path)
self.assertIsNone(os.environ.get('RANDOM_VARIABLE'))
1 change: 1 addition & 0 deletions test/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import unittest



class ProjectTests(unittest.TestCase):
# ./docker
def test_docker_dir(self):
Expand Down
1 change: 0 additions & 1 deletion test/test_spam_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def test_has_values_but_not_enabled(self):

def test_spam_change_properties(self):
"""Tests changing the properties of the spam check class"""

expected = {'enable': False, 'threshold': 10, 'post_to_url': 'https://www.testing.com'}
spam_check = SpamCheck(enable=True, threshold=5, post_to_url='https://www.test.com')
spam_check.enable = False
Expand Down
Loading

0 comments on commit 62ba6f1

Please sign in to comment.