Skip to content

Commit

Permalink
Merge pull request #101 from shotgunsoftware/ticket/34500_travis_env_…
Browse files Browse the repository at this point in the history
…vars

For #34500 : Cleaning up tests so travis-ci can automate them all
  • Loading branch information
victoriagrey committed Feb 1, 2016
2 parents e5449df + 637b5d5 commit d65cd66
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
- [email protected]
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions shotgun_api3/shotgun.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@

# ----------------------------------------------------------------------------
# Version
__version__ = "3.0.26.dev"
__version__ = "3.0.26"

# ----------------------------------------------------------------------------
# Errors
Expand Down Expand Up @@ -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()
Expand Down
38 changes: 22 additions & 16 deletions tests/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Base class for Shotgun API tests."""
import os
import re
import unittest
from ConfigParser import ConfigParser
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit d65cd66

Please sign in to comment.