Skip to content
17 changes: 11 additions & 6 deletions tests/integration/feeds/test_feeds_client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
"""Integration tests for FeedsClient."""

import random
import string
import uuid
from pathlib import Path
from random import randint
from typing import BinaryIO, Callable
Expand All @@ -8,17 +11,19 @@
from nisystemlink.clients.core import ApiException
from nisystemlink.clients.feeds import FeedsClient
from nisystemlink.clients.feeds.models import CreateFeedRequest, Platform

from uplink import retry

FEED_DESCRIPTION = "Sample feed for uploading packages"
PACKAGE_PATH = str(
Path(__file__).parent.resolve()
/ "test_files"
/ "sample-measurement_0.5.0_windows_x64.nipkg"
)
PREFIX = "Feeds Client Test -"


@pytest.fixture(scope="class")
@retry(when=retry.when.status(429), stop=retry.stop.after_attempt(5))
def client(enterprise_config) -> FeedsClient:
"""Fixture to create a FeedsClient instance."""
return FeedsClient(enterprise_config)
Expand Down Expand Up @@ -73,13 +78,13 @@ def invalid_id() -> str:
@pytest.fixture(scope="class")
def get_feed_name():
"""Generate a feed name."""
name = "testfeed_"
feed_count = 0

def _get_feed_name():
nonlocal feed_count
feed_count += 1
feed_name = name + str(feed_count)

first_char = random.choice(string.ascii_letters)
uuid_part = uuid.uuid4().hex
feed_name = f"{PREFIX}{first_char}{uuid_part}"

return feed_name

yield _get_feed_name
Expand Down