예제 #1
0
    def testValidEmailNoMatchKeysCaseInsensitive(self):
        """
            There exists subscriptions and some rfps, but the keywords match due matching
            being case insensitive.
        """
        some_publish_date = date(2012, 11, 10) #date.today()
        some_publish_date = date(2012, 11, 10) #date.today()

        create_RFP("aTitle", "aDesc", ["aKeyword1", "aKeyword2"], "aOrg", "aURI", "aOrigID",
            some_publish_date, some_publish_date, some_publish_date)

        create_RFP("aTitle2", "aDesc2", ["aKeyword3", "aKeyword4"], "aOrg", "aURI", "aOrigID",
            some_publish_date, some_publish_date, some_publish_date)


        create_subscription("aUsername", "aKEyworD1")
        sub = Subscription.all().fetch(2)[0]
        res = list()
        emailSender = EmailSender()
        emailSender._send_rfps_to_subscribers(sub, "aFirstName", str_email, res)
        msg = 'No RFPs found for username: %s and keyword: %s' % (sub.username, sub.keyword)
        self.assertEqual(1, len(res))
        self.assertNotEquals(res[0], msg)

        msg = "Found %d RFPs for %s with keyword '%s' for email: %s" % (1, sub.username, sub.keyword, str_email)
        self.assertEqual(1, len(res))
예제 #2
0
    def testValidEmailSentMultipleRFPS(self):
        """
            The tests shows that multiple RFPs with the same keyword for the subscription are sent out.
            The email would list 2 rfps
            To add, the keywords are interchanged at different positions on the list.
        """
        some_publish_date = date(2012, 11, 10) #date.today()

        create_RFP("aTitle", "aDesc", ["aKeyword1", "aKeyword2"], "aOrg", "aURI", "aOrigID",
            some_publish_date, some_publish_date, some_publish_date)

        create_RFP("aTitle2", "aDesc2", ["aKeyword2", "aKeyword1"], "aOrg", "aURI", "aOrigID",
            some_publish_date, some_publish_date, some_publish_date)


        create_subscription("aUsername", "aKeyword1")

        sub = Subscription.all().fetch(2)[0]

        res = list()

        emailSender = EmailSender()
        emailSender._send_rfps_to_subscribers(sub, "aFirstName", str_email, res)

        msg = "Found %d RFPs for %s with keyword '%s' for email: %s" % (2, sub.username, sub.keyword, str_email)

        self.assertEqual(1, len(res))
        self.assertEquals(res[0], msg)
예제 #3
0
 def testInvalidEmailSentNOSubsAndNORfps(self):
     """
         No subscriptions/rfps are present, thus an email should not be sent out.
     """
     some_publish_date = date(2012, 11, 10) #date.today()
     res = list()
     emailSender = EmailSender()
     emailSender._send_rfps_to_subscribers(None, "aFirstName", str_email, res)
     msg = 'Problem with sending a sub, probably None object'
     self.assertEqual(1, len(res))
     self.assertEquals(res[0], msg)
예제 #4
0
    def testEmailSent(self):
        emailSender = EmailSender()
        template_values = {
            "rfps": [],
            "name": 'test name',
            'search_text': 'test keyword',
            'is_admin': False,
            'search_uri': 'http://rfpow301.appspot.com/rfp/search/',
            'permalink_uri': 'http://rfpow301.appspot.com/rfp/'
        }

        emailSender.send(to=str_email, template_values=template_values)
        self.assertEmailSent(to=str_email)
예제 #5
0
    def testInvalidEmailSentNOSubs(self):
        """
            No subscriptions are present, thus an email should not be sent out.
        """
        some_publish_date = date(2012, 11, 10) #date.today()

        create_RFP("aTitle", "aDesc", ["aKeyword1", "aKeyword2"], "aOrg", "aURI", "aOrigID",
                    some_publish_date, some_publish_date, some_publish_date)
        #create_subscription("aUsername", "aKeyword1")


        res = list()

        emailSender = EmailSender()
        emailSender._send_rfps_to_subscribers(None, "aFirstName", str_email, res)

        msg = 'Problem with sending a sub, probably None object'

        self.assertEqual(1, len(res))
        self.assertEquals(res[0], msg)
예제 #6
0
    def testInvalidEmailSentNORfps(self):
        """
            No Rfps are presented, thus an email should not be sent out.
        """
        some_publish_date = date(2012, 11, 10) #date.today()

#        create_RFP("aTitle", "aDesc", ["aKeyword1", "aKeyword2"], "aOrg", "aURI", "aOrigID",
#            some_publish_date, some_publish_date, some_publish_date)
        create_subscription("aUsername", "aKeyword1")

        sub = Subscription.all().fetch(2)[0]

        res = list()

        emailSender = EmailSender()
        emailSender._send_rfps_to_subscribers(sub, "aFirstName", str_email, res)

        msg = 'No RFPs found for username: %s and keyword: %s' % (sub.username, sub.keyword)

        self.assertEqual(1, len(res))
        self.assertEquals(res[0], msg)
예제 #7
0
    def testInvalidEmailNoMatchKeys(self):
        """
            There exists subscriptions and some rfps, but the keywords don't match.
        """
        some_publish_date = date(2012, 11, 10) #date.today()
        some_publish_date = date(2012, 11, 10) #date.today()

        create_RFP("aTitle", "aDesc", ["aKeyword1", "aKeyword2"], "aOrg", "aURI", "aOrigID",
            some_publish_date, some_publish_date, some_publish_date)

        create_RFP("aTitle2", "aDesc2", ["aKeyword3", "aKeyword4"], "aOrg", "aURI", "aOrigID",
            some_publish_date, some_publish_date, some_publish_date)


        create_subscription("aUsername", "noMatchKeyword")
        sub = Subscription.all().fetch(2)[0]
        res = list()
        emailSender = EmailSender()
        emailSender._send_rfps_to_subscribers(sub, "aFirstName", str_email, res)
        msg = 'No RFPs found for username: %s and keyword: %s' % (sub.username, sub.keyword)
        self.assertEqual(1, len(res))
        self.assertEquals(res[0], msg)
예제 #8
0
    def testInvalidEmailSent(self):
        """
            The parsed date of rfp is older than the last time the subscription was ran, so it was
            likely that the emailer had already sent that old rfp out. So we deliberately
            have the email fail at find RFPs.
        """
        some_publish_date = date(1800, 11, 10) #date.today()

        create_RFP("aTitle", "aDesc", ["aKeyword1", "aKeyword2"], "aOrg", "aURI", "aOrigID",
            some_publish_date, some_publish_date, some_publish_date)
        create_subscription("aUsername", "aKeyword1")

        sub = Subscription.all().fetch(2)[0]

        res = list()

        emailSender = EmailSender()
        emailSender._send_rfps_to_subscribers(sub, "aFirstName", str_email, res)

        msg = "Found %d RFPs for %s with keyword '%s' for email: %s" % (1, sub.username, sub.keyword, str_email)

        self.assertEqual(1, len(res))
        self.assertNotEquals(res[0], msg)
예제 #9
0
    def testValidEmailSent(self):
        """
            The parsed date of rfp is newer than the last time the subscription was ran, so the
            emailer had not seen this rfp and thus must send it. So we deliberately
            have the email send the found RFP.
        """
        some_publish_date = date(2012, 11, 10) #date.today()

        create_RFP("aTitle", "aDesc", ["aKeyword1", "aKeyword2"], "aOrg", "aURI", "aOrigID",
            some_publish_date, some_publish_date, some_publish_date)
        create_subscription("aUsername", "aKeyword1")

        sub = Subscription.all().fetch(2)[0]

        res = list()

        emailSender = EmailSender()
        emailSender._send_rfps_to_subscribers(sub, "aFirstName", str_email, res)

        msg = "Found %d RFPs for %s with keyword '%s' for email: %s" % (1, sub.username, sub.keyword, str_email)

        self.assertEqual(1, len(res))
        self.assertEqual(res[0], msg)
예제 #10
0
 def send_rfps(self):
     logging.info('Starting RFP email updates...')
     emailSender = EmailSender()
     results = emailSender.send_rfps_to_subscribers()
     logging.info('Done RFP email updates')
     return results
예제 #11
0
 def send_rfps(self):
     logging.info('Starting RFP email updates...')
     emailSender = EmailSender()
     results = emailSender.send_rfps_to_subscribers()
     logging.info('Done RFP email updates')
     return results