Skip to content

Commit ba9d4f2

Browse files
feat: Add test suite structure for shopping_ads examples
- Created a new test directory `examples/shopping_ads/tests/`. - Added initial placeholder test files for each example script in `examples/shopping_ads/`. - Updated `noxfile.py` to ensure tests in the new directory are discovered by changing the start directory for `unittest discover` from `tests` to `.` (project root). All shopping_ads examples were already using Google Ads API v19, so no changes were needed for that.
1 parent 4f350a8 commit ba9d4f2

8 files changed

Lines changed: 100 additions & 1 deletion

examples/shopping_ads/tests/__init__.py

Whitespace-only changes.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import unittest
2+
from examples.shopping_ads import add_listing_scope
3+
4+
class TestAddListingScope(unittest.TestCase):
5+
def test_script_runs(self):
6+
# Basic test to ensure the main function can be imported and called.
7+
try:
8+
# Attempt to import and call the main function if it exists
9+
# This is a placeholder and might need adjustment based on the
10+
# actual structure of add_listing_scope.py
11+
add_listing_scope.main
12+
self.assertTrue(True)
13+
except AttributeError:
14+
self.fail("add_listing_scope.py does not have a main function or it's not importable.")
15+
except Exception as e:
16+
self.fail(f"Running add_listing_scope.py main function failed with {e}")
17+
18+
if __name__ == "__main__":
19+
unittest.main()
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import unittest
2+
from examples.shopping_ads import add_performance_max_product_listing_group_tree
3+
4+
class TestAddPerformanceMaxProductListingGroupTree(unittest.TestCase):
5+
def test_script_runs(self):
6+
# Basic test to ensure the main function can be imported and called.
7+
try:
8+
add_performance_max_product_listing_group_tree.main
9+
self.assertTrue(True)
10+
except AttributeError:
11+
self.fail("add_performance_max_product_listing_group_tree.py does not have a main function or it's not importable.")
12+
except Exception as e:
13+
self.fail(f"Running add_performance_max_product_listing_group_tree.py main function failed with {e}")
14+
15+
if __name__ == "__main__":
16+
unittest.main()
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import unittest
2+
from examples.shopping_ads import add_performance_max_retail_campaign
3+
4+
class TestAddPerformanceMaxRetailCampaign(unittest.TestCase):
5+
def test_script_runs(self):
6+
# Basic test to ensure the main function can be imported and called.
7+
try:
8+
add_performance_max_retail_campaign.main
9+
self.assertTrue(True)
10+
except AttributeError:
11+
self.fail("add_performance_max_retail_campaign.py does not have a main function or it's not importable.")
12+
except Exception as e:
13+
self.fail(f"Running add_performance_max_retail_campaign.py main function failed with {e}")
14+
15+
if __name__ == "__main__":
16+
unittest.main()
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import unittest
2+
from examples.shopping_ads import add_shopping_product_ad
3+
4+
class TestAddShoppingProductAd(unittest.TestCase):
5+
def test_script_runs(self):
6+
# Basic test to ensure the main function can be imported and called.
7+
try:
8+
add_shopping_product_ad.main
9+
self.assertTrue(True)
10+
except AttributeError:
11+
self.fail("add_shopping_product_ad.py does not have a main function or it's not importable.")
12+
except Exception as e:
13+
self.fail(f"Running add_shopping_product_ad.py main function failed with {e}")
14+
15+
if __name__ == "__main__":
16+
unittest.main()
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import unittest
2+
from examples.shopping_ads import add_shopping_product_listing_group_tree
3+
4+
class TestAddShoppingProductListingGroupTree(unittest.TestCase):
5+
def test_script_runs(self):
6+
# Basic test to ensure the main function can be imported and called.
7+
try:
8+
add_shopping_product_listing_group_tree.main
9+
self.assertTrue(True)
10+
except AttributeError:
11+
self.fail("add_shopping_product_listing_group_tree.py does not have a main function or it's not importable.")
12+
except Exception as e:
13+
self.fail(f"Running add_shopping_product_listing_group_tree.py main function failed with {e}")
14+
15+
if __name__ == "__main__":
16+
unittest.main()
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import unittest
2+
from examples.shopping_ads import get_product_category_constants
3+
4+
class TestGetProductCategoryConstants(unittest.TestCase):
5+
def test_script_runs(self):
6+
# Basic test to ensure the main function can be imported and called.
7+
try:
8+
get_product_category_constants.main
9+
self.assertTrue(True)
10+
except AttributeError:
11+
self.fail("get_product_category_constants.py does not have a main function or it's not importable.")
12+
except Exception as e:
13+
self.fail(f"Running get_product_category_constants.py main function failed with {e}")
14+
15+
if __name__ == "__main__":
16+
unittest.main()

noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"unittest",
2929
"discover",
3030
"--buffer",
31-
"-s=tests",
31+
"-s=.",
3232
"-p",
3333
"*_test.py",
3434
]

0 commit comments

Comments
 (0)