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

chore: PEP8 fix #87

Merged
merged 3 commits into from
Oct 30, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions examples/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,33 @@

import time

from os import sys, path
from smtpapi import SMTPAPIHeader

if __name__ == '__main__' and __package__ is None:
from os import sys, path
sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
vkmrishad marked this conversation as resolved.
Show resolved Hide resolved
from smtpapi import SMTPAPIHeader

from smtpapi import SMTPAPIHeader
header = SMTPAPIHeader()

# [To](http://sendgrid.com/docs/API_Reference/SMTP_API/index.html)
#header.add_to('test@example.com')
# header.add_to('test@example.com')
header.set_tos(['test1@example.com', 'test2@example.com'])

# [Substitutions](http://sendgrid.com/docs/API_Reference/SMTP_API/substitution_tags.html)
#header.add_substitution('key', 'value')
# header.add_substitution('key', 'value')
header.set_substitutions({'key': ['value1', 'value2']})

# [Unique Arguments](http://sendgrid.com/docs/API_Reference/SMTP_API/unique_arguments.html)
#header.add_unique_arg('key', 'value')
header.set_unique_args({'key':'value'})
# header.add_unique_arg('key', 'value')
header.set_unique_args({'key': 'value'})

# [Categories](http://sendgrid.com/docs/API_Reference/SMTP_API/categories.html)
#header.add_category('category')
# header.add_category('category')
header.set_categories(['category1', 'category2'])

# [Sections](http://sendgrid.com/docs/API_Reference/SMTP_API/section_tags.html)
#header.add_section('key', 'section')
header.set_sections({'key1':'section1', 'key2':'section2'})
# header.add_section('key', 'section')
header.set_sections({'key1': 'section1', 'key2': 'section2'})

# [Filters](http://sendgrid.com/docs/API_Reference/SMTP_API/apps.html)
header.add_filter('filter', 'setting', 'value')
Expand All @@ -41,8 +41,8 @@
header.set_ip_pool("testPool")

# [Scheduling Parameters](https://sendgrid.com/docs/API_Reference/SMTP_API/scheduling_parameters.html)
#header.add_send_each_at(unix_timestamp) # must be a unix timestamp
#header.set_send_each_at([]) # must be a unix timestamp
header.set_send_at(int(time.time())) # must be a unix timestamp
# header.add_send_each_at(unix_timestamp) # must be a unix timestamp
# header.set_send_each_at([]) # must be a unix timestamp
header.set_send_at(int(time.time())) # must be a unix timestamp

print(header.json_string())
print(header.json_string())
9 changes: 5 additions & 4 deletions smtpapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import json
import os


dir_path = os.path.dirname(os.path.realpath(__file__))
if os.path.isfile(os.path.join(dir_path, 'VERSION.txt')):
__version__ = open(os.path.join(dir_path, 'VERSION.txt')).read().strip()


class _CustomJSONEncoder(json.JSONEncoder):

def default(self, o):
Expand All @@ -15,6 +15,7 @@ def default(self, o):
# Provide a fallback to the default encoder if we haven't implemented special support for the object's class
return super(_CustomJSONEncoder, self).default(o)


class SMTPAPIHeader(object):

def __init__(self):
Expand Down Expand Up @@ -67,14 +68,14 @@ def set_sections(self, value):

def add_send_each_at(self, time):
if 'send_each_at' not in self.data:
self.data['send_each_at'] = []
self.data['send_each_at'] = []
self.data['send_each_at'].append(time)

def set_send_each_at(self, time):
self.data['send_each_at'] = time
self.data['send_each_at'] = time

def set_send_at(self, time):
self.data['send_at'] = time
self.data['send_at'] = time

def add_filter(self, app, setting, val):
if 'filters' not in self.data:
Expand Down
2 changes: 2 additions & 0 deletions test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def test_license_year(self):
break
self.assertEqual('Copyright (c) 2013-%s SendGrid, Inc.' % datetime.datetime.now().year, copyright_line)


class TestRepository(unittest.TestCase):

def setUp(self):
Expand Down Expand Up @@ -122,5 +123,6 @@ def test_repository_files_exists(self):
else:
self.assertTrue(os.path.exists(file_path), msg=self.file_not_found_message.format(file_path))


if __name__ == '__main__':
unittest.main()
2 changes: 2 additions & 0 deletions test/test_lisence.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sendgrid
from sendgrid.helpers.mail import *
from sendgrid.version import __version__

try:
import unittest2 as unittest
except ImportError:
Expand All @@ -13,6 +14,7 @@

host = "http://localhost:4010"


def test_license_year(self):
LICENSE_FILE = 'license.txt'
with open(LICENSE_FILE, 'r') as f:
Expand Down
2 changes: 2 additions & 0 deletions test/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
except ImportError:
import unittest


class ProjectTests(unittest.TestCase):

# ./Docker or docker/Docker
Expand Down Expand Up @@ -71,5 +72,6 @@ def test_usage(self):
def test_use_cases(self):
self.assertEqual(True, os.path.isfile('./VERSION.txt'))


if __name__ == '__main__':
unittest.main()