From c1027a4ba35dd641961323070a83b6917322f5bc Mon Sep 17 00:00:00 2001 From: rjambrecic <32619626+rjambrecic@users.noreply.github.com> Date: Mon, 26 Aug 2024 11:07:10 +0200 Subject: [PATCH 1/4] Update packages (#81) --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4c803db..bd55176 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" ] @@ -70,7 +70,7 @@ lint = [ "ruff==0.5.4", "pyupgrade-directories==0.3.0", "bandit==1.7.9", - "semgrep==1.84.1", + "semgrep==1.85.0", "pytest-mypy-plugins==3.1.2", ] From 10d5153debb041282c4274ed84db5ea8263ef53d Mon Sep 17 00:00:00 2001 From: rjambrecic <32619626+rjambrecic@users.noreply.github.com> Date: Tue, 27 Aug 2024 10:44:02 +0200 Subject: [PATCH 2/4] Set Ad Group Name to None if Level value contains 'Campaign' (#87) --- google_sheets/data_processing/processing.py | 2 +- tests/data_processing/test_processing.py | 51 +++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/google_sheets/data_processing/processing.py b/google_sheets/data_processing/processing.py index 65d2e4d..872f378 100644 --- a/google_sheets/data_processing/processing.py +++ b/google_sheets/data_processing/processing.py @@ -229,7 +229,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( diff --git a/tests/data_processing/test_processing.py b/tests/data_processing/test_processing.py index 8d8a056..44ffd74 100644 --- a/tests/data_processing/test_processing.py +++ b/tests/data_processing/test_processing.py @@ -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( From dcfcab0962005119f0f18a0a6b40f076baee82c7 Mon Sep 17 00:00:00 2001 From: rjambrecic <32619626+rjambrecic@users.noreply.github.com> Date: Tue, 27 Aug 2024 10:57:16 +0200 Subject: [PATCH 3/4] Update packages (#88) Co-authored-by: Kumaran Rajendhiran --- pyproject.toml | 9 +++++---- tests/app/test_app.py | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index bd55176..707a414 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,7 +56,7 @@ dependencies = [ # public distributions server = [ - "uvicorn==0.30.3", + "uvicorn==0.30.6", ] # dev dependencies @@ -67,7 +67,7 @@ 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.85.0", @@ -75,9 +75,9 @@ lint = [ ] 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 = [ @@ -200,6 +200,7 @@ markers = [ "slow", "all", ] +asyncio_default_fixture_loop_scope = "function" [tool.coverage.run] parallel = true diff --git a/tests/app/test_app.py b/tests/app/test_app.py index 493ceab..613fbe8 100644 --- a/tests/app/test_app.py +++ b/tests/app/test_app.py @@ -301,7 +301,7 @@ class TestProcessCampaignData: ), ], ) - @pytest.mark.asyncio() + @pytest.mark.asyncio async def test_process_campaign_data( self, template_sheet_values: GoogleSheetValues, @@ -455,7 +455,7 @@ class TestProcessData: ), ], ) - @pytest.mark.asyncio() + @pytest.mark.asyncio async def test_process_data_keywords( self, template_sheet_values: GoogleSheetValues, @@ -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=[ From 77a23f1abcfe5947466d9f7921ea2756b3d80a7f Mon Sep 17 00:00:00 2001 From: rjambrecic <32619626+rjambrecic@users.noreply.github.com> Date: Wed, 28 Aug 2024 11:46:37 +0200 Subject: [PATCH 4/4] Add columns which start with 'Sitelink' to the new routes sheet (#89) Co-authored-by: Kumaran Rajendhiran --- google_sheets/data_processing/processing.py | 1 + tests/data_processing/test_processing.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/google_sheets/data_processing/processing.py b/google_sheets/data_processing/processing.py index 872f378..10177d1 100644 --- a/google_sheets/data_processing/processing.py +++ b/google_sheets/data_processing/processing.py @@ -71,6 +71,7 @@ def _validate_language_codes( "Include Location", "Include Language", "Exclude Language", + "Sitelink", ] diff --git a/tests/data_processing/test_processing.py b/tests/data_processing/test_processing.py index 44ffd74..553c686 100644 --- a/tests/data_processing/test_processing.py +++ b/tests/data_processing/test_processing.py @@ -353,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( @@ -370,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", } ), ),