Skip to content

Commit

Permalink
SG-19308 pip install fix. (#237)
Browse files Browse the repository at this point in the history
Fixes an issue where the cacert.pem inside the bundled certifi was included in a pip install.

The tests have also been changed to allow the CI testing to test via the pip installed Python API, to ensure that we are including everything that needs to be included when pip installing.

* Increase the amount of thumbnail request attempts.

Co-authored-by: Philip Scadding <philip.scadding@autodesk.com>
  • Loading branch information
jfboismenu and pscadding authored Nov 19, 2020
1 parent 9c90991 commit 73b1fab
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ matrix:
# command to install dependencies
install:
- pip install -r tests/ci_requirements.txt
- pip install . -U
before_script:
- cp ./tests/example_config ./tests/config
# Run flake and then run tests
script:
- if [ -n "$RUN_FLAKE" = true ]; then flake8; fi
- coverage run -m nose --config="nose.cfg"
- cd tests && coverage run -m nose --no-path-adjustment
after_success: coveralls
notifications:
email:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@
packages=find_packages(exclude=('tests',)),
script_args=script_args,
include_package_data=True,
package_data={'': ['cacerts.txt']},
package_data={'': ['cacerts.txt', 'cacert.pem']},
zip_safe=False,
)
6 changes: 3 additions & 3 deletions tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
def skip(f):
return lambda self: None

CONFIG_PATH = 'tests/config'


class TestBase(unittest.TestCase):
'''Base class for tests.
Expand Down Expand Up @@ -57,7 +55,9 @@ def setUpClass(cls):
# Since the file is read and never modified, we will only read
# it once in memory and be done.
cls.config = SgTestConfig()
cls.config.read_config(CONFIG_PATH)
cur_folder = os.path.dirname(os.path.abspath(__file__))
config_path = os.path.join(cur_folder, "config")
cls.config.read_config(config_path)

def setUp(self, auth_mode='ApiUser'):
self.human_login = self.config.human_login
Expand Down
4 changes: 3 additions & 1 deletion tests/run_appveyor.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@

copy tests\example_config tests\config
%PYTHON%\Scripts\pip install -r tests/ci_requirements.txt
%PYTHON%\Scripts\nosetests.exe -v --config="nose.cfg"
%PYTHON%\Scripts\pip install . -U
cd tests
%PYTHON%\Scripts\nosetests.exe -v --no-path-adjustment
2 changes: 1 addition & 1 deletion tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

from . import base

THUMBNAIL_MAX_ATTEMPTS = 12
THUMBNAIL_MAX_ATTEMPTS = 18
THUMBNAIL_RETRY_INTERAL = 5
TRANSIENT_IMAGE_PATH = "images/status/transient"

Expand Down
7 changes: 5 additions & 2 deletions tests/tests_unit.py → tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,12 @@ def test_found_correct_cert(self):
isn't set), is the one bundled with this API
"""
# Get the path to the cert file we expect the Shotgun API to find
cur_path = os.path.dirname(os.path.abspath(__file__))
cert_path = os.path.normpath(
os.path.join(cur_path, "..", "shotgun_api3", "lib", "certifi", "cacert.pem")
# Get the path relative to where we picked up the API and not relative
# to file on disk. On CI we pip install the API to run the tests
# so we have to pick the location from the installed copy.
# Call dirname to remove from __init__.py
os.path.join(os.path.dirname(api.__file__), "lib", "certifi", "cacert.pem")
)
# Now ensure that the path the SG API has found is correct.
self.assertEquals(cert_path, self.certs)
Expand Down

0 comments on commit 73b1fab

Please sign in to comment.