forked from superdesk/superdesk-planning
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add assigned user/desk info to planning json
CPCN-502
- Loading branch information
Showing
2 changed files
with
63 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -318,3 +318,44 @@ def test_matching_product_ids(self): | |
output = formatter.format(item, {"name": "Test Subscriber"})[0] | ||
output_item = json.loads(output[1]) | ||
self.assertEqual(output_item["products"], [{"code": "prod-type-planning", "name": "planning-only"}]) | ||
|
||
def test_assigned_desk_user(self): | ||
with self.app.app_context(): | ||
item = deepcopy(self.item) | ||
desk_id = ObjectId() | ||
user_id = ObjectId() | ||
|
||
item["coverages"][0]["assigned_to"].update( | ||
desk=desk_id, | ||
user=user_id, | ||
) | ||
|
||
self.app.data.insert( | ||
"desks", | ||
[{"_id": desk_id, "name": "sports", "email": "[email protected]"}], | ||
) | ||
|
||
self.app.data.insert("users", [{"_id": user_id, "display_name": "John Doe", "email": "[email protected]"}]) | ||
|
||
formatter = JsonPlanningFormatter() | ||
with mock.patch.dict(self.app.config, {"PLANNING_JSON_ASSIGNED_INFO_EXTENDED": True}): | ||
output = formatter.format(item, {"name": "Test Subscriber"})[0] | ||
output_item = json.loads(output[1]) | ||
coverage = output_item["coverages"][0] | ||
assert coverage["assigned_user"] == { | ||
"first_name": None, | ||
"last_name": None, | ||
"display_name": "John Doe", | ||
"email": "[email protected]", | ||
} | ||
assert coverage["assigned_desk"] == { | ||
"name": "sports", | ||
"email": "[email protected]", | ||
} | ||
|
||
# without config | ||
output = formatter.format(item, {"name": "Test Subscriber"})[0] | ||
output_item = json.loads(output[1]) | ||
coverage = output_item["coverages"][0] | ||
assert "email" not in coverage["assigned_user"] | ||
assert "email" not in coverage["assigned_desk"] |