Skip to content

Commit

Permalink
tests: make more stable
Browse files Browse the repository at this point in the history
  • Loading branch information
wochinge committed Nov 7, 2023
1 parent 54c5cbc commit d8d54ce
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@

load_dotenv()


logger = structlog.get_logger(__name__)


def _get_file_names(integration_config: CommonConfig, workspace_name: str) -> List[str]:
list_response = httpx.get(
f"{integration_config.api_url}/workspaces/{workspace_name}/files",
headers={"Authorization": f"Bearer {integration_config.api_key}"},
params={"limit": 100},
)
assert list_response.status_code == HTTPStatus.OK
file_names: List[str] = list_response.json()["data"]
Expand Down Expand Up @@ -102,8 +102,10 @@ def upload_session_response() -> UploadSession:
wait=wait_fixed(1),
reraise=True,
)
def _wait_for_file_to_be_available(integration_config: CommonConfig, workspace_name: str) -> None:
assert len(_get_file_names(integration_config, workspace_name)) > 0
def _wait_for_file_to_be_available(
integration_config: CommonConfig, workspace_name: str, expected_file_count: int = 15
) -> None:
assert len(_get_file_names(integration_config, workspace_name)) >= expected_file_count


@pytest.fixture(scope="session")
Expand Down Expand Up @@ -135,7 +137,7 @@ def workspace_name(integration_config: CommonConfig) -> Generator[str, None, Non
)
assert response.status_code == HTTPStatus.CREATED

_wait_for_file_to_be_available(integration_config, workspace_name)
_wait_for_file_to_be_available(integration_config, workspace_name, expected_file_count=15)

yield workspace_name

Expand Down

0 comments on commit d8d54ce

Please sign in to comment.