Skip to content

Commit

Permalink
Filter read by given run_id
Browse files Browse the repository at this point in the history
  • Loading branch information
MGibson1 committed Sep 26, 2024
1 parent 2844922 commit cb58c28
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions languages/python/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ def project_with_run_id(val: [dict]) -> [dict]:
return [dict(val, name=with_run_id(val["name"])) for val in val]


def filter_projects_to_this_run(projects: [ProjectResponse]) -> [ProjectResponse]:
if projects is None:
return None
return [project for project in projects if project.name.endswith(run_id)]


def filter_secrets_to_this_run(secrets: [SecretResponse]) -> [SecretResponse]:
if secrets is None:
return None
return [secret for secret in secrets if secret.key.endswith(run_id)]


def secret_with_run_id(val: [dict]) -> [dict]:
return [
dict(
Expand Down Expand Up @@ -100,7 +112,8 @@ def setUpClass(cls):

# Query for projects
cls.projects_response = cls.client.projects().list(organization_id)
cls.projects = getattr(cls.projects_response.data, "data", None)
cls.all_projects = getattr(cls.projects_response.data, "data", None)
cls.projects = filter_projects_to_this_run(cls.all_projects)
cls.mutable_projects_response = cls.mutable_client.projects().list(
organization_id
)
Expand All @@ -109,7 +122,7 @@ def setUpClass(cls):
@classmethod
def tearDownClass(cls):
os.remove(cls.state_path)
os.remove(cls.mutable_state_path)
os.remove(cls.immutable_state_path)


class ReadTests(PythonLanguageTests, unittest.TestCase):
Expand All @@ -129,7 +142,8 @@ def setUpClass(cls):
cls.secrets_response = cls.client.secrets().get_by_ids(
[secret.id for secret in cls.list_response.data.data]
)
cls.secrets = getattr(cls.secrets_response.data, "data", None)
cls.all_secrets = getattr(cls.secrets_response.data, "data", None)
cls.secrets = filter_secrets_to_this_run(cls.all_secrets)
cls.list = getattr(cls.list_response.data, "data", None)

def test_list_response_is_success(self):
Expand Down

0 comments on commit cb58c28

Please sign in to comment.