Skip to content

Commit d65cd66

Browse files
committed
Merge pull request #101 from shotgunsoftware/ticket/34500_travis_env_vars
For #34500 : Cleaning up tests so travis-ci can automate them all
2 parents e5449df + 637b5d5 commit d65cd66

File tree

5 files changed

+33
-22
lines changed

5 files changed

+33
-22
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ python:
44
- "2.7"
55
# command to install dependencies
66
install:
7-
- pip install nose --use-mirrors
7+
- pip install nose
88
before_script:
99
- cp ./tests/example_config ./tests/config
1010
# command to run tests
11-
script: nosetests tests.tests_unit tests.test_client
11+
script: nosetests -v
1212
notifications:
1313
email:
1414

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ Integration and unit tests are provided.
5353

5454
## Changelog
5555

56-
**v3.0.26 - TBD**
56+
**v3.0.27 - TBD**
57+
58+
**v3.0.26 - 2016 Feb 1**
59+
60+
+ 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.
61+
+ Fix to prevent stripping out case-sensitivity of a URL if the user passes their credentials to config.server as an authrization header.
5762

5863
**v3.0.25 - 2016 Jan 12**
5964

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
setup(
1919
name='shotgun_api3',
20-
version='3.0.25',
20+
version='3.0.26',
2121
description='Shotgun Python API ',
2222
long_description=readme,
2323
author='Shotgun Software',

shotgun_api3/shotgun.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878

7979
# ----------------------------------------------------------------------------
8080
# Version
81-
__version__ = "3.0.26.dev"
81+
__version__ = "3.0.26"
8282

8383
# ----------------------------------------------------------------------------
8484
# Errors
@@ -422,7 +422,7 @@ def __init__(self,
422422
# if the service contains user information strip it out
423423
# copied from the xmlrpclib which turned the user:password into
424424
# and auth header
425-
auth, self.config.server = urllib.splituser(self.config.server)
425+
auth, self.config.server = urllib.splituser(urlparse.urlsplit(base_url).netloc)
426426
if auth:
427427
auth = base64.encodestring(urllib.unquote(auth))
428428
self.config.authorization = "Basic " + auth.strip()

tests/base.py

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Base class for Shotgun API tests."""
2+
import os
23
import re
34
import unittest
45
from ConfigParser import ConfigParser
@@ -285,29 +286,34 @@ def setUp(self):
285286
class SgTestConfig(object):
286287
'''Reads test config and holds values'''
287288
def __init__(self):
288-
self.mock = True
289-
self.server_url = None
290-
self.script_name = None
291-
self.api_key = None
292-
self.http_proxy = None
293-
self.session_uuid = None
294-
self.project_name = None
295-
self.human_name = None
296-
self.human_login = None
297-
self.human_password = None
298-
self.asset_code = None
299-
self.version_code = None
300-
self.shot_code = None
301-
self.task_content = None
302289

290+
for key in self.config_keys():
291+
292+
# Look for any environment variables that match our test
293+
# configuration naming of "SG_{KEY}". Default is None.
294+
value = os.environ.get('SG_%s' % (str(key).upper()))
295+
if key in ['mock']:
296+
value = (value == None) or (str(value).lower() in ['true','1'])
297+
setattr(self, key, value)
298+
299+
def config_keys(self):
300+
return [
301+
'api_key', 'asset_code', 'http_proxy', 'human_login', 'human_name',
302+
'human_password', 'mock', 'project_name', 'script_name',
303+
'server_url', 'session_uuid', 'shot_code', 'task_content',
304+
'version_code'
305+
]
303306

304307
def read_config(self, config_path):
305308
config_parser = ConfigParser()
306309
config_parser.read(config_path)
307310
for section in config_parser.sections():
308311
for option in config_parser.options(section):
309-
value = config_parser.get(section, option)
310-
setattr(self, option, value)
312+
# We only care about the configuration file if an environment
313+
# variable has not already been set
314+
if not getattr(self, option, None):
315+
value = config_parser.get(section, option)
316+
setattr(self, option, value)
311317

312318

313319
def _find_or_create_entity(sg, entity_type, data, identifyiers=None):

0 commit comments

Comments
 (0)