1. Stephen Tanner
  2. scavenger

Commits

Stephen Tanner  committed e2bf5d1

Started adding testing.

  • Participants
  • Parent commits 7bb4500
  • Branches default

Comments (0)

Files changed (2)

File test_webmaster.py

View file
+#This module is to test the webmaster code
+import unittest
+from webmaster import WebMaster
+
+class TestWebMaster()

File webmaster.py

View file
 
         body += self._build_table(posts)
 
+        subject = str(len(posts)) + " New Links Posted"
+        self.send_mail(subject, body)
+
+
+
+
+    #send mail
+    def send_mail(self, subject, body):
         headers = [
-    		"From: <" + self.email["from"] + ">",
+            "From: <" + self.email["from"] + ">",
             "To: <" + self.email["to"] + ">",
-            "Subject: " + str(len(posts)) + " New Links Posted",
+            "Subject: " + subject,
             "Content-Type: text/html"
         ]
 
-
         session = smtplib.SMTP(self.email['host'], self.email['port'])
         session.ehlo()
-        session.starttls() # Omit if SMTPS
-        session.ehlo() # Omit if SMTPS
-
+        session.starttls()
+        session.ehlo()
 
         session.login(self.email['user'], self.email['pass'])
 
-
         session.sendmail(self.email["from"], self.email["to"], "\r\n".join(headers) + "\r\n\r\n" + body)
         session.quit()
 
+
     #Need to build an html table of links
     def _build_table(self, posts):
         tbl = "<table><thead><tr><th>Title</th><th>Link</th></tr></thead><tbody>"
     def parse_post(self, page, post_class):
         bs_page = BeautifulSoup(page)
         post = bs_page.find("div", class_=post_class)
+        post_dict = {}
 
         return post