2121from recoco .apps .projects .utils import assign_advisor , assign_collaborator
2222from recoco .utils import login
2323
24+ from ...conversations import models as conversation_models
2425from .. import models
2526
2627
@@ -193,13 +194,17 @@ def test_upload_file_available_for_project_collaborators(
193194
194195 assert response .status_code == 302
195196
196- document = models .Document .objects .all ()[ 0 ]
197+ document = models .Document .objects .first ()
197198 assert document .project == project
198199 assert document .description == data ["description" ]
199200 assert document .uploaded_by == user
200201 assert not document .private
201202 assert document .the_file is not None
202203
204+ msg = conversation_models .Message .objects .first ()
205+ assert msg .posted_by == user
206+ assert msg .nodes .first ().document == document
207+
203208
204209@pytest .mark .django_db
205210def test_upload_file_rejects_executables (client , request , project , malicious_file ):
@@ -229,9 +234,7 @@ def test_upload_document_is_either_link_or_file(client, request, project):
229234
230235
231236@pytest .mark .django_db
232- def test_upload_file_does_not_trigger_notifications (
233- client , request , project , good_file
234- ):
237+ def test_upload_file_trigger_msg_trace_notif (client , request , project , good_file ):
235238 data = {"description" : "this is some content" , "the_file" : good_file }
236239
237240 other_user = baker .make (auth_models .User )
@@ -247,10 +250,12 @@ def test_upload_file_does_not_trigger_notifications(
247250 assert response .status_code == 302
248251
249252 document = models .Document .objects .all ()[0 ]
253+ msg = document .documentnode_set .first ().message
250254
251- assert action_object_stream (document ).count () == 1
255+ assert action_object_stream (msg ).count () == 1
256+ assert action_object_stream (document ).count () == 0
252257 assert user .notifications .count () == 0
253- assert other_user .notifications .count () == 0
258+ assert other_user .notifications .count () == 1
254259
255260
256261@pytest .mark .django_db
0 commit comments