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 runTest(self): city = cities.City(city_name='Gotham') 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:00: Event 1: http://dd.events/e-1 - 10:00: Event 2: http://dd.events/e-2 Friday January 3: - 9:00: Event 3: http://dd.events/e-3''')
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.put() u = users.User(id=USER_ID) u.fb_access_token = "DUMMY" u.put()
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 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=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): 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, '')