예제 #1
0
    def test_new_event(self):
        '''
        Tests that all fields from a Facebook page to event are inserted 
        correctly.
        '''
        event_fbid = '286153888063194'        # Oxford 5k
        event_info = load_test_json('fb_event_oxford_5k.json')
        event_count_before = Event.objects.count()

        # ensure no FBPageRecord already exists for the given id
        with self.assertRaises(FacebookEventRecord.DoesNotExist):
            FacebookEventRecord.objects.get(fb_id=event_fbid)

        store_fbevent(event_info,create_owners=False)
        
        self.assertEquals(Event.objects.count(),event_count_before+1)
        try:
            event = Event.objects.get(name=u'Oxford Athletic Club Freaky 5K')
        except Event.DoesNotExist:
            self.fail('Event not inserted')

        try:
            # make ensure the stored FBEventRecord has the correct Event set
            record = FacebookEventRecord.objects.get(fb_id=event_fbid)
            self.assertEquals(record.event,event)
            # ensure the last updated time was set correctly on the event record
            self.assertEquals(record.last_updated,datetime(2011,9,23,18,27,48))
        except Event.DoesNotExist:
            self.fail('FacebookEventRecord not found!')            

        # check properties of event were stored correctly (see http://graph.facebook.com/291107654260858)
        # event goes from 10/29/11 13:30 16:30 (UTC time)
        self.assertEquals(event.dtstart,datetime(2011,10,29,13,30))
        self.assertEquals(event.dtend,datetime(2011,10,29,16,30))
        self.assertTrue(event.description.startswith(u'Join the Steel City Road Runners Club'))
예제 #2
0
    def test_existing_event(self):
        '''
        Tests that an event is not created if an existing event already exists.
        '''
        event_fbid = '291107654260858'         # mr. smalls event (already exists via fixture)
        event_info = load_test_json('fb_event_mr_smalls.json')
        event_count_before = Event.objects.count()
        record_count_before = FacebookEventRecord.objects.count()

        store_fbevent(event_info,create_owners=False)
        self.assertEquals(event_count_before,Event.objects.count())

        # ensure the Facebook record didn't get saved
        self.assertEquals(record_count_before,FacebookEventRecord.objects.count())