From ef758f9ff9826a311ea115e9add12bd1a8073484 Mon Sep 17 00:00:00 2001 From: Robert Jambrecic Date: Tue, 10 Sep 2024 06:51:54 +0000 Subject: [PATCH 1/2] Update packages --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index fe2ac47..99787e6 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.143.0", + "google-api-python-client==2.144.0", "asyncify==0.10.0", "pandas==2.2.2" ] @@ -67,10 +67,10 @@ lint = [ "types-Pygments", "types-docutils", "mypy==1.11.2", - "ruff==0.6.3", + "ruff==0.6.4", "pyupgrade-directories==0.3.0", "bandit==1.7.9", - "semgrep==1.85.0", + "semgrep==1.86.0", "pytest-mypy-plugins==3.1.2", ] From f5cd870908ec6d280af1e5d6e5902365f94a0dbc Mon Sep 17 00:00:00 2001 From: Robert Jambrecic Date: Tue, 10 Sep 2024 08:07:36 +0000 Subject: [PATCH 2/2] Inserting ticket prices to headlines --- google_sheets/data_processing/processing.py | 4 ++++ tests/app/test_app.py | 10 +++++++--- tests/data_processing/test_processing.py | 5 +++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/google_sheets/data_processing/processing.py b/google_sheets/data_processing/processing.py index e878fc5..9a24701 100644 --- a/google_sheets/data_processing/processing.py +++ b/google_sheets/data_processing/processing.py @@ -33,6 +33,7 @@ def validate_input_data( INSERT_CRITERION_TYPE = "{INSERT_CRITERION_TYPE}" INSERT_LANGUAGE_CODE = "{INSERT_LANGUAGE_CODE}" INSERT_CATEGORY = "{INSERT_CATEGORY}" +INSERT_TICKET_PRICE = "{INSERT_TICKET_PRICE}" def _update_campaign_name( @@ -204,6 +205,9 @@ def _process_row( new_row = new_row.str.replace(INSERT_STATION_TO, station["Station To"]) new_row = new_row.str.replace(INSERT_CRITERION_TYPE, new_row["Match Type"]) new_row = new_row.str.replace(INSERT_CATEGORY, new_campaign_row["Category"]) + new_row = new_row.str.replace( + INSERT_TICKET_PRICE, new_campaign_row["Ticket Price"] + ) if target_resource == "ad": new_row["Final URL"] = station["Final Url"] diff --git a/tests/app/test_app.py b/tests/app/test_app.py index f7e717f..b00687f 100644 --- a/tests/app/test_app.py +++ b/tests/app/test_app.py @@ -409,6 +409,7 @@ class TestProcessData: "Final Url To", "Language Code", "Category", + "Ticket Price", ], [ "India", @@ -418,6 +419,7 @@ class TestProcessData: "https://www.example.com/to", "EN", "Bus", + "10.5", ], ] ), @@ -517,7 +519,7 @@ async def test_process_data_ads(self) -> None: "Bus", "https://www.example.com/from", "H" * 31, - "Headline 2", + "Headline 2 {INSERT_TICKET_PRICE}", "Headline 3", "Description Line 1", "Description Line 2", @@ -536,6 +538,7 @@ async def test_process_data_ads(self) -> None: "Final Url To", "Language Code", "Category", + "Ticket Price", ], [ "India", @@ -545,6 +548,7 @@ async def test_process_data_ads(self) -> None: "https://www.example.com/to", "EN", "Bus", + "10.5", ], ] ) @@ -588,7 +592,7 @@ async def test_process_data_ads(self) -> None: "Exact", "https://www.example.com/from", "HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH", - "Headline 2", + "Headline 2 10.5", "Headline 3", "Description Line 1", "Description Line 2", @@ -602,7 +606,7 @@ async def test_process_data_ads(self) -> None: "Exact", "https://www.example.com/to", "HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH", - "Headline 2", + "Headline 2 10.5", "Headline 3", "Description Line 1", "Description Line 2", diff --git a/tests/data_processing/test_processing.py b/tests/data_processing/test_processing.py index 65f3796..466c40b 100644 --- a/tests/data_processing/test_processing.py +++ b/tests/data_processing/test_processing.py @@ -137,6 +137,7 @@ def test_process_row( "Station To": "B", "Language Code": "EN", "Category": category, + "Ticket Price": "100", } ) final_df = pd.DataFrame(columns=template_row.index) @@ -177,6 +178,7 @@ def test_process_row( "Station To": ["C", "D"], "Language Code": ["EN", "EN"], "Category": ["Bus", "Bus"], + "Ticket Price": ["100", "200"], } ), pd.DataFrame( @@ -256,6 +258,7 @@ def test_process_row( "Station To": ["C", "D"], "Language Code": ["EN", "EN"], "Category": ["Bus", "Bus"], + "Ticket Price": ["100", "200"], } ), pd.DataFrame( @@ -339,6 +342,7 @@ def test_process_row( "Station To": ["C", "D"], "Language Code": ["EN", "DE"], "Category": ["Bus", "Bus"], + "Ticket Price": ["100", "200"], } ), pd.DataFrame( @@ -396,6 +400,7 @@ def test_process_row( "Station To": ["C", "D"], "Language Code": ["EN", "DE"], "Category": ["Bus", "Bus"], + "Ticket Price": ["100", "200"], } ), pd.DataFrame(