def test_no_location(): e = Event( name="get-together", start_date=datetime.datetime.utcnow().isoformat().split('.')[0] + 'Z', ) e.add_source(url='http://example.com/foobar') e.validate()
def get_events(self): events = [ { "name": "Meeting of the Join Committee on Foo", "start_time": dt.datetime.fromtimestamp(1408923205), "location": "Somewhere just east of Northwestsouthshire" }, { "name": "Meeting of the Join Committee on Bar", "start_time": dt.datetime.fromtimestamp(1008923205), "location": "Council Chambers", "_location": { "name": "Council Chambers", "url": "http://somewhere.example.com", "note": "Council Chambers, first room on the left in city hall", "coordinates": { "latitude": "42.360391", "longitude": "-71.058004", } } }, { "name": "Meeting of the Join Committee on Baz", "start_time": dt.datetime.fromtimestamp(1408929205), "location": "City Hall", "media": [{ "date": "2014-04-12", "type": "recording", "name": "Recording of the meeting", "links": [ { "mimetype": "video/mp4", "url": "http://example.com/video.mp4" }, { "mimetype": "video/webm", "url": "http://example.com/video.webm" }, ], "offset": 19, }] }, { "name": "Meeting of the Join Committee on Baz", "start_time": dt.datetime.fromtimestamp(1418929205), "location": "City Hall", "participants": [ { "note": "Meeting Chair", "type": "person", "name": "Yandel V. Watkins", }, { "note": "Attending Committee", "type": "organization", "name": "Ways and Means", }, ], "links": [{ "note": "Council Homepage", "url": "http://council.example.com", }, { "note": "Background on the topic", "url": "http://topic.news.example.com/", }], }, { "name": "Meeting of the Join Committee on Bar", "start_time": dt.datetime.fromtimestamp(1008923205), "location": "Council Chambers", "documents": [ { "url": "http://someone.example.com/slides.html", "mimetype": "text/html", "name": "HTML Slides", }, { "url": "http://someone.example.com/slides.ppt", "mimetype": "application/vnd.ms-powerpoint", "name": "Powerpoint of the Slides", }, { "url": "http://test.example.com/otherthing.ogg", "mimetype": "audio/ogg", "name": "Background Music", }, ], }, { "name": "Meeting of the Join Committee on Fnord", "start_time": dt.datetime.fromtimestamp(1418929205), "location": "City Hall", "agenda": [ { "related_entities": [ { "note": "Yandel will be presenting on the effects of this bill", "type": "person", "name": "Yandel V. Watkins", }, ], "media": [{ "date": "2014-04-12", "type": "recording", "name": "Recording of the meeting", "links": [ { "mimetype": "video/mp4", "url": "http://example.com/video.mp4" }, { "mimetype": "video/webm", "url": "http://example.com/video.webm" }, ], "offset": 19, }], "notes": [ "Yandel started his presentation.", "Yandel made some good points.", "Yandel sat down.", ], "subjects": ["testimony", "this-bill", "this-subject"], "order": '0', "description": "Yandel will give a talk", }, { "related_entities": [ { "note": "Mckenzie will be presenting on the effects of this bill", "type": "person", "name": "Mckenzie A. Cannon", }, ], "media": [{ "date": "2014-04-12", "type": "recording", "name": "Recording of the meeting", "links": [ { "mimetype": "video/mp4", "url": "http://example.com/video.mp4" }, { "mimetype": "video/webm", "url": "http://example.com/video.webm" }, ], "offset": 200, }], "notes": [ "Mckenzie started his presentation.", "Mckenzie made some good points.", "Mckenzie made some good better points.", "Mckenzie sat down.", ], "subjects": ["testimony", "this-bill-2", "this-subject"], "order": '1', "description": "Mckenzie will give a talk", }, ], }, ] for e in events: obj = Event(name=e['name'], start_time=e['start_time'], location=e['location']) obj.add_source("http://example.com/events") l = e.get("_location", None) if l: obj.location = l for key in [ "media", "links", "participants", "agenda", "documents" ]: l = e.get(key, None) if l: setattr(obj, key, l) obj.validate() yield obj
def get_events(self): events = [ {"name": "Meeting of the Join Committee on Foo", "start_time": dt.datetime.fromtimestamp(1408923205), "location": "Somewhere just east of Northwestsouthshire"}, {"name": "Meeting of the Join Committee on Bar", "start_time": dt.datetime.fromtimestamp(1008923205), "location": "Council Chambers", "_location": { "name": "Council Chambers", "url": "http://somewhere.example.com", "note": "Council Chambers, first room on the left in city hall", "coordinates": { "latitude": "42.360391", "longitude": "-71.058004", } }}, {"name": "Meeting of the Join Committee on Baz", "start_time": dt.datetime.fromtimestamp(1408929205), "location": "City Hall", "media": [ {"date": "2014-04-12", "type": "recording", "name": "Recording of the meeting", "links": [ {"mimetype": "video/mp4", "url": "http://example.com/video.mp4"}, {"mimetype": "video/webm", "url": "http://example.com/video.webm"}, ], "offset": 19, } ]}, {"name": "Meeting of the Join Committee on Baz", "start_time": dt.datetime.fromtimestamp(1418929205), "location": "City Hall", "participants": [ {"note": "Meeting Chair", "type": "person", "name": "Yandel V. Watkins",}, {"note": "Attending Committee", "type": "organization", "name": "Ways and Means",}, ], "links": [ {"note": "Council Homepage", "url": "http://council.example.com",}, {"note": "Background on the topic", "url": "http://topic.news.example.com/",} ],}, {"name": "Meeting of the Join Committee on Bar", "start_time": dt.datetime.fromtimestamp(1008923205), "location": "Council Chambers", "documents": [ {"url": "http://someone.example.com/slides.html", "mimetype": "text/html", "name": "HTML Slides",}, {"url": "http://someone.example.com/slides.ppt", "mimetype": "application/vnd.ms-powerpoint", "name": "Powerpoint of the Slides",}, {"url": "http://test.example.com/otherthing.ogg", "mimetype": "audio/ogg", "name": "Background Music",}, ], }, {"name": "Meeting of the Join Committee on Fnord", "start_time": dt.datetime.fromtimestamp(1418929205), "location": "City Hall", "agenda": [ {"related_entities": [ {"note": "Yandel will be presenting on the effects of this bill", "type": "person", "name": "Yandel V. Watkins",}, ], "media": [ {"date": "2014-04-12", "type": "recording", "name": "Recording of the meeting", "links": [ {"mimetype": "video/mp4", "url": "http://example.com/video.mp4"}, {"mimetype": "video/webm", "url": "http://example.com/video.webm"}, ], "offset": 19, } ], "notes": [ "Yandel started his presentation.", "Yandel made some good points.", "Yandel sat down.", ], "subjects": [ "testimony", "this-bill", "this-subject" ], "order": '0', "description": "Yandel will give a talk", }, {"related_entities": [ {"note": "Mckenzie will be presenting on the effects of this bill", "type": "person", "name": "Mckenzie A. Cannon",}, ], "media": [ {"date": "2014-04-12", "type": "recording", "name": "Recording of the meeting", "links": [ {"mimetype": "video/mp4", "url": "http://example.com/video.mp4"}, {"mimetype": "video/webm", "url": "http://example.com/video.webm"}, ], "offset": 200, } ], "notes": [ "Mckenzie started his presentation.", "Mckenzie made some good points.", "Mckenzie made some good better points.", "Mckenzie sat down.", ], "subjects": [ "testimony", "this-bill-2", "this-subject" ], "order": '1', "description": "Mckenzie will give a talk", }, ],}, ] for e in events: obj = Event(name=e['name'], start_time=e['start_time'], location=e['location']) obj.add_source("http://example.com/events") l = e.get("_location", None) if l: obj.location = l for key in [ "media", "links", "participants", "agenda", "documents" ]: l = e.get(key, None) if l: setattr(obj, key, l) obj.validate() yield obj