Skip to content

Commit

Permalink
🎨 Imporve formating
Browse files Browse the repository at this point in the history
🎨 Remove parentheses PT023

🎨 Extra formating changes
  • Loading branch information
Maciej Gardzinski committed Sep 26, 2024
1 parent f1eee82 commit 777354a
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 22 deletions.
1 change: 1 addition & 0 deletions src/viadot/orchestration/prefect/flows/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from .transform import transform
from .transform_and_catalog import transform_and_catalog


__all__ = [
"cloud_for_customers_to_adls",
"cloud_for_customers_to_databricks",
Expand Down
1 change: 1 addition & 0 deletions src/viadot/orchestration/prefect/tasks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from .sql_server import create_sql_server_table, sql_server_query, sql_server_to_df
from .supermetrics import supermetrics_to_df


__all__ = [
"adls_upload",
"bcp",
Expand Down
1 change: 1 addition & 0 deletions src/viadot/sources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from .supermetrics import Supermetrics, SupermetricsCredentials
from .uk_carbon_intensity import UKCarbonIntensity


__all__ = [
"CloudForCustomers",
"Epicor",
Expand Down
11 changes: 5 additions & 6 deletions src/viadot/utils.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Util functions."""

from collections.abc import Callable
import contextlib
from datetime import datetime, timezone
import functools
import logging
import re
import subprocess
from collections.abc import Callable
from datetime import datetime, timezone
from typing import TYPE_CHECKING, Any, Literal, Optional

import pandas as pd
Expand All @@ -20,6 +20,7 @@
from viadot.exceptions import APIError, ValidationError
from viadot.signals import SKIP


if TYPE_CHECKING:
from viadot.sources.base import Source

Expand Down Expand Up @@ -481,8 +482,7 @@ def join_dfs(
columns_from_right_df: list[str] | None = None,
how: Literal["left", "right", "outer", "inner", "cross"] = "left",
) -> pd.DataFrame:
"""
Combine Data Frames according to the chosen method.
"""Combine Data Frames according to the chosen method.
Args:
df_left (pd.DataFrame): Left dataframe.
Expand All @@ -500,13 +500,12 @@ def join_dfs(
if columns_from_right_df is None:
columns_from_right_df = df_right.columns

df_merged = df_left.merge(
return df_left.merge(
df_right[columns_from_right_df],
left_on=left_on,
right_on=right_on,
how=how,
)
return df_merged


def add_viadot_metadata_columns(func: Callable) -> Callable:
Expand Down
11 changes: 6 additions & 5 deletions tests/integration/orchestration/prefect/flows/test_mediatool.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
from viadot.orchestration.prefect.flows import mediatool_to_adls



def test_genesys_to_adls(azure_key_vault_secret,
organization_ids,
media_entries_columns,
adls_azure_key_vault_secret):
def test_genesys_to_adls(
azure_key_vault_secret,
organization_ids,
media_entries_columns,
adls_azure_key_vault_secret,
):
state = mediatool_to_adls(
azure_key_vault_secret=azure_key_vault_secret,
organization_ids=organization_ids,
Expand Down
23 changes: 12 additions & 11 deletions tests/unit/test_mediatool.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from viadot.sources import Mediatool
from viadot.sources.mediatool import MediatoolCredentials


variables = {
"credentials": {"user_id": "test_user", "token": "test_token"},
"organizations": {
Expand All @@ -22,13 +23,13 @@
}


@pytest.mark.basic()
@pytest.mark.basic
def test_mediatool_credentials():
"""Test Mediatool credentials."""
MediatoolCredentials(user_id="test_user", token="test_token")
MediatoolCredentials(user_id="test_user", token="test_token") # noqa: S106


@pytest.mark.basic()
@pytest.mark.basic
@patch("viadot.sources.mediatool.get_source_credentials", return_value=None)
def test_missing_credentials(mock_get_source_credentials):
"""Test raise error without credentials."""
Expand All @@ -38,7 +39,7 @@ def test_missing_credentials(mock_get_source_credentials):
mock_get_source_credentials.assert_called_once()


@pytest.mark.functions()
@pytest.mark.functions
@patch("viadot.sources.mediatool.handle_api_response")
def test_get_organizations(mock_handle_api_response):
"""Test Mediatool `_get_organizations` function."""
Expand All @@ -53,7 +54,7 @@ def test_get_organizations(mock_handle_api_response):
assert result == expected_result


@pytest.mark.functions()
@pytest.mark.functions
@patch("viadot.sources.mediatool.handle_api_response")
def test_get_media_entries(mock_handle_api_response):
"""Test Mediatool `_get_media_entries` function."""
Expand All @@ -68,7 +69,7 @@ def test_get_media_entries(mock_handle_api_response):
assert result == expected_result


@pytest.mark.functions()
@pytest.mark.functions
@patch("viadot.sources.mediatool.handle_api_response")
def test_get_vehicles(mock_handle_api_response):
"""Test Mediatool `_get_vehicles` function."""
Expand All @@ -83,7 +84,7 @@ def test_get_vehicles(mock_handle_api_response):
assert result == expected_result


@pytest.mark.functions()
@pytest.mark.functions
@patch("viadot.sources.mediatool.handle_api_response")
def test_get_campaigns(mock_handle_api_response):
"""Test Mediatool `_get_campaigns` function."""
Expand All @@ -98,7 +99,7 @@ def test_get_campaigns(mock_handle_api_response):
assert result == expected_result


@pytest.mark.functions()
@pytest.mark.functions
@patch("viadot.sources.mediatool.handle_api_response")
def test_get_media_types(mock_handle_api_response):
"""Test Mediatool `_get_media_types` function."""
Expand All @@ -113,7 +114,7 @@ def test_get_media_types(mock_handle_api_response):
assert result == expected_result


@pytest.mark.functions()
@pytest.mark.functions
def test_rename_columns():
"""Test Mediatool `_rename_columns` function."""
df = pd.DataFrame({"col1": [1, 2], "col2": [3, 4]})
Expand All @@ -125,7 +126,7 @@ def test_rename_columns():
pd.testing.assert_frame_equal(result, expected_result)


@pytest.mark.connect()
@pytest.mark.connect
@patch("viadot.sources.mediatool.handle_api_response")
def test_api_connection(mock_handle_api_response):
"""Test Mediatool `api_connection` method."""
Expand All @@ -140,7 +141,7 @@ def test_api_connection(mock_handle_api_response):
assert result == expected_result


@pytest.mark.functions()
@pytest.mark.functions
@patch("viadot.sources.mediatool.handle_api_response")
def test_to_df(mock_handle_api_response):
"""Test Mediatool `to_df` method."""
Expand Down

0 comments on commit 777354a

Please sign in to comment.