Add test for events-played.json data
ADD
tests/mock_data/events-played.json
+[
+ {"type": "activity", "size": 1, "ActivityNotification": [{"event": "started", "uuid": "c30c1edc-8df0-4713-a7f1-f1373f6db8e9", "Activity": {"uuid": "c30c1edc-8df0-4713-a7f1-f1373f6db8e9", "type": "library.refresh.items", "cancellable": false, "userID": 1, "title": "Refreshing", "subtitle": "", "progress": 0}}]},
+ {"type": "activity", "size": 1, "ActivityNotification": [{"event": "updated", "uuid": "c30c1edc-8df0-4713-a7f1-f1373f6db8e9", "Activity": {"uuid": "c30c1edc-8df0-4713-a7f1-f1373f6db8e9", "type": "library.refresh.items", "cancellable": false, "userID": 1, "title": "Refreshing", "subtitle": "Checking files", "progress": 0, "Context": {"key": "/library/metadata/513"}}}]},
+ {"type": "activity", "size": 1, "ActivityNotification": [{"event": "updated", "uuid": "c30c1edc-8df0-4713-a7f1-f1373f6db8e9", "Activity": {"uuid": "c30c1edc-8df0-4713-a7f1-f1373f6db8e9", "type": "library.refresh.items", "cancellable": false, "userID": 1, "title": "Refreshing", "subtitle": "Refreshing local metadata", "progress": 33, "Context": {"accessible": true, "exists": true, "key": "/library/metadata/513"}}}]},
+ {"type": "activity", "size": 1, "ActivityNotification": [{"event": "updated", "uuid": "c30c1edc-8df0-4713-a7f1-f1373f6db8e9", "Activity": {"uuid": "c30c1edc-8df0-4713-a7f1-f1373f6db8e9", "type": "library.refresh.items", "cancellable": false, "userID": 1, "title": "Refreshing", "subtitle": "Refreshing media analysis", "progress": 66, "Context": {"accessible": true, "exists": true, "key": "/library/metadata/513", "refreshed": false}}}]},
+ {"type": "activity", "size": 1, "ActivityNotification": [{"event": "ended", "uuid": "c30c1edc-8df0-4713-a7f1-f1373f6db8e9", "Activity": {"uuid": "c30c1edc-8df0-4713-a7f1-f1373f6db8e9", "type": "library.refresh.items", "cancellable": false, "userID": 1, "title": "Refreshing", "subtitle": "Refreshing media analysis", "progress": 100, "Context": {"accessible": true, "analyzed": false, "exists": true, "key": "/library/metadata/513", "refreshed": false}}}]}
+]

MODIFY
tests/test_events.py
tests/test_events.py
@@ -11,3 +11,17 @@ def test_events():
for event in events:
assert event["event"] == "ended"
assert event["Activity"]["progress"] == 100
+
+
+def test_event_played():
+ event_factory = EventFactory()
+ raw_events = load_mock("events-played.json")
+
+ events = [list(event_factory.get_events(data))[0] for data in raw_events]
+ assert len(events) == 5
+ assert events[0]["event"] == "started"
+ assert events[1]["event"] == "updated"
+ assert events[4]["event"] == "ended"
+ assert events[4]["Activity"]["type"] == "library.refresh.items"
+ assert events[4]["Activity"]["progress"] == 100
+ assert events[4]["Activity"]["Context"]["key"] == "/library/metadata/513"

Add test for events-played.json data