Skip to content

Commit e135038

Browse files
committed
use test.utils.mark_live_test rather than unittest.skipIf(...)
1 parent a6695fe commit e135038

File tree

13 files changed

+26
-41
lines changed

13 files changed

+26
-41
lines changed

test/test_azure/test_azure_blob_storage.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from parsons import AzureBlobStorage, Table
99
from parsons.utilities import files
10+
from test.utils import mark_live_test
1011

1112
TEST_ACCOUNT_NAME = os.getenv("PARSONS_AZURE_ACCOUNT_NAME")
1213
TEST_CREDENTIAL = os.getenv("PARSONS_AZURE_CREDENTIAL")
@@ -15,7 +16,7 @@
1516
TEST_FILE_CONTENTS = "Test"
1617

1718

18-
@unittest.skipIf(not os.getenv("LIVE_TEST"), "Skipping because not running live test")
19+
@mark_live_test
1920
class TestAzureBlobStorage(unittest.TestCase):
2021
def setUp(self):
2122
self.azure_blob = AzureBlobStorage(

test/test_box/test_box_storage.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from boxsdk.exception import BoxAPIException, BoxOAuthException
1010

1111
from parsons import Box, Table
12+
from test.utils import mark_live_test
1213

1314
"""Prior to running, you should ensure that the relevant environment
1415
variables have been set, e.g. via
@@ -28,7 +29,7 @@ def generate_random_string(length):
2829
return "".join(random.choice(string.ascii_letters) for i in range(length))
2930

3031

31-
@unittest.skipIf(not os.getenv("LIVE_TEST"), "Skipping because not running live test")
32+
@mark_live_test
3233
class TestBoxStorage(unittest.TestCase):
3334
def setUp(self) -> None:
3435
warnings.filterwarnings(action="ignore", message="unclosed", category=ResourceWarning)

test/test_civis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import os
21
import unittest
32

43
from parsons import CivisClient, Table
4+
from test.utils import mark_live_test
55

66
# from . import scratch_creds
77

88

9-
@unittest.skipIf(not os.environ.get("LIVE_TEST"), "Skipping because not running live test")
9+
@mark_live_test
1010
class TestCivisClient(unittest.TestCase):
1111
def setUp(self):
1212
self.civis = CivisClient()

test/test_databases/test_dbsync.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from parsons.databases.database_connector import DatabaseConnector
1111
from parsons.databases.sqlite import Sqlite
1212
from test.test_databases.fakes import FakeDatabase
13-
from test.utils import assert_matching_tables
13+
from test.utils import assert_matching_tables, mark_live_test
1414

1515
_dir = os.path.dirname(__file__)
1616

@@ -195,7 +195,7 @@ def initialize_db_connections(self) -> None:
195195

196196
# These tests interact directly with the Postgres database. In order to run, set the
197197
# env to LIVE_TEST='TRUE'.
198-
@unittest.skipIf(not os.environ.get("LIVE_TEST"), "Skipping because not running live test")
198+
@mark_live_test
199199
class TestPostgresDBSync(TestDBSync):
200200
db = Postgres
201201
setup_sql = f"""
@@ -209,6 +209,6 @@ class TestPostgresDBSync(TestDBSync):
209209

210210
# These tests interact directly with the Postgres database. In order to run, set the
211211
# env to LIVE_TEST='TRUE'.
212-
@unittest.skipIf(not os.environ.get("LIVE_TEST"), "Skipping because not running live test")
212+
@mark_live_test
213213
class TestRedshiftDBSync(TestPostgresDBSync):
214214
db = Redshift

test/test_databases/test_mysql.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
import os
21
import unittest
32

43
from parsons import MySQL, Table
54
from parsons.databases.mysql.create_table import MySQLCreateTable
6-
from test.utils import assert_matching_tables
5+
from test.utils import assert_matching_tables, mark_live_test
76

87

98
# These tests interact directly with the MySQL database. To run, set env variable "LIVE_TEST=True"
10-
@unittest.skipIf(not os.environ.get("LIVE_TEST"), "Skipping because not running live test")
9+
@mark_live_test
1110
class TestMySQLLive(unittest.TestCase):
1211
def setUp(self):
1312
self.mysql = MySQL()
@@ -41,7 +40,7 @@ def test_insert_data(self):
4140

4241

4342
# These tests interact directly with the MySQL database. To run, set env variable "LIVE_TEST=True"
44-
@unittest.skipIf(not os.environ.get("LIVE_TEST"), "Skipping because not running live test")
43+
@mark_live_test
4544
class TestMySQL(unittest.TestCase):
4645
def setUp(self):
4746
self.mysql = MySQL()

test/test_databases/test_postgres.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import pytest
55

66
from parsons import Postgres, Table
7-
from test.utils import assert_matching_tables
7+
from test.utils import assert_matching_tables, mark_live_test
88

99
# The name of the schema and will be temporarily created for the tests
1010
TEMP_SCHEMA = "parsons_test"
@@ -149,7 +149,7 @@ def test_create_statement(self):
149149
# These tests interact directly with the Postgres database
150150

151151

152-
@unittest.skipIf(not os.environ.get("LIVE_TEST"), "Skipping because not running live test")
152+
@mark_live_test
153153
class TestPostgresDB(unittest.TestCase):
154154
def setUp(self):
155155
self.temp_schema = TEMP_SCHEMA

test/test_databases/test_redshift.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from testfixtures import LogCapture
77

88
from parsons import S3, Redshift, Table
9-
from test.utils import assert_matching_tables, validate_list
9+
from test.utils import assert_matching_tables, mark_live_test, validate_list
1010

1111
# The name of the schema and will be temporarily created for the tests
1212
TEMP_SCHEMA = "parsons_test2"
@@ -381,7 +381,7 @@ def test_copy_statement_columns(self):
381381
# These tests interact directly with the Redshift database
382382

383383

384-
@unittest.skipIf(not os.environ.get("LIVE_TEST"), "Skipping because not running live test")
384+
@mark_live_test
385385
class TestRedshiftDB(unittest.TestCase):
386386
def setUp(self):
387387
self.temp_schema = TEMP_SCHEMA

test/test_donorbox/test_donorbox.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ def test_get_campaigns(self, m):
4242
]
4343
assert len(result.columns) == len(columns)
4444

45-
@unittest.skip("requires live account setup")
4645
@mark_live_test
4746
def test_get_campaigns_live_test(self):
4847
result = self.donorbox.get_campaigns()
@@ -74,7 +73,6 @@ def test_get_campaigns_with_id_filter(self, m):
7473
assert result.to_dicts()[0]["id"] == 366590
7574
assert result.to_dicts()[0]["name"] == "Membership Campaign"
7675

77-
@unittest.skip("requires live account setup")
7876
@mark_live_test
7977
def test_get_campaigns_with_id_filter_live_test(self):
8078
result = self.donorbox.get_campaigns(id=366590)
@@ -95,7 +93,6 @@ def test_get_campaigns_with_name_filter(self, m):
9593
assert result.to_dicts()[0]["id"] == 366590
9694
assert result.to_dicts()[0]["name"] == "Membership Campaign"
9795

98-
@unittest.skip("requires live account setup")
9996
@mark_live_test
10097
def test_get_campaigns_with_name_filter_live_test(self):
10198
result = self.donorbox.get_campaigns(name="Membership Campaign")
@@ -120,7 +117,6 @@ def test_get_campaigns_with_order_filter(self, m):
120117
result = self.donorbox.get_campaigns(order="asc")
121118
assert result["id"] == [366172, 366590]
122119

123-
@unittest.skip("requires live account setup")
124120
@mark_live_test
125121
def test_get_campaigns_with_order_filter_live_test(self):
126122
# check order of the ids without looking at IDs. or maybe look at updated/created date
@@ -182,7 +178,6 @@ def test_get_donations(self, m):
182178
]
183179
assert len(result.columns) == len(columns)
184180

185-
@unittest.skip("requires live account setup")
186181
@mark_live_test
187182
def test_get_donations_live_test(self):
188183
result = self.donorbox.get_donations()
@@ -228,7 +223,6 @@ def test_get_donations_live_test(self):
228223
assert result.columns == columns
229224
assert result.num_rows == 3
230225

231-
@unittest.skip("requires live account setup")
232226
@mark_live_test
233227
def test_get_donations_with_date_from_filter_live_test(self):
234228
# Correct formats (YYYY-mm-dd YYYY/mm/dd YYYYmmdd dd-mm-YYYY) successfully filter
@@ -243,7 +237,6 @@ def test_get_donations_with_date_from_filter_live_test(self):
243237
with pytest.raises(ValueError): # noqa: PT011
244238
self.donorbox.get_donations(date_from="10 20 2022")
245239

246-
@unittest.skip("requires live account setup")
247240
@mark_live_test
248241
def test_get_donations_with_date_to_filter_live_test(self):
249242
# Correct formats (YYYY-mm-dd YYYY/mm/dd YYYYmmdd dd-mm-YYYY) successfully filter
@@ -279,7 +272,6 @@ def test_get_donations_with_amount_min_filter(self, m):
279272
result = self.donorbox.get_donations(amount_min="5")
280273
assert result.num_rows == 0
281274

282-
@unittest.skip("requires live account setup")
283275
@mark_live_test
284276
def test_get_donations_with_amount_min_filter_live_test(self):
285277
result = self.donorbox.get_donations(amount_min="3")
@@ -310,7 +302,6 @@ def test_get_donations_with_amount_max_filter(self, m):
310302
result = self.donorbox.get_donations(amount_max="2")
311303
assert result.num_rows == 0
312304

313-
@unittest.skip("requires live account setup")
314305
@mark_live_test
315306
def test_get_donations_with_amount_max_filter_live_test(self):
316307
result = self.donorbox.get_donations(amount_max="3")
@@ -349,7 +340,6 @@ def test_get_donors(self, m):
349340
]
350341
assert len(result.columns) == len(columns)
351342

352-
@unittest.skip("requires live account setup")
353343
@mark_live_test
354344
def test_get_donors_live_test(self):
355345
result = self.donorbox.get_donors()
@@ -429,7 +419,6 @@ def test_get_plans(self, m):
429419
assert result.columns == columns
430420
assert result.num_rows == 3
431421

432-
@unittest.skip("requires live account setup")
433422
@mark_live_test
434423
def test_get_plans_live_test(self):
435424
result = self.donorbox.get_plans()
@@ -450,7 +439,6 @@ def test_get_plans_live_test(self):
450439
assert result.columns == columns
451440
assert result.num_rows == 3
452441

453-
@unittest.skip("requires live account setup")
454442
@mark_live_test
455443
def test_get_plans_with_date_from_filter_live_test(self):
456444
# Correct formats (YYYY-mm-dd YYYY/mm/dd YYYYmmdd dd-mm-YYYY) successfully filter
@@ -465,7 +453,6 @@ def test_get_plans_with_date_from_filter_live_test(self):
465453
with pytest.raises(ValueError): # noqa: PT011
466454
result = self.donorbox.get_plans(date_from="10 20 2022")
467455

468-
@unittest.skip("requires live account setup")
469456
@mark_live_test
470457
def test_get_plans_with_date_to_filter_live_test(self):
471458
# Correct formats (YYYY-mm-dd YYYY/mm/dd YYYYmmdd dd-mm-YYYY) successfully filter

test/test_facebook_ads.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import os
21
import unittest
32

43
import pytest
54

65
from parsons import FacebookAds, Table
6+
from test.utils import mark_live_test
77

88
users_table = Table(
99
[
@@ -27,7 +27,7 @@
2727
)
2828

2929

30-
@unittest.skipIf(not os.environ.get("LIVE_TEST"), "Skipping because not running live test")
30+
@mark_live_test
3131
class TestFacebookAdsIntegration(unittest.TestCase):
3232
def setUp(self):
3333
self.fb_ads = FacebookAds()

test/test_geocoder/test_census_geocoder.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import os
21
import unittest
32
from unittest import mock
43

54
import petl
65
from test_responses import batch_resp, coord_resp, geographies_resp, locations_resp
76

87
from parsons import CensusGeocoder, Table
9-
from test.utils import assert_matching_tables
8+
from test.utils import assert_matching_tables, mark_live_test
109

1110

12-
@unittest.skipIf(not os.environ.get("LIVE_TEST"), "Skipping because not running live test")
11+
@mark_live_test
1312
class TestCensusGeocoder(unittest.TestCase):
1413
def setUp(self):
1514
self.cg = CensusGeocoder()

0 commit comments

Comments
 (0)