-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #364 from dyvenia/dev
Release 0.4.0
- Loading branch information
Showing
45 changed files
with
2,374 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import logging | ||
import pandas as pd | ||
import os | ||
from typing import Any, Dict, List, Literal | ||
from prefect import Flow | ||
from prefect.tasks.secrets import PrefectSecret | ||
from prefect.run_configs import DockerRun | ||
from viadot.task_utils import df_to_csv, df_converts_bytes_to_int | ||
from viadot.tasks.aselite import ASELiteToDF | ||
from viadot.tasks import AzureDataLakeUpload | ||
from viadot.flows.aselite_to_adls import ASELiteToADLS | ||
|
||
|
||
TMP_FILE_NAME = "test_flow.csv" | ||
MAIN_DF = None | ||
|
||
df_task = ASELiteToDF() | ||
file_to_adls_task = AzureDataLakeUpload() | ||
|
||
|
||
def test_aselite_to_adls(): | ||
|
||
credentials_secret = PrefectSecret("aselite").run() | ||
vault_name = PrefectSecret("AZURE_DEFAULT_KEYVAULT").run() | ||
|
||
query_designer = """SELECT TOP 10 [ID] | ||
,[SpracheText] | ||
,[SpracheKat] | ||
,[SpracheMM] | ||
,[KatSprache] | ||
,[KatBasisSprache] | ||
,[CodePage] | ||
,[Font] | ||
,[Neu] | ||
,[Upd] | ||
,[UpdL] | ||
,[LosKZ] | ||
,[AstNr] | ||
,[KomKz] | ||
,[RKZ] | ||
,[ParentLanguageNo] | ||
,[UPD_FIELD] | ||
FROM [UCRMDEV].[dbo].[CRM_00]""" | ||
|
||
flow = ASELiteToADLS( | ||
"Test flow", | ||
query=query_designer, | ||
sqldb_credentials_secret=credentials_secret, | ||
vault_name=vault_name, | ||
file_path=TMP_FILE_NAME, | ||
to_path="raw/supermetrics/mp/result_df_flow_at_des_m.csv", | ||
run_config=None, | ||
) | ||
|
||
result = flow.run() | ||
assert result.is_successful() | ||
|
||
MAIN_DF = pd.read_csv(TMP_FILE_NAME, delimiter="\t") | ||
|
||
assert isinstance(MAIN_DF, pd.DataFrame) == True | ||
|
||
assert MAIN_DF.shape == (10, 17) | ||
|
||
os.remove(TMP_FILE_NAME) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from viadot.flows import MultipleFlows | ||
import logging | ||
|
||
|
||
def test_multiple_flows_working(caplog): | ||
list = [ | ||
["Flow of flows 1 test", "dev"], | ||
["Flow of flows 2 - working", "dev"], | ||
["Flow of flows 3", "dev"], | ||
] | ||
flow = MultipleFlows(name="test", flows_list=list) | ||
with caplog.at_level(logging.INFO): | ||
flow.run() | ||
assert "All of the tasks succeeded." in caplog.text | ||
|
||
|
||
def test_multiple_flows_not_working(caplog): | ||
list = [ | ||
["Flow of flows 1 test", "dev"], | ||
["Flow of flows 2 test - not working", "dev"], | ||
["Flow of flows 3", "dev"], | ||
] | ||
flow = MultipleFlows(name="test", flows_list=list) | ||
flow.run() | ||
assert "One of the flows has failed!" in caplog.text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from viadot.tasks import ASELiteToDF | ||
import pandas as pd | ||
|
||
|
||
def test_aselite_to_df(): | ||
query = """SELECT TOP (10) [usageid] | ||
,[configid] | ||
,[verticalid] | ||
,[textgroupid] | ||
,[nr] | ||
,[storedate] | ||
FROM [UCRMDEV_DESIGNER].[dbo].[PORTAL_APPLICATION_TEXTUSAGE]""" | ||
task = ASELiteToDF() | ||
df = task.run(query=query) | ||
assert isinstance(df, pd.DataFrame) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.