def standard_user_role_response( ) -> Tuple[str, List[Tuple[UserRole, ExpectedResponse]]]: all_roles = standard_role_response() return ( all_roles[0], [(user_role, response) for user_role, response in all_roles[1] if user_role not in [UserRole.ANONYMOUS, UserRole.GUEST]], )
@pytest.fixture() def cluster_create(faker: Faker) -> ClusterCreate: instance = ClusterCreate( name=faker.name(), endpoint=faker.uri(), type=random.choice(list(ClusterType)), authentication=SimpleAuthentication(username=faker.user_name(), password=faker.password()), ) assert instance return instance @pytest.mark.parametrize(*standard_role_response(), ids=str) async def test_create_cluster( enable_dev_features: None, mocked_director_v2_api, client: TestClient, logged_user: Dict[str, Any], faker: Faker, cluster_create: ClusterCreate, user_role: UserRole, expected: ExpectedResponse, ): cluster_create.access_rights[logged_user["id"]] = CLUSTER_ADMIN_RIGHTS print(f"--> creating {cluster_create=!r}") # check we can create a cluster assert client.app url = client.app.router["create_cluster_handler"].url_for()
StateType.PENDING, StateType.NOT_STARTED, ]), f"pipeline did not start yet... {set_of_states}" assert (len(set_of_states) == 1 ), f"there are more than one state in {set_of_states}" assert (expected_state in set_of_states ), f"{expected_state} not found in {set_of_states}" check_pipeline_results() # TESTS ------------------------------------------ @pytest.mark.parametrize( *standard_role_response(), ) async def test_start_pipeline( sleeper_service: Dict[str, str], postgres_session: sa.orm.session.Session, rabbit_service: RabbitConfig, redis_service: RedisConfig, simcore_services: Dict[str, URL], client, socketio_client_factory: Callable, logged_user: LoggedUser, user_project: NewProject, mock_workbench_adjacency_list: Dict, user_role: UserRole, expected: ExpectedResponse, ): project_id = user_project["uuid"]
assert actual_user["first_name"] == parts[0] assert "last_name" in actual_user assert actual_user["last_name"] == parts[1] assert "login" in actual_user assert actual_user["login"] == expected_user["email"] assert "gravatar_id" in actual_user assert actual_user["gravatar_id"] == gravatar_hash(expected_user["email"]) assert "accessRights" in actual_user assert actual_user["accessRights"] == expected_access_rights assert "id" in actual_user assert actual_user["id"] == expected_user["id"] assert "gid" in actual_user @pytest.mark.parametrize( *standard_role_response(), ) async def test_list_groups( client, logged_user, user_role, expected, primary_group: Dict[str, str], standard_groups: List[Dict[str, str]], all_group: Dict[str, str], ): url = client.app.router["list_groups"].url_for() assert str(url) == f"{PREFIX}" resp = await client.get(url) data, error = await assert_status( resp, expected.ok if user_role != UserRole.GUEST else web.HTTPOk)
def standard_user_role() -> Tuple[str, Tuple[UserRole, ExpectedResponse]]: all_roles = standard_role_response() return (all_roles[0], [pytest.param(*all_roles[1][2], id="standard user role")])