Skip to content

Commit

Permalink
Separate state files
Browse files Browse the repository at this point in the history
  • Loading branch information
MGibson1 committed Sep 26, 2024
1 parent 7cedc78 commit eb22826
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions languages/python/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def secret_with_project_id(val: [dict], projects: [ProjectResponse]) -> [dict]:
]


def secrets_equal(a: dict, b: SecretResponse, projects: [ProjectResponse]) -> bool:
def secrets_equal(a: dict, b: SecretResponse) -> bool:
return (
a["key"] == b.key
and a["project_id"] == b.project_id
Expand Down Expand Up @@ -91,11 +91,11 @@ def setUpClass(cls):
cls.mutable_client = BitwardenClient(settings)

# authenticate
print(cls)
cls.state_path = os.path.join(language_tests_path, "state.json")
cls.mutable_state_path = os.path.join(language_tests_path, "mutable_state.json")
cls.client.auth().login_access_token(os.getenv("ACCESS_TOKEN"), cls.state_path)
cls.mutable_client.auth().login_access_token(
os.getenv("MUTABLE_ACCESS_TOKEN"), cls.state_path
os.getenv("MUTABLE_ACCESS_TOKEN"), cls.mutable_state_path
)

# Query for projects
Expand All @@ -109,6 +109,7 @@ def setUpClass(cls):
@classmethod
def tearDownClass(cls):
os.remove(cls.state_path)
os.remove(cls.mutable_state_path)


class ReadTests(PythonLanguageTests, unittest.TestCase):
Expand Down Expand Up @@ -150,7 +151,7 @@ def test_secrets_have_correct_data(self):
None,
)
self.assertIsNotNone(expected_secret)
self.assertTrue(secrets_equal(expected_secret, secret, self.projects))
self.assertTrue(secrets_equal(expected_secret, secret))

def test_projects_have_correct_data(self):
expected_names = [p["name"] for p in self.expected_projects]
Expand All @@ -173,7 +174,7 @@ def test_sync(self):
None,
)
self.assertIsNotNone(expected_secret)
self.assertTrue(secrets_equal(expected_secret, secret, self.projects))
self.assertTrue(secrets_equal(expected_secret, secret))

def test_project_get_equal_to_list(self):
for project in self.projects:
Expand Down Expand Up @@ -222,7 +223,7 @@ def test_create_secret(self):
[self.write_project.id],
)
self.assertTrue(response.success)
self.assertTrue(secrets_equal(secret, response.data, self.projects))
self.assertTrue(secrets_equal(secret, response.data))

# delete
response = self.mutable_client.secrets().delete([response.data.id])
Expand Down Expand Up @@ -252,7 +253,7 @@ def test_update_secret(self):
[self.write_project.id],
)
self.assertTrue(response.success)
self.assertTrue(secrets_equal(updated_secret, response.data, self.projects))
self.assertTrue(secrets_equal(updated_secret, response.data))


class ProjectsWriteTests(PythonLanguageTests, unittest.TestCase):
Expand Down

0 comments on commit eb22826

Please sign in to comment.