diff --git a/.travis.yml b/.travis.yml index caab72b3..cd190b41 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,11 +4,11 @@ python: - "2.7" # command to install dependencies install: - - pip install nose --use-mirrors + - pip install nose before_script: - cp ./tests/example_config ./tests/config # command to run tests -script: nosetests tests.tests_unit tests.test_client +script: nosetests -v notifications: email: - api@shotgunsoftware.com diff --git a/README.md b/README.md index efa52187..8e9c69e8 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,12 @@ Integration and unit tests are provided. ## Changelog -**v3.0.26 - TBD** +**v3.0.27 - TBD** + +**v3.0.26 - 2016 Feb 1** + + + Updating testing framework to use environment variables inconjunction with existing example_config file so that commits and pull requests are automatically run on travis-ci. + + Fix to prevent stripping out case-sensitivity of a URL if the user passes their credentials to config.server as an authrization header. **v3.0.25 - 2016 Jan 12** diff --git a/setup.py b/setup.py index b68bdafa..117c754e 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ setup( name='shotgun_api3', - version='3.0.25', + version='3.0.26', description='Shotgun Python API ', long_description=readme, author='Shotgun Software', diff --git a/shotgun_api3/shotgun.py b/shotgun_api3/shotgun.py index ff56db1a..06accf9c 100755 --- a/shotgun_api3/shotgun.py +++ b/shotgun_api3/shotgun.py @@ -78,7 +78,7 @@ # ---------------------------------------------------------------------------- # Version -__version__ = "3.0.26.dev" +__version__ = "3.0.26" # ---------------------------------------------------------------------------- # Errors @@ -422,7 +422,7 @@ def __init__(self, # if the service contains user information strip it out # copied from the xmlrpclib which turned the user:password into # and auth header - auth, self.config.server = urllib.splituser(self.config.server) + auth, self.config.server = urllib.splituser(urlparse.urlsplit(base_url).netloc) if auth: auth = base64.encodestring(urllib.unquote(auth)) self.config.authorization = "Basic " + auth.strip() diff --git a/tests/base.py b/tests/base.py index 201844b4..5ed11afb 100644 --- a/tests/base.py +++ b/tests/base.py @@ -1,4 +1,5 @@ """Base class for Shotgun API tests.""" +import os import re import unittest from ConfigParser import ConfigParser @@ -285,29 +286,34 @@ def setUp(self): class SgTestConfig(object): '''Reads test config and holds values''' def __init__(self): - self.mock = True - self.server_url = None - self.script_name = None - self.api_key = None - self.http_proxy = None - self.session_uuid = None - self.project_name = None - self.human_name = None - self.human_login = None - self.human_password = None - self.asset_code = None - self.version_code = None - self.shot_code = None - self.task_content = None + for key in self.config_keys(): + + # Look for any environment variables that match our test + # configuration naming of "SG_{KEY}". Default is None. + value = os.environ.get('SG_%s' % (str(key).upper())) + if key in ['mock']: + value = (value == None) or (str(value).lower() in ['true','1']) + setattr(self, key, value) + + def config_keys(self): + return [ + 'api_key', 'asset_code', 'http_proxy', 'human_login', 'human_name', + 'human_password', 'mock', 'project_name', 'script_name', + 'server_url', 'session_uuid', 'shot_code', 'task_content', + 'version_code' + ] def read_config(self, config_path): config_parser = ConfigParser() config_parser.read(config_path) for section in config_parser.sections(): for option in config_parser.options(section): - value = config_parser.get(section, option) - setattr(self, option, value) + # We only care about the configuration file if an environment + # variable has not already been set + if not getattr(self, option, None): + value = config_parser.get(section, option) + setattr(self, option, value) def _find_or_create_entity(sg, entity_type, data, identifyiers=None):