Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

# Fixes #500 #512

Closed
wants to merge 6 commits into from
Closed

# Fixes #500 #512

wants to merge 6 commits into from

Conversation

extemporalgenome
Copy link

@extemporalgenome extemporalgenome commented Oct 30, 2017

Checklist

  • I have made a material change to the repo (functionality, testing, spelling, grammar)
  • I have read the [Contribution Guide] and my PR follows them.
  • I updated my branch with the master branch.
  • (transparent change): I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation about the functionality in the appropriate .md file
  • I have added in line documentation to the code I modified

Short description of what this PR does:

  • Fixes CodeClimate style issue.

@mbernier edit:
Fixes #500

@thinkingserious thinkingserious added the status: code review request requesting a community code review or review from Twilio label Oct 30, 2017
@SendGridDX
Copy link

SendGridDX commented Oct 30, 2017

CLA assistant check
All committers have signed the CLA.

@extemporalgenome
Copy link
Author

I see other issues in code-climate. I'll add fixes for at least most of those to this PR.

@thinkingserious
Copy link
Contributor

@extemporalgenome

We have not been able to merge your Pull Request, but because you are awesome - we wanted to make sure you could still get a SendGrid Hacktoberfest shirt.

Please go fill out our swag form before Nov 5th and we will send the shirt! (We know that you might have tried this before and it didn’t work, sorry about that!)

You have till Nov 5th to fill out this form in order to get the Hacktoberfest shirt!

Thank you for contributing during Hacktoberfest! We hope to see you in the repos soon! Just so you know, we always give away a SendGrid shirt for your first ever non-Hacktoberfest PR that gets merged.

@mbernier
Copy link
Contributor

@extemporalgenome we have two things that happened with this PR - can you please look into these and fix them?

First - one of the tests stopped passing:

======================================================================

FAIL: test_asm_display_group_limit (test.test_mail.UnitTests)

----------------------------------------------------------------------

Traceback (most recent call last):

  File "/home/travis/build/sendgrid/sendgrid-python/test/test_mail.py", line 472, in test_asm_display_group_limit

    self.assertRaises(ValueError, ASM, 1, list(range(26)))

AssertionError: ValueError not raised by ASM
----------------------------------------------------------------------

Second - There is a merge conflict on the mail.py file:

    def get(self):
        """Get a response body for this Mail.

        :rtype: dict
        """
<<<<<<< issue-500
        mail = {
            'from': _get(self.from_email),
            'subject': self.subject,
            'personalizations': _get_list(self.personalizations),
            'content': _get_list(self.contents),
            'attachments': _get_list(self.attachments),
            'template_id': self.template_id,
            'sections': _merge_dicts(self.sections),
            'headers': _merge_dicts(self.headers),
            'categories': _get_list(self.categories),
            'custom_args': _merge_dicts(self.custom_args),
            'send_at': self.send_at,
            'batch_id': self.batch_id,
            'asm': _get(self.asm),
            'ip_pool_name': self.ip_pool_name,
            'mail_settings': _get(self.mail_settings),
            'tracking_settings': _get(self.tracking_settings),
            'reply_to': _get(self.reply_to),
        }

        return _trim_none(mail)
=======
        mail = {}
        if self.from_email is not None:
            mail["from"] = self.from_email.get()
        if self.subject is not None:
            mail["subject"] = self.subject

        if self.personalizations:
            mail["personalizations"] = [
                personalization.get()
                for personalization in self.personalizations
            ]

        if self.contents:
            mail["content"] = [ob.get() for ob in self.contents]

        if self.attachments:
            mail["attachments"] = [ob.get() for ob in self.attachments]

        if self.template_id is not None:
            mail["template_id"] = self.template_id

        if self.sections:
            sections = {}
            for key in self.sections:
                sections.update(key.get())
            mail["sections"] = sections

        if self.headers:
            headers = {}
            for key in self.headers:
                headers.update(key.get())
            mail["headers"] = headers

        if self.categories:
            mail["categories"] = [category.get() for category in
                                  self.categories]

        if self.custom_args:
            custom_args = {}
            for key in self.custom_args:
                custom_args.update(key.get())
            mail["custom_args"] = custom_args

        if self.send_at is not None:
            mail["send_at"] = self.send_at

        if self.batch_id is not None:
            mail["batch_id"] = self.batch_id

        if self.asm is not None:
            mail["asm"] = self.asm.get()

        if self.ip_pool_name is not None:
            mail["ip_pool_name"] = self.ip_pool_name

        if self.mail_settings is not None:
            mail["mail_settings"] = self.mail_settings.get()

        if self.tracking_settings is not None:
            mail["tracking_settings"] = self.tracking_settings.get()

        if self.reply_to is not None:
            mail["reply_to"] = self.reply_to.get()
        return mail
>>>>>>> master

    @property
    def from_email(self):
        """The email from which this Mail will be sent.

        :rtype: string
        """
        return self._from_email

@thinkingserious thinkingserious added type: community enhancement feature request not on Twilio's roadmap difficulty: medium fix is medium in difficulty labels Feb 27, 2018
@thinkingserious
Copy link
Contributor

Thanks again for helping improve this SDK!

We have started to execute on PR #347 (Python Mail Helper Refactor) and have integrated your work into this branch. Please follow along at PR #347 to follow our progress.

With Best Regards,

Elmer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: medium fix is medium in difficulty status: code review request requesting a community code review or review from Twilio type: community enhancement feature request not on Twilio's roadmap
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix "similar-code" issue in sendgrid/helpers/mail/mail.py
5 participants