def test_get_template_folders_shows_user_folders_when_user_id_passed_in( app_, mock_get_template_folders, service_one, active_user_with_permissions, mocker ): mock_get_template_folders.return_value = _get_all_folders(active_user_with_permissions) service = Service(service_one) result = service.get_template_folders(user=User(active_user_with_permissions)) assert result == [ { 'name': ["Parent 1 - invisible", "1's Visible child"], 'id': mocker.ANY, 'parent_id': None, 'users_with_permission': [active_user_with_permissions['id']] }, { 'name': ["Parent 1 - invisible", ["1's Invisible child", "1's Visible grandchild"]], 'id': mocker.ANY, 'parent_id': None, 'users_with_permission': [active_user_with_permissions['id']] }, { 'name': "Parent 2 - visible", 'id': VIS_PARENT_FOLDER_ID, 'parent_id': None, 'users_with_permission': [active_user_with_permissions['id']] }, ]
def test_get_template_folders_shows_all_folders_when_user_id_not_passed_in( mock_get_template_folders, service_one, active_user_with_permissions, mocker ): mock_get_template_folders.return_value = _get_all_folders(active_user_with_permissions) service = Service(service_one) result = service.get_template_folders() assert result == [ { 'name': "Invisible folder", 'id': mocker.ANY, 'parent_id': None, 'users_with_permission': [] }, { 'name': "Parent 1 - invisible", 'id': INV_PARENT_FOLDER_ID, 'parent_id': None, 'users_with_permission': [] }, { 'name': "Parent 2 - visible", 'id': VIS_PARENT_FOLDER_ID, 'parent_id': None, 'users_with_permission': [active_user_with_permissions['id']], } ]
def test_get_template_folders_shows_all_folders_when_user_id_not_passed_in( mock_get_template_folders, service_one, active_user_with_permissions, mocker ): mock_get_template_folders.return_value = _get_all_folders(active_user_with_permissions) service = Service(service_one) result = service.get_template_folders() assert result == [ { "name": "Invisible folder", "id": mocker.ANY, "parent_id": None, "users_with_permission": [], }, { "name": "Parent 1 - invisible", "id": INV_PARENT_FOLDER_ID, "parent_id": None, "users_with_permission": [], }, { "name": "Parent 2 - visible", "id": VIS_PARENT_FOLDER_ID, "parent_id": None, "users_with_permission": [active_user_with_permissions["id"]], }, ]