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.
Handle assignment notification based on user preferences [SDBELGA-818] (
superdesk#2018) * Handle assignment notification based on user preferences [SDBELGA-818] * address comment * refactore code * check assigned user * Refactor: Define user_id constant * fix pytest * add user default prefrence * fix behave tests
- Loading branch information
1 parent
3eb114c
commit 4a8dbf9
Showing
7 changed files
with
108 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,10 @@ Feature: Assignments | |
""" | ||
[{"name": "Sports", "content_expiry": 60, "members": [{"user": "#CONTEXT_USER_ID#"}]}] | ||
""" | ||
And "users" | ||
""" | ||
[{"_id": "507f191e810c19729de87034", "name":"testfoo", "email":"[email protected]", "username":"johnfoo"}] | ||
""" | ||
|
||
@auth | ||
Scenario: Empty planning list | ||
|
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 |
---|---|---|
|
@@ -625,6 +625,10 @@ Feature: Planning | |
""" | ||
[{"_id": "desk_123", "name": "Politic Desk"}] | ||
""" | ||
Given "users" | ||
""" | ||
[{"_id": "507f191e810c19729de871eb", "name":"testfoo", "email":"[email protected]", "username":"johnfoo"}] | ||
""" | ||
Given "vocabularies" | ||
""" | ||
[{ | ||
|
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
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 |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
|
||
assignment_id = "5b20652a1d41c812e24aa49e" | ||
USER_ID = ObjectId("5d385f31fe985ec67a0ca583") | ||
|
||
|
||
class AssignmentLinkTestCase(TestCase): | ||
|
@@ -81,12 +82,33 @@ def test_updates_creates_new_record(self): | |
"coverage_item": "cov1", | ||
"assigned_to": { | ||
"state": "assigned", | ||
"user": "test", | ||
"user": USER_ID, | ||
"desk": "test", | ||
}, | ||
} | ||
], | ||
) | ||
self.app.data.insert( | ||
"users", | ||
[ | ||
{ | ||
"_id": USER_ID, | ||
"username": "admin", | ||
"password": "blabla", | ||
"email": "[email protected]", | ||
"user_type": "administrator", | ||
"is_active": True, | ||
"needs_activation": False, | ||
"is_author": True, | ||
"is_enabled": True, | ||
"display_name": "John Smith", | ||
"sign_off": "ADM", | ||
"first_name": "John", | ||
"last_name": "Smith", | ||
"role": ObjectId("5d542206c04280bc6d6157f9"), | ||
} | ||
], | ||
) | ||
|
||
get_resource_service("assignments_link").post( | ||
[{"assignment_id": assignment_id, "item_id": "item1", "reassign": True}] | ||
|
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 |
---|---|---|
|
@@ -5,9 +5,34 @@ | |
|
||
|
||
class AssignmentUnlinkTestCase(TestCase): | ||
USER_ID = ObjectId("5d385f31fe985ec67a0ca583") | ||
|
||
def setUp(self): | ||
super().setUp() | ||
with self.app.app_context(): | ||
users = [ | ||
{ | ||
"_id": self.USER_ID, | ||
"username": "admin", | ||
"password": "blabla", | ||
"email": "[email protected]", | ||
"user_type": "administrator", | ||
"is_active": True, | ||
"needs_activation": False, | ||
"is_author": True, | ||
"is_enabled": True, | ||
"display_name": "John Smith", | ||
"sign_off": "ADM", | ||
"first_name": "John", | ||
"last_name": "Smith", | ||
"role": ObjectId("5d542206c04280bc6d6157f9"), | ||
} | ||
] | ||
self.app.data.insert("users", users) | ||
|
||
def test_delivery_record(self): | ||
with self.app.app_context(): | ||
flask.g.user = {"_id": ObjectId()} | ||
flask.g.user = {"_id": self.USER_ID} | ||
self.app.data.insert( | ||
"vocabularies", | ||
[ | ||
|
@@ -105,8 +130,8 @@ def test_delivery_record(self): | |
def test_unlinks_all_content_updates(self): | ||
with self.app.app_context(): | ||
self.app.config.update({"PLANNING_LINK_UPDATES_TO_COVERAGES": True}) | ||
flask.g.user = {"_id": ObjectId()} | ||
user_id = ObjectId() | ||
flask.g.user = {"_id": self.USER_ID} | ||
user_id = self.USER_ID | ||
desk_id = ObjectId() | ||
|
||
# Make sure users a members of the desks | ||
|
@@ -218,8 +243,8 @@ def test_unlinks_all_content_updates(self): | |
def test_unlinks_properly_on_unlinking_any_update_in_chain(self): | ||
with self.app.app_context(): | ||
self.app.config.update({"PLANNING_LINK_UPDATES_TO_COVERAGES": True}) | ||
flask.g.user = {"_id": ObjectId()} | ||
user_id = ObjectId() | ||
flask.g.user = {"_id": self.USER_ID} | ||
user_id = self.USER_ID | ||
desk_id = ObjectId() | ||
|
||
# Make sure users a members of the desks | ||
|
@@ -336,8 +361,8 @@ def test_unlinks_properly_on_unlinking_any_update_in_chain(self): | |
def test_unlinks_archived_content(self): | ||
with self.app.app_context(): | ||
self.app.config.update({"PLANNING_LINK_UPDATES_TO_COVERAGES": True}) | ||
flask.g.user = {"_id": ObjectId()} | ||
user_id = ObjectId() | ||
flask.g.user = {"_id": self.USER_ID} | ||
user_id = self.USER_ID | ||
desk_id = ObjectId() | ||
self.app.data.insert( | ||
"vocabularies", | ||
|
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 |
---|---|---|
|
@@ -3,6 +3,9 @@ | |
from planning.tests import TestCase | ||
from superdesk import get_resource_service | ||
from superdesk.errors import SuperdeskApiError | ||
from bson import ObjectId | ||
|
||
USER_ID = ObjectId("5d385f31fe985ec67a0ca583") | ||
|
||
|
||
class DuplicateCoverageTestCase(TestCase): | ||
|
@@ -28,7 +31,7 @@ def setUp(self): | |
}, | ||
"news_coverage_status": {"qcode": "ncostat:int"}, | ||
"assigned_to": { | ||
"user": "59f7f0881d41c88cab3f2a99", | ||
"user": USER_ID, | ||
"desk": "desk1", | ||
"state": "in_progress", | ||
}, | ||
|
@@ -37,6 +40,27 @@ def setUp(self): | |
} | ||
], | ||
) | ||
self.app.data.insert( | ||
"users", | ||
[ | ||
{ | ||
"_id": USER_ID, | ||
"username": "admin", | ||
"password": "blabla", | ||
"email": "[email protected]", | ||
"user_type": "administrator", | ||
"is_active": True, | ||
"needs_activation": False, | ||
"is_author": True, | ||
"is_enabled": True, | ||
"display_name": "John Smith", | ||
"sign_off": "ADM", | ||
"first_name": "John", | ||
"last_name": "Smith", | ||
"role": ObjectId("5d542206c04280bc6d6157f9"), | ||
} | ||
], | ||
) | ||
|
||
def test_duplicate(self): | ||
with self.app.app_context(): | ||
|
@@ -49,7 +73,7 @@ def test_duplicate(self): | |
"scheduled": datetime(2029, 10, 13, 15, 00, tzinfo=pytz.UTC), | ||
}, | ||
"assigned_to": { | ||
"user": "562435231d41c835d7b5fb55", | ||
"user": USER_ID, | ||
"desk": "desk2", | ||
"state": "in_progress", | ||
}, | ||
|
@@ -63,7 +87,7 @@ def test_duplicate(self): | |
|
||
self.assertEqual(new_coverage["planning"]["slugline"], "new slugline") | ||
self.assertEqual(new_coverage["planning"]["scheduled"], datetime(2029, 10, 13, 15, 00, tzinfo=pytz.UTC)) | ||
self.assertEqual(new_coverage["assigned_to"]["user"], "562435231d41c835d7b5fb55") | ||
self.assertEqual(new_coverage["assigned_to"]["user"], USER_ID) | ||
self.assertEqual(new_coverage["assigned_to"]["desk"], "desk2") | ||
self.assertEqual(new_coverage["assigned_to"]["state"], "in_progress") | ||
self.assertEqual(new_coverage["news_coverage_status"], {"qcode": "ncostat:onreq"}) | ||
|