Skip to content

Commit

Permalink
make gf config class variable and simplify fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloPardoGarcia committed Sep 18, 2024
1 parent af99445 commit 257d15f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 28 deletions.
3 changes: 2 additions & 1 deletion src/glassflow/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@


class APIClient:
glassflow_config = GlassFlowConfig()

def __init__(self):
self.client = requests_http.Session()
self.glassflow_config = GlassFlowConfig()

def _get_headers(
self, request: dataclass, req_content_type: Optional[str] = None
Expand Down
40 changes: 13 additions & 27 deletions tests/glassflow/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,35 @@
import pytest

from glassflow import GlassFlowClient, PipelineDataSink, PipelineDataSource
from glassflow.client import GlassFlowConfig
from glassflow.api_client import APIClient


@pytest.fixture
def staging_config():
config = GlassFlowConfig()
config.server_url = "https://staging.api.glassflow.dev/v1"
return config
# Use staging api server
APIClient.glassflow_config.server_url = "https://staging.api.glassflow.dev/v1"


@pytest.fixture
def client(staging_config):
c = GlassFlowClient()
c.glassflow_config = staging_config
return c
def client():
return GlassFlowClient()


@pytest.fixture
def source(pipeline_credentials, staging_config):
source = PipelineDataSource(**pipeline_credentials)
source.glassflow_config = staging_config
return source
def source(pipeline_credentials):
return PipelineDataSource(**pipeline_credentials)


@pytest.fixture
def source_with_invalid_access_token(pipeline_credentials_invalid_token, staging_config):
source = PipelineDataSource(**pipeline_credentials_invalid_token)
source.glassflow_config = staging_config
return source
def source_with_invalid_access_token(pipeline_credentials_invalid_token):
return PipelineDataSource(**pipeline_credentials_invalid_token)


@pytest.fixture
def source_with_non_existing_id(pipeline_credentials_invalid_id, staging_config):
source = PipelineDataSource(**pipeline_credentials_invalid_id)
source.glassflow_config = staging_config
return source
def source_with_non_existing_id(pipeline_credentials_invalid_id):
return PipelineDataSource(**pipeline_credentials_invalid_id)


@pytest.fixture
def sink(pipeline_credentials, staging_config):
sink = PipelineDataSink(**pipeline_credentials)
sink.glassflow_config = staging_config
return sink
def sink(pipeline_credentials):
return PipelineDataSink(**pipeline_credentials)


@pytest.fixture
Expand Down

0 comments on commit 257d15f

Please sign in to comment.