Skip to content

Commit

Permalink
Merge pull request #90 from airtai/dev
Browse files Browse the repository at this point in the history
4 PRs
  • Loading branch information
kumaranvpl authored Aug 30, 2024
2 parents bb6e149 + 77a23f1 commit 2b36472
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 10 deletions.
3 changes: 2 additions & 1 deletion google_sheets/data_processing/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def _validate_language_codes(
"Include Location",
"Include Language",
"Exclude Language",
"Sitelink",
]


Expand Down Expand Up @@ -229,7 +230,7 @@ def process_data_f(
):
new_row["Match Type"] = new_row["Keyword Match Type"]

if new_row["Level"] == "Campaign":
if "Campaign" in new_row["Level"]:
new_row["Ad Group Name"] = None

final_df = pd.concat(
Expand Down
13 changes: 7 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ dependencies = [
"pydantic>=2.3,<3",
"fastapi>=0.110.2",
"prisma==0.13.1",
"google-api-python-client==2.140.0",
"google-api-python-client==2.142.0",
"asyncify==0.10.0",
"pandas==2.2.2"
]
Expand All @@ -56,7 +56,7 @@ dependencies = [
# public distributions

server = [
"uvicorn==0.30.3",
"uvicorn==0.30.6",
]

# dev dependencies
Expand All @@ -67,17 +67,17 @@ lint = [
"types-Pygments",
"types-docutils",
"mypy==1.11.0",
"ruff==0.5.4",
"ruff==0.6.2",
"pyupgrade-directories==0.3.0",
"bandit==1.7.9",
"semgrep==1.84.1",
"semgrep==1.85.0",
"pytest-mypy-plugins==3.1.2",
]

test-core = [
"coverage[toml]==7.6.0",
"coverage[toml]==7.6.1",
"pytest==8.3.2",
"pytest-asyncio==0.23.8",
"pytest-asyncio==0.24.0",
]

testing = [
Expand Down Expand Up @@ -200,6 +200,7 @@ markers = [
"slow",
"all",
]
asyncio_default_fixture_loop_scope = "function"

[tool.coverage.run]
parallel = true
Expand Down
6 changes: 3 additions & 3 deletions tests/app/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ class TestProcessCampaignData:
),
],
)
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_process_campaign_data(
self,
template_sheet_values: GoogleSheetValues,
Expand Down Expand Up @@ -455,7 +455,7 @@ class TestProcessData:
),
],
)
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_process_data_keywords(
self,
template_sheet_values: GoogleSheetValues,
Expand Down Expand Up @@ -491,7 +491,7 @@ async def test_process_data_keywords(
)
assert detail in exc.value.detail

@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_process_data_ads(self) -> None:
template_sheet_values = GoogleSheetValues(
values=[
Expand Down
55 changes: 55 additions & 0 deletions tests/data_processing/test_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,57 @@ def test_validate_input_data(df: pd.DataFrame, expected: str) -> None:
}
),
),
(
pd.DataFrame(
{
"Campaign Name": [
"{INSERT_COUNTRY} - {INSERT_STATION_FROM} - {INSERT_STATION_TO} - {INSERT_LANGUAGE_CODE}",
"{INSERT_COUNTRY} - {INSERT_STATION_FROM} - {INSERT_STATION_TO} - {INSERT_LANGUAGE_CODE}",
],
"Language Code": ["EN", "DE"],
"Ad Group Name": [
"{INSERT_STATION_FROM} - {INSERT_STATION_TO}",
"{INSERT_STATION_FROM} - {INSERT_STATION_TO}",
],
"Match Type": ["Exact", "Exact"],
}
),
pd.DataFrame(
{
"Keyword": ["k1", "k2"],
"Max CPC": ["", ""],
"Language Code": ["EN", "DE"],
"Negative": ["TRUE", "TRUE"],
"Level": ["Campaign", "Campaign List"],
"Keyword Match Type": ["Exact", "Exact"],
}
),
pd.DataFrame(
{
"Country": ["USA", "USA"],
"Station From": ["A", "B"],
"Station To": ["C", "D"],
"Language Code": ["EN", "DE"],
}
),
pd.DataFrame(
{
"Campaign Name": [
"USA - A - C - EN",
"USA - B - D - DE",
],
"Ad Group Name": [
None,
None,
],
"Match Type": ["Exact", "Exact"],
"Keyword": ["k1", "k2"],
"Max CPC": ["", ""],
"Negative": ["TRUE", "TRUE"],
"Level": ["Campaign", "Campaign List"],
}
),
),
],
)
def test_process_data_f(
Expand Down Expand Up @@ -302,6 +353,8 @@ def test_process_data_f(
"Include Location 2": "Croatia",
"Include Language 1": "English",
"Exclude Language 1": "German",
"Sitelink Asset ID 1": "111",
"Sitelink Asset ID 2": "222",
}
),
pd.Series(
Expand All @@ -319,6 +372,8 @@ def test_process_data_f(
"Include Location 2": "Croatia",
"Include Language 1": "English",
"Exclude Language 1": "German",
"Sitelink Asset ID 1": "111",
"Sitelink Asset ID 2": "222",
}
),
),
Expand Down

0 comments on commit 2b36472

Please sign in to comment.