def test_check_less_thirty(self): data = [{ "id": "725", "name": "Off the Grid: North Berkeley (Sunday Dinner)", "description": "Every Sunday from 5pm to 9pm, grab bites from a rotating list of 8-10 artisanal street food vendors.\n\nLocation: Corner of Delaware and Sacramento St \u0040 North Berkeley Bart Station \n\nTime: Sundays from 5pm to 8pm - Launching this Sunday, February 9th \nDownload Off the Grid App for amenities around this market! http://offthegridsf.com/app", "start_time": "2005-08-02T17:00:00-0700", "location": " North Berkeley Bart Station, 1750 Sacramento Street, Berkeley CA", }, { "id": "725", "name": "Off the Grid: North Berkeley (Sunday Dinner)", "description": "Every Sunday from 5pm to 9pm, grab bites from a rotating list of 8-10 artisanal street food vendors.\n\nLocation: Corner of Delaware and Sacramento St \u0040 North Berkeley Bart Station \n\nTime: Sundays from 5pm to 8pm - Launching this Sunday, February 9th \nDownload Off the Grid App for amenities around this market! http://offthegridsf.com/app", "start_time": "2020-08-02T17:00:00-0700", "location": " North Berkeley Bart Station, 1750 Sacramento Street, Berkeley CA" }] new_events = check_less_thirty(data) self.assertEqual(len(new_events), 1)
def eventsview(request): check_db() if len(Vendor.objects.all()) == 0: content = read_data("http://offthegridsf.com/vendors#food") vendors = parse_HTML(content) create_vendor_models(vendors) fb_data = read_data(facebookurl) if len(Event.objects.all()) > 0 and fb_data != "ERROR": event_data_ready = check_recent_fb_json(fb_data["data"]) create_event_models(event_data_ready) establish_relation() elif fb_data != "ERROR": print "WERE here" next_parameter = fb_data["paging"]["cursors"]["after"] next_set = transform_url(facebookurl, next_parameter) second = read_data(next_set) fulldata = fb_data["data"] + second["data"] events = check_less_thirty(fulldata) create_event_models(events) establish_relation() event_list = Event.objects.all().order_by("-event_time") context_dict = {"events": event_list} return render(request, "GingerBites/events.html", context_dict)