Skip to content

Commit e6500b9

Browse files
authored
Fix rootlevel project lookup. (#29)
1 parent 45b5eb5 commit e6500b9

File tree

9 files changed

+26
-35
lines changed

9 files changed

+26
-35
lines changed

minder-tests/api-history.robot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Library resources.helpers
66
Library resources.profiles.Profiles
77
Library resources.github.GitHub
88

9-
Suite Setup Set Rest Base URL From Config
9+
Suite Setup Load Config
1010

1111
Test Setup Default Setup
1212
Test Teardown Default Teardown

minder-tests/api-profiles.robot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Library resources.profiles.Profiles
1414
Library resources.minder_restapi_lib.MinderRestApiLib
1515
Library resources.minderlib
1616

17-
Suite Setup Set Rest Base URL From Config
17+
Suite Setup Load Config
1818

1919
Test Setup Default Setup
2020
Test Teardown Default Teardown

minder-tests/api-project.robot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Resource resources/keywords.robot
33
Library resources.projects.Projects
44

5-
Suite Setup Set Rest Base URL From Config
5+
Suite Setup Load Config
66

77
Test Setup Default Setup
88
Test Teardown Default Teardown

minder-tests/api-provider.robot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Resource resources/keywords.robot
33
Library resources.oauth_service.OAuthService
44

5-
Suite Setup Set Rest Base URL From Config
5+
Suite Setup Load Config
66

77
Test Setup Default Setup
88
Test Teardown Default Teardown
@@ -33,4 +33,4 @@ Test Authorization URL API for GitHub OAuth
3333
Given Response Format Is Valid
3434
Then URL Is Not Empty
3535
And URL Is Authorization Code
36-
And State Is Not Empty
36+
And State Is Not Empty

minder-tests/api-repositories.robot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Library resources.repositories_service.RepositoriesService
1414
Library resources.github.GitHub
1515
Library resources.minderlib
1616

17-
Suite Setup Set Rest Base URL From Config
17+
Suite Setup Load Config
1818

1919
Test Setup Default Setup
2020
Test Teardown Default Teardown

minder-tests/api-tests.robot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Library resources.minder_restapi_lib.MinderRestApiLib
1111
Library resources.eval_results_service.EvalResultsService
1212
Library resources.rule_type_service.RuleTypeService
1313

14-
Suite Setup Set Rest Base URL From Config
14+
Suite Setup Load Config
1515

1616
Test Setup Create Project And Ruletypes
1717
Test Teardown Delete Ruletypes And Project

minder-tests/minder-tests.robot

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ Documentation Test suite for some simple Minder operations
33
44
Test Tags smoke
55

6-
Library resources.helpers
7-
Library resources/minderlib.py
6+
Resource resources/keywords.robot
7+
Resource resources/variables.robot
88

9-
Suite Setup Set Grpc Base URL From Config
9+
Library resources.helpers
10+
Library resources.minderlib
11+
12+
Suite Setup Load Config
1013

1114

1215
*** Variables ***
@@ -36,10 +39,3 @@ Project created
3639
Given I Am Logged Into Minder
3740
When I List My Projects
3841
Then I Should Have At Least One Project
39-
40-
41-
*** Keywords ***
42-
Set Grpc Base URL From Config
43-
[Documentation] Reads the GRPC_BASE_URL from the config file and sets it for all tests.
44-
${GRPC_BASE_URL}= Get Grpc URL From Config
45-
Set Suite Variable ${GRPC_BASE_URL}

resources/keywords.robot

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ Library BuiltIn
1212
Library RequestsLibrary
1313

1414
*** Keywords ***
15-
Set Rest Base URL From Config
16-
[Documentation] Reads the BASE_URL from the config file and sets it for all tests.
15+
Load Config
16+
[Documentation] Reads tests' config file and sets useful variables for all tests.
1717
${BASE_URL}= Get Rest URL From Config
1818
Set Suite Variable ${BASE_URL}
19+
${root_project}= Get Environment Variable MINDER_PROJECT
20+
Set Suite Variable ${root_project}
21+
${GRPC_BASE_URL}= Get Grpc URL From Config
22+
Set Suite Variable ${GRPC_BASE_URL}
1923

2024
Create Ruletypes
2125
[Documentation] Create the ruletypes for the current project.
@@ -39,4 +43,4 @@ Set Project as Environment Variable With Test Name
3943
Remove Project Environment Variable For Test
4044
[Documentation] Remove the environment variable after the test.
4145
Remove Minder Project With Test Name
42-
Remove Environment Variable MINDER_PROJECT
46+
Set Environment Variable MINDER_PROJECT ${root_project}

resources/projects.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from robot.api import logger
21
from robot.api.deco import keyword
32
from robot.libraries.BuiltIn import BuiltIn
43
import re
@@ -40,20 +39,12 @@ def get_toplevel_project(self):
4039
Raises:
4140
Exception: If the API request fails or the expected project is not found.
4241
"""
43-
try:
44-
data = self.rest_api.get_request("/user")
45-
logger.debug(f"Received response: {data}")
46-
47-
for project in data.get("projects", []):
48-
if project.get("description") == "A self-enrolled project.":
49-
logger.info(
50-
f"Found self-enrolled project with UUID: {project['projectId']}"
51-
)
52-
return project["projectId"]
53-
54-
raise Exception("No self-enrolled project found in the response")
55-
except Exception as e:
56-
raise Exception(f"Failed to get top-level project: {str(e)}")
42+
project_id = BuiltIn().get_variable_value("${root_project}")
43+
if project_id is None:
44+
raise Exception("Variable ${root_project} is not set")
45+
if project_id == "":
46+
raise Exception("Variable ${root_project} is empty")
47+
return project_id
5748

5849
@keyword
5950
def client_lists_roles(self):

0 commit comments

Comments
 (0)