示例#1
0
    def test_days_until_next_event(self, mock_now, mock_upcoming_events):

        mock_upcoming_events.return_value = [self.event_pub, self.event_dojo]

        days, event = days_until_next_event()

        self.assertEquals(days, 6)
        self.assertEquals(event, self.event_pub)
示例#2
0
def tweet_events():

    from ug.util.gcal import NoEvents, days_until_next_event

    try:
        days, event = days_until_next_event()
    except NoEvents:
        print "no events"
        return

    where = event.where.split(',')[0]
    time = event.when.time()
    time_string = "%02d:%02d" % (time.hour, time.minute)

    print days

    if days == app.config['ADMIN_REMINDER_DAYS']:

        print "DM to d0ugal"

        send_dm("d0ugal",
                "Hey - we have an event coming up, have you sorted it?")

    elif days == app.config['LIST_REMINDER_DAYS']:

        print "weekly tweet"

        tweet = ('The next Python Glasgow event is a {title} in {days} '
                 'days at {where}. See http://pythonglasgow.org/ for more '
                 'details.').format(title=event.title, where=where, days=days)

        update_status(tweet)
        send_dm("d0ugal", tweet)

    elif days == 0:

        print "on the day tweet."

        tweet = ("There is a {title} tonight at {time} in {where}. See "
                 "http://pythonglasgow.org/ for more details."
                 ).format(title=event.title, time=time_string, where=where)

        update_status(tweet)
        send_dm("d0ugal", tweet)

    else:
        print "No Twitter updates today"
示例#3
0
    def test_days_until_next_event_none(self, mock_upcoming_events):

        mock_upcoming_events.return_value = []

        with self.assertRaises(NoEvents):
            days_until_next_event()