diff --git a/examples/example.py b/examples/example.py index cd09eb3..719eb17 100644 --- a/examples/example.py +++ b/examples/example.py @@ -6,6 +6,7 @@ if __name__ == '__main__' and __package__ is None: from os import sys, path + sys.path.append(path.dirname(path.dirname(path.abspath(__file__)))) from smtpapi import SMTPAPIHeader @@ -21,7 +22,7 @@ # [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.set_unique_args({'key': 'value'}) # [Categories](http://sendgrid.com/docs/API_Reference/SMTP_API/categories.html) # header.add_category('category') @@ -43,6 +44,6 @@ # [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.set_send_at(int(time.time())) # must be a unix timestamp print(header.json_string()) diff --git a/smtpapi/__init__.py b/smtpapi/__init__.py index 5781d87..13306e6 100644 --- a/smtpapi/__init__.py +++ b/smtpapi/__init__.py @@ -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): @@ -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): @@ -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: diff --git a/test/__init__.py b/test/__init__.py index 83b29d8..3e700d8 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -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): @@ -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() diff --git a/test/test_lisence.py b/test/test_lisence.py index d47c309..b3a7645 100644 --- a/test/test_lisence.py +++ b/test/test_lisence.py @@ -1,6 +1,7 @@ import sendgrid from sendgrid.helpers.mail import * from sendgrid.version import __version__ + try: import unittest2 as unittest except ImportError: @@ -13,6 +14,7 @@ host = "http://localhost:4010" + def test_license_year(self): LICENSE_FILE = 'license.txt' with open(LICENSE_FILE, 'r') as f: diff --git a/test/test_project.py b/test/test_project.py index daf7d85..41e440a 100644 --- a/test/test_project.py +++ b/test/test_project.py @@ -5,6 +5,7 @@ except ImportError: import unittest + class ProjectTests(unittest.TestCase): # ./Docker or docker/Docker @@ -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()