@@ -353,36 +353,6 @@ def test_failed_register_no_team(session):
353353 project_collection .register ("Project" )
354354
355355
356- def test_project_registration (collection : ProjectCollection , session ):
357- # Given
358- create_time = parse ('2019-09-10T00:00:00+00:00' )
359- project_data = ProjectDataFactory (
360- name = 'testing' ,
361- description = 'A sample project' ,
362- created_at = int (create_time .timestamp () * 1000 ) # The lib expects ms since epoch, which is really odd
363- )
364- session .set_response ({'project' : project_data })
365-
366- # When
367- with pytest .warns (DeprecationWarning ):
368- created_project = collection .register ('testing' )
369-
370- # Then
371- assert 1 == session .num_calls
372- expected_call = FakeCall (
373- method = 'POST' ,
374- path = '/projects' ,
375- json = {
376- 'name' : 'testing'
377- }
378- )
379- assert expected_call == session .last_call
380-
381- assert 'A sample project' == created_project .description
382- assert 'CREATED' == created_project .status
383- assert create_time == created_project .created_at
384-
385-
386356def test_project_registration (collection : ProjectCollection , session ):
387357 # Given
388358 create_time = parse ('2019-09-10T00:00:00+00:00' )
@@ -454,7 +424,7 @@ def test_list_no_team(session):
454424 projects = list (project_collection .list ())
455425
456426 assert 1 == session .num_calls
457- expected_call = FakeCall (method = 'GET' , path = f '/projects' , params = {'per_page' : 1000 , 'page' : 1 })
427+ expected_call = FakeCall (method = 'GET' , path = '/projects' , params = {'per_page' : 1000 , 'page' : 1 })
458428 assert expected_call == session .last_call
459429 assert 5 == len (projects )
460430
@@ -472,6 +442,27 @@ def test_list_projects_with_page_params(collection, session):
472442 expected_call = FakeCall (method = 'GET' , path = f'/teams/{ collection .team_id } /projects' , params = {'per_page' : 10 , 'page' : 1 })
473443 assert expected_call == session .last_call
474444
445+ def test_search_all_no_team (session ):
446+ project_collection = ProjectCollection (session = session )
447+ projects_data = ProjectDataFactory .create_batch (2 )
448+ project_name_to_match = projects_data [0 ]['name' ]
449+
450+ search_params = {
451+ 'name' : {
452+ 'value' : project_name_to_match ,
453+ 'search_method' : 'EXACT' }}
454+ expected_response = [p for p in projects_data if p ["name" ] == project_name_to_match ]
455+
456+ project_collection .session .set_response ({'projects' : expected_response })
457+
458+ # Then
459+ results = list (project_collection .search_all (search_params = search_params ))
460+
461+ expected_call = FakeCall (method = 'POST' , path = '/projects/search' , params = {'userId' : '' }, json = {'search_params' : search_params })
462+
463+ assert 1 == project_collection .session .num_calls
464+ assert expected_call == project_collection .session .last_call
465+ assert 1 == len (results )
475466
476467def test_search_all (collection : ProjectCollection ):
477468 # Given
@@ -490,7 +481,7 @@ def test_search_all(collection: ProjectCollection):
490481 results = list (collection .search_all (search_params = search_params ))
491482
492483 expected_call = FakeCall (method = 'POST' ,
493- path = ' /projects/search' ,
484+ path = f'/teams/ { collection . team_id } /projects/search' ,
494485 params = {'userId' : '' },
495486 json = {'search_params' : {
496487 'name' : {
@@ -513,7 +504,7 @@ def test_search_all_no_search_params(collection: ProjectCollection):
513504 result = list (collection .search_all (search_params = None ))
514505
515506 expected_call = FakeCall (method = 'POST' ,
516- path = ' /projects/search' ,
507+ path = f'/teams/ { collection . team_id } /projects/search' ,
517508 params = {'userId' : '' },
518509 json = {})
519510
@@ -539,7 +530,7 @@ def test_search_projects(collection: ProjectCollection):
539530 result = list (collection .search (search_params = search_params ))
540531
541532 expected_call = FakeCall (method = 'POST' ,
542- path = ' /projects/search' ,
533+ path = f'/teams/ { collection . team_id } /projects/search' ,
543534 params = {'userId' : '' },
544535 json = {'search_params' : {
545536 'name' : {
@@ -561,7 +552,7 @@ def test_search_projects_no_search_params(collection: ProjectCollection):
561552 # Then
562553 result = list (collection .search ())
563554
564- expected_call = FakeCall (method = 'POST' , path = ' /projects/search' , params = {'userId' : '' }, json = {})
555+ expected_call = FakeCall (method = 'POST' , path = f'/teams/ { collection . team_id } /projects/search' , params = {'userId' : '' }, json = {})
565556
566557 assert 1 == collection .session .num_calls
567558 assert expected_call == collection .session .last_call
@@ -577,7 +568,7 @@ def test_delete_project(collection, session):
577568
578569 # Then
579570 assert 1 == session .num_calls
580- expected_call = FakeCall (method = 'DELETE' , path = '/projects/{}' . format ( uid ) )
571+ expected_call = FakeCall (method = 'DELETE' , path = f '/projects/{ uid } ' )
581572 assert expected_call == session .last_call
582573
583574
@@ -607,11 +598,8 @@ def test_list_members(project, session):
607598
608599 # Then
609600 assert 2 == session .num_calls
610- expect_call_1 = FakeCall (
611- method = 'GET' ,
612- path = '/teams/{}' .format (team_data ['id' ]),
613- )
614- expect_call_2 = FakeCall (method = 'GET' , path = '/teams/{}/users' .format (project .team_id ))
601+ expect_call_1 = FakeCall (method = 'GET' , path = f'/teams/{ team_data ["id" ]} ' )
602+ expect_call_2 = FakeCall (method = 'GET' , path = f'/teams/{ project .team_id } /users' )
615603 assert expect_call_1 == session .calls [0 ]
616604 assert expect_call_2 == session .calls [1 ]
617605 assert isinstance (members [0 ], TeamMember )
0 commit comments