Skip to content

Commit

Permalink
Added test skips to avoid throttling
Browse files Browse the repository at this point in the history
  • Loading branch information
miballe committed Sep 10, 2024
1 parent bfd309f commit f166bf3
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 1 deletion.
3 changes: 3 additions & 0 deletions test/auth/test_oauthuser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from factiva.analytics import OAuthUser
from factiva.analytics.common import config

GITHUB_CI = config.load_environment_value('CI', False)
FACTIVA_CLIENTID = config.load_environment_value("FACTIVA_CLIENTID")
FACTIVA_USERNAME = config.load_environment_value("FACTIVA_USERNAME")
FACTIVA_PASSWORD = config.load_environment_value("FACTIVA_PASSWORD")
Expand Down Expand Up @@ -50,6 +51,8 @@ def test_wrong_credentials():
Creates an object from the provided string
The key is invalid and this should validate how the error is processed
"""
if GITHUB_CI:
pytest.skip("Not to be tested in GitHub Actions")
with pytest.raises(PermissionError, match=r'Invalid user credentials'):
o = OAuthUser(client_id='client_id_value',
username='username_value',
Expand Down
7 changes: 7 additions & 0 deletions test/auth/test_userkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from factiva.analytics import UserKey
from factiva.analytics.common import config

GITHUB_CI = config.load_environment_value('CI', False)
FACTIVA_USERKEY = config.load_environment_value("FACTIVA_USERKEY")
DUMMY_KEY = 'abcd1234abcd1234abcd1234abcd1234'

Expand All @@ -13,6 +14,8 @@ def test_userkey_from_env():
"""
Creates an empty object from the ENV variable with a value only for the key property
"""
if GITHUB_CI:
pytest.skip("Not to be tested in GitHub Actions")
usr = UserKey()
assert usr.key == FACTIVA_USERKEY
assert isinstance(usr.cloud_token, dict)
Expand All @@ -22,6 +25,8 @@ def test_user_with_parameter_and_stats():
"""
API Key is passed as a string and stats=True
"""
if GITHUB_CI:
pytest.skip("Not to be tested in GitHub Actions")
usr = UserKey(FACTIVA_USERKEY)
assert usr.key == FACTIVA_USERKEY
assert isinstance(usr.cloud_token, dict)
Expand All @@ -32,6 +37,8 @@ def test_invalid_key():
Creates an object from the provided string and request the usage details to the API service
The key is invalid and this should validate how the error is processed
"""
if GITHUB_CI:
pytest.skip("Not to be tested in GitHub Actions")
with pytest.raises(ValueError, match=r'Factiva User-Key does not exist or inactive.'):
UserKey(DUMMY_KEY)

Expand Down
12 changes: 12 additions & 0 deletions test/snapshots/test_explain.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# Test operations before any API request

def test_create_from_envuser():
if GITHUB_CI:
pytest.skip("Not to be tested in GitHub Actions")
se = SnapshotExplain()
assert isinstance(se, SnapshotExplain)
assert se.user_key.key == ENVIRONMENT_USER_KEY
Expand All @@ -23,6 +25,8 @@ def test_create_from_envuser():
}

def test_create_from_user_param():
if GITHUB_CI:
pytest.skip("Not to be tested in GitHub Actions")
se = SnapshotExplain(user_key=VALID_USER_KEY)
assert isinstance(se, SnapshotExplain)
assert se.user_key.key == VALID_USER_KEY
Expand All @@ -33,6 +37,8 @@ def test_create_from_user_param():
}

def test_create_from_userkey():
if GITHUB_CI:
pytest.skip("Not to be tested in GitHub Actions")
u = UserKey()
assert isinstance(u, UserKey)
se = SnapshotExplain(user_key=u)
Expand All @@ -45,6 +51,8 @@ def test_create_from_userkey():
}

def test_create_envuser_where():
if GITHUB_CI:
pytest.skip("Not to be tested in GitHub Actions")
se = SnapshotExplain(query=VALID_WHERE_STATEMENT)
assert isinstance(se, SnapshotExplain)
assert se.user_key.key == ENVIRONMENT_USER_KEY
Expand All @@ -55,6 +63,8 @@ def test_create_envuser_where():
}

def test_create_envuser_envwhere():
if GITHUB_CI:
pytest.skip("Not to be tested in GitHub Actions")
seq = SnapshotExplainQuery()
assert isinstance(seq, SnapshotExplainQuery)
se = SnapshotExplain(query=seq)
Expand All @@ -67,6 +77,8 @@ def test_create_envuser_envwhere():
}

def test_failed_where_and_jobid():
if GITHUB_CI:
pytest.skip("Not to be tested in GitHub Actions")
with pytest.raises(ValueError, match=r'The query and job_id parameters*'):
se = SnapshotExplain(query=VALID_WHERE_STATEMENT, job_id='abcd1234-ab12-ab12-ab12-abcdef123456')
assert isinstance(se, SnapshotExplain)
Expand Down
12 changes: 12 additions & 0 deletions test/snapshots/test_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# Test operations before any API request

def test_create_from_envuser():
if GITHUB_CI:
pytest.skip("Not to be tested in GitHub Actions")
se = SnapshotExtraction()
assert isinstance(se, SnapshotExtraction)
assert se.user_key.key == ENVIRONMENT_USER_KEY
Expand All @@ -23,6 +25,8 @@ def test_create_from_envuser():
}

def test_create_from_user_param():
if GITHUB_CI:
pytest.skip("Not to be tested in GitHub Actions")
se = SnapshotExtraction(user_key=VALID_USER_KEY)
assert isinstance(se, SnapshotExtraction)
assert se.user_key.key == VALID_USER_KEY
Expand All @@ -34,6 +38,8 @@ def test_create_from_user_param():
}

def test_create_from_userkey():
if GITHUB_CI:
pytest.skip("Not to be tested in GitHub Actions")
u = UserKey()
assert isinstance(u, UserKey)
se = SnapshotExtraction(user_key=u)
Expand All @@ -47,6 +53,8 @@ def test_create_from_userkey():
}

def test_create_envuser_where():
if GITHUB_CI:
pytest.skip("Not to be tested in GitHub Actions")
se = SnapshotExtraction(query=VALID_WHERE_STATEMENT)
assert isinstance(se, SnapshotExtraction)
assert se.user_key.key == ENVIRONMENT_USER_KEY
Expand All @@ -58,6 +66,8 @@ def test_create_envuser_where():
}

def test_create_envuser_envwhere():
if GITHUB_CI:
pytest.skip("Not to be tested in GitHub Actions")
seq = SnapshotExtractionQuery()
assert isinstance(seq, SnapshotExtractionQuery)
se = SnapshotExtraction(query=seq)
Expand All @@ -71,6 +81,8 @@ def test_create_envuser_envwhere():
}

def test_failed_where_and_jobid():
if GITHUB_CI:
pytest.skip("Not to be tested in GitHub Actions")
with pytest.raises(ValueError, match=r'The query and job_id parameters*'):
se = SnapshotExtraction(query=VALID_WHERE_STATEMENT, job_id='abcd1234-ab12-ab12-ab12-abcdef123456')
assert isinstance(se, SnapshotExtraction)
Expand Down
14 changes: 13 additions & 1 deletion test/snapshots/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@


def test_create_from_envuser():
if GITHUB_CI:
pytest.skip("Not to be tested in GitHub Actions")
sts = SnapshotTimeSeries()
assert isinstance(sts, SnapshotTimeSeries)
assert sts.user_key.key == ENVIRONMENT_USER_KEY
Expand All @@ -26,6 +28,8 @@ def test_create_from_envuser():
}

def test_create_from_user_param():
if GITHUB_CI:
pytest.skip("Not to be tested in GitHub Actions")
sts = SnapshotTimeSeries(user_key=VALID_USER_KEY)
assert isinstance(sts, SnapshotTimeSeries)
assert sts.user_key.key == VALID_USER_KEY
Expand All @@ -40,6 +44,8 @@ def test_create_from_user_param():
}

def test_create_from_userkey():
if GITHUB_CI:
pytest.skip("Not to be tested in GitHub Actions")
u = UserKey()
assert isinstance(u, UserKey)
sts = SnapshotTimeSeries(user_key=u)
Expand All @@ -56,6 +62,8 @@ def test_create_from_userkey():
}

def test_create_envuser_where():
if GITHUB_CI:
pytest.skip("Not to be tested in GitHub Actions")
sts = SnapshotTimeSeries(query=VALID_WHERE_STATEMENT)
assert isinstance(sts, SnapshotTimeSeries)
assert sts.user_key.key == ENVIRONMENT_USER_KEY
Expand All @@ -70,6 +78,8 @@ def test_create_envuser_where():
}

def test_create_envuser_envwhere():
if GITHUB_CI:
pytest.skip("Not to be tested in GitHub Actions")
seq = SnapshotTimeSeriesQuery()
assert isinstance(seq, SnapshotTimeSeriesQuery)
sts = SnapshotTimeSeries(query=seq)
Expand All @@ -86,14 +96,16 @@ def test_create_envuser_envwhere():
}

def test_failed_where_and_jobid():
if GITHUB_CI:
pytest.skip("Not to be tested in GitHub Actions")
with pytest.raises(ValueError, match=r'The query and job_id parameters*'):
sts = SnapshotTimeSeries(query=VALID_WHERE_STATEMENT, job_id='abcd1234-ab12-ab12-ab12-abcdef123456')
assert isinstance(sts, SnapshotTimeSeries)


# Test operations sending requests to the API
# These are only executed when running locally. For optimisation purposes
# no API tests are executed in the CI/CD (GitHub Actions) environment.
# no heavy API tests are executed in the CI/CD (GitHub Actions) environment.

def test_job_envuser_envwhere():
if GITHUB_CI:
Expand Down
8 changes: 8 additions & 0 deletions test/taxonomy/test_factivataxonomy.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import os
import pytest
import pandas as pd
from factiva.analytics import FactivaTaxonomy, FactivaTaxonomyCategories, UserKey
from factiva.analytics.common import config

GITHUB_CI = config.load_environment_value('CI', False)
FACTIVA_USERKEY = config.load_environment_value("FACTIVA_USERKEY")
SAVE_PATH = os.getcwd()

Expand All @@ -23,6 +25,8 @@ def test_create_taxonomy_instance_userkey_user():


def test_download_category_file():
if GITHUB_CI:
pytest.skip("Not to be tested in GitHub Actions")
t = FactivaTaxonomy()
assert t.download_raw_category(FactivaTaxonomyCategories.INDUSTRIES, path=SAVE_PATH)
assert t.download_raw_category(FactivaTaxonomyCategories.INDUSTRIES, path=SAVE_PATH, file_format='avro')
Expand All @@ -34,6 +38,8 @@ def test_download_category_file():


def test_get_category_codes():
if GITHUB_CI:
pytest.skip("Not to be tested in GitHub Actions")
t = FactivaTaxonomy()
industries = t.get_category_codes(FactivaTaxonomyCategories.INDUSTRIES)
assert isinstance(industries, pd.DataFrame)
Expand All @@ -43,6 +49,8 @@ def test_get_category_codes():


def test_lookup_code_good():
if GITHUB_CI:
pytest.skip("Not to be tested in GitHub Actions")
t = FactivaTaxonomy()
assert t.all_subjects == None
mcat = t.lookup_code('MCAT', FactivaTaxonomyCategories.SUBJECTS)
Expand Down

0 comments on commit f166bf3

Please sign in to comment.