Skip to content
This repository has been archived by the owner on Dec 11, 2021. It is now read-only.

Commit

Permalink
Check if isOnline only once.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Ferrier committed Dec 15, 2014
1 parent d6f9a8f commit 6f63215
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions email2pdf_unittest
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,19 @@ import unittest

def setUpModule():
global examineDir
global isOnline

examineDir = '/tmp'
examineDir = tempfile.mkdtemp(dir=examineDir)
print("Output examination directory: " + examineDir)

ONLINE_URL = "https://raw.githubusercontent.com/andrewferrier/email2pdf/master"
try:
requests.get(ONLINE_URL)
isOnline = True
except:
isOnline = False


def touch(fname):
open(fname, 'w').close()
Expand All @@ -48,13 +56,6 @@ class BaseTestClasses:
self.command = os.path.normpath(os.path.join(os.getcwd(), 'email2pdf'))
self.checkedByTime = False

ONLINE_URL = "https://raw.githubusercontent.com/andrewferrier/email2pdf/master"
try:
requests.get(ONLINE_URL)
self.isOnline = True
except:
self.isOnline = False

def getTimeStamp(self, myTime):
return myTime.strftime("%Y-%m-%dT%H-%M-%S")

Expand Down Expand Up @@ -444,7 +445,7 @@ class TestMIME(BaseTestClasses.Email2PDFTestCase):
self.assertTrue(os.path.exists(os.path.join(self.workingDir, filename)))

def test_remoteImageDoesExist(self):
if self.isOnline:
if isOnline:
path = os.path.join(examineDir, "remoteImageDoesExist.pdf")
self.addHeaders()
self.attachHTML('<img src="https://raw.githubusercontent.com/andrewferrier/email2pdf/master/basi2c16.png">')
Expand Down Expand Up @@ -518,7 +519,7 @@ class TestMIME(BaseTestClasses.Email2PDFTestCase):
self.assertFalse(os.path.exists(os.path.join(self.workingDir, imageFilename)))

def test_embeddedImageExtraHTMLContent(self):
if self.isOnline:
if isOnline:
self.addHeaders()
imageFilename = self.attachImage('myid')
self.attachHTML('<p><img src="https://raw.githubusercontent.com/andrewferrier/email2pdf/master/basi2c16.png">' +
Expand Down

0 comments on commit 6f63215

Please sign in to comment.