def runTest(self): city = cities_db.City(dict(city_name='Gotham', country_name='US')) d = datetime.date(2020, 1, 1) week_start = d - datetime.timedelta(days=d.weekday()) # round down to last monday search_results = [ search_base.SearchResult( '1', { 'name': 'Event 1', 'start_time': '2020-01-01T09:00:00', }, eventdata.DBEvent(fb_event={ 'info': {}, }) ), search_base.SearchResult( '2', { 'name': 'Event 2', 'start_time': '2020-01-01T10:00:00', }, eventdata.DBEvent(fb_event={ 'info': {}, }) ), search_base.SearchResult( '3', { 'name': 'Event 3', 'start_time': '2020-01-03T09:00:00', }, eventdata.DBEvent(fb_event={ 'info': {}, }) ), ] message = weekly._generate_post_for(city, week_start, search_results) contents = message.split('\n\n', 1)[1].rsplit('\n\n', 1)[0] self.assertEqual( contents, '''\ Wednesday January 1: - 9:00AM: Event 1: https://dd.events/e-1 - 10:00AM: Event 2: https://dd.events/e-2 Friday January 3: - 9:00AM: Event 3: https://dd.events/e-3''' )
def runTest(self): db_event = eventdata.DBEvent(address='ungeocodeable mess of crap') fb_event = self.get_event('100') location_info = event_locations.LocationInfo(fb_event, db_event=db_event, debug=True) self.assertEqual(location_info.final_city, None) self.assertEqual(location_info.latlong(), (None, None))
def setUp(self): super(TestTasks, self).setUp() e = eventdata.DBEvent(id=EVENT_ID) e.search_time_period = dates.TIME_FUTURE e.put() m = users.User(id=MIKE_ID) m.fb_access_token = "DUMMY" m.expired_oauth_token = False m.put() u = users.User(id=USER_ID) u.fb_access_token = "DUMMY" u.expired_oauth_token = False u.put()
def create_web_event(event_id='tokyo-dance-life:1000001', json_body={}): event = eventdata.DBEvent(id=event_id) event.creating_method = eventdata.CM_WEB_SCRAPE full_json_body = { 'start_time': '2020-10-10T00:00:00Z', 'end_time': '2020-10-10T12:00:00Z', 'name': 'name', 'description': 'description', 'photo': None, 'location_address': 'Tokyo, Japan', } full_json_body.update(json_body) event_updates.update_and_save_web_events([(event, full_json_body)]) return event
def runTest(self): db_event = eventdata.DBEvent(address='San Jose, CA') fb_event = self.get_event('100') location_info = event_locations.LocationInfo(fb_event, db_event=db_event, debug=True) self.assertEqual(location_info.overridden_address, 'San Jose, CA') self.assertEqual(location_info.remapped_address, None) self.assertEqual(location_info.fb_address, 'San Francisco') self.assertEqual(location_info.final_city, 'San Jose, CA, United States') self.assertNearEqual(location_info.latlong(), (37.339385700000001, -121.89495549999999))
def runTest(self): db_event = eventdata.DBEvent(address=event_locations.ONLINE_ADDRESS) fb_event = self.get_event('100') location_info = event_locations.LocationInfo(fb_event, db_event=db_event, debug=True) self.assertEqual(location_info.overridden_address, event_locations.ONLINE_ADDRESS) self.assertEqual(location_info.remapped_address, None) self.assertEqual(location_info.fb_address, 'San Francisco') self.assertEqual(location_info.final_city, event_locations.ONLINE_ADDRESS) self.assertEqual(location_info.is_online_event(), True) self.assertEqual(location_info.actual_city(), None) self.assertEqual(location_info.latlong(), (None, None))
def runTest(self): config = { 'short_url_length': 22, 'characters_reserved_per_media': 24, } db_event = eventdata.DBEvent(id='555') db_event.start_time = datetime.datetime(2010, 1, 1, 12) db_event.actual_city_name = 'Sacramento, CA, United States' db_event.fb_event = FB_EVENT url = 'https://www.dancedeets.com/events/555/some-really-long-name-here-that-just-keeps-on-going-and-may-or-may-not-ever-get-truncated-but-we-will-just-have-to-wait-and-see?utm_campaign=autopost&utm_medium=share&utm_source=twitter_feed' self.maxDiff = 1000 self.assertEqual( event.format_twitter_post(config, db_event, media=False, handles=[]), u'2010/01/01: Sacramento, CA, United States: Some really long name here that just keeps on going and may or may not ev… %s' % url ) self.assertEqual( event.format_twitter_post(config, db_event, media=False, handles=['@name']), u'2010/01/01: Sacramento, CA, United States: Some really long name here that just keeps on going and may or may … %s @name' % url ) self.assertEqual( event.format_twitter_post( config, db_event, media=False, handles=['@name1', '@name2', '@name3', '@name4', '@name5', '@name6', '@name7'] ), u'2010/01/01: Sacramento, CA, United States: Some really long name here that just k… %s @name1 @name2 @name3 @name4 @name5' % url ) self.assertEqual( event.format_twitter_post( config, db_event, media=False, handles=['@mspersia', '@grooveologydc', '@groovealils', '@dam_sf', '@mishmashboutique'] ), u'2010/01/01: Sacramento, CA, United States: Some really long name here that jus… %s @mspersia @grooveologydc @groovealils' % url ) self.assertEqual( event.format_twitter_post(config, db_event, media=False, handles=['@jodywisternoff', '@jodywisternoff', '@Lane8music']), u'2010/01/01: Sacramento, CA, United States: Some really long name here that just keep… %s @jodywisternoff @jodywisternoff' % url )
def runTest(self): db_event = eventdata.DBEvent(address='San Francisco, CA') fb_event = self.get_event('100') try: event_locations.update_remapped_address(fb_event, 'TBD') location_info = event_locations.LocationInfo(fb_event, db_event=db_event, debug=True) self.assertEqual(location_info.overridden_address, 'San Francisco, CA') self.assertEqual(location_info.remapped_address, 'TBD') self.assertEqual(location_info.needs_override_address(), True) location_info = event_locations.LocationInfo(fb_event, debug=True) self.assertEqual(location_info.overridden_address, None) self.assertEqual(location_info.remapped_address, 'TBD') self.assertEqual(location_info.needs_override_address(), True) finally: event_locations.update_remapped_address(fb_event, '')