def test_init(mock_settings): """Expect proper initialization from arguments.""" client = StructurizrClient(settings=mock_settings) assert client.url == "https://api.structurizr.com" assert client.workspace_id == 19 assert client.api_key == "7f4e4edc-f61c-4ff2-97c9-ea4bc2a7c98c" assert client.api_secret == "ae140655-da7c-4a8d-9467-5a7d9792fca0" assert client.user == "astley@localhost" assert client.agent == "structurizr-python/1.0.0" assert str(client.workspace_archive_location) == "."
def test_suppressing_archive(mock_settings, mocker): """Test that when the archive location is None then no archive is written.""" old_settings = mock_settings._asdict() old_settings["workspace_archive_location"] = None new_mock_settings = MockSettings(**old_settings) client = StructurizrClient(settings=new_mock_settings) mocked_open = mocker.mock_open(mock=mocker.Mock(spec_set=GzipFile)) mocker.patch("gzip.open", mocked_open) client._archive_workspace('{"mock_key":"mock_value"}') assert not mocked_open.called
def client(mock_settings) -> StructurizrClient: """Provide a client instance with the mock settings.""" return StructurizrClient(settings=mock_settings)