Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
[report]
source = shotgun_api3
omit = shotgun_api3/lib/*
# Copyright (c) 2018 Shotgun Software Inc.
#
# CONFIDENTIAL AND PROPRIETARY
#
# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit
# Source Code License included in this distribution package. See LICENSE.
# By accessing, using, copying or modifying this work you indicate your
# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights
# not expressly granted therein are reserved by Shotgun Software Inc.
#
# coverage configuration - used by https://coveralls.io/ integration
#
#

[run]
source=shotgun_api3
omit=
shotgun_api3/lib/httplib2/*
shotgun_api3/lib/simplejson/*
shotgun_api3/lib/xmlrpclib.py
49 changes: 49 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright (c) 2018 Shotgun Software Inc.
#
# CONFIDENTIAL AND PROPRIETARY
#
# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit
# Source Code License included in this distribution package. See LICENSE.
# By accessing, using, copying or modifying this work you indicate your
# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights
# not expressly granted therein are reserved by Shotgun Software Inc.

# Flake 8 PEP and lint configuration - https://gitlab.com/pycqa/flake8
#
# This defines the official lint and PEP8 rules for this repository
#
# You can run this locally by doing pep install flake8 and then
# >flake8 /path/to/core
#
# This is also used by the hound CI - see the .hound.yml config file.
#
#
[flake8]

# things we don't want to lint
exclude =
.git,
.flake8,
.gitignore,
.travis.yml,
.cache,
.eggs,
*.rst,
*.yml,
*.pyc,
*.pyo,
*.egg-info,
__pycache__,
# Those are our third parties, do not lint them!
shotgun_api3/lib/httplib2/*.py,
shotgun_api3/lib/simplejson/*.py,
shotgun_api3/lib/xmlrpclib.py

# exceptions
#
# E501 line too long (112 > 79 characters)
# E402 module level import not top of file
# E999 SyntaxError: invalid syntax (hack for hound CI which runs python 3.x)

ignore = E501, E402, E999

16 changes: 16 additions & 0 deletions .hound.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (c) 2017 Shotgun Software Inc.
#
# CONFIDENTIAL AND PROPRIETARY
#
# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit
# Source Code License included in this distribution package. See LICENSE.
# By accessing, using, copying or modifying this work you indicate your
# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights
# not expressly granted therein are reserved by Shotgun Software Inc.

# https://houndci.com configuration file for linting and PEP8

python:
enabled: true
config_file: .flake8

5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ python:
- "2.7"
# command to install dependencies
install:
- pip install nose
- pip install -r tests/ci_requirements.txt
before_script:
- cp ./tests/example_config ./tests/config
# command to run tests
script: nosetests -v
script: coverage run -m nose
after_success: coveralls
notifications:
email:
- api@shotgunsoftware.com
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
[![VFX Platform](https://img.shields.io/badge/vfxplatform-2018-yellow.svg)](http://www.vfxplatform.com/)
[![Reference Documentation](http://img.shields.io/badge/doc-reference-blue.svg)](http://developer.shotgunsoftware.com/python-api)
[![Build Status Linux](https://secure.travis-ci.org/shotgunsoftware/python-api.svg?branch=master)](http://travis-ci.org/shotgunsoftware/python-api)
[![Build status Windows](https://ci.appveyor.com/api/projects/status/slvw7u4jatvdly98/branch/master?svg=true
)](https://ci.appveyor.com/project/jfboismenu/python-api/branch/master)
[![Coverage Status](https://coveralls.io/repos/github/shotgunsoftware/python-api/badge.svg?branch=master)](https://coveralls.io/github/shotgunsoftware/python-api?branch=master)
[![Linting](https://img.shields.io/badge/PEP8%20by-Hound%20CI-a873d1.svg)](https://houndci.com)

# Shotgun Python API

Shotgun provides a simple Python-based API for accessing Shotgun and integrating with other tools. This is the official API that is maintained by Shotgun Software (support@shotgunsoftware.com)
Expand Down Expand Up @@ -32,9 +40,6 @@ You can see the [full history of the Python API on the documentation site](http:

Integration and unit tests are provided.

[![Build Status](https://secure.travis-ci.org/shotgunsoftware/python-api.svg?branch=master)](http://travis-ci.org/shotgunsoftware/python-api)


- All tests require the [nose unit testing tools](http://nose.readthedocs.org), and a `tests/config` file (you can copy an example from `tests/example_config`).
- Tests can be run individually like this: `nosetest tests/test_client.py`
- `test_client` and `tests_unit` use mock server interaction and do not require a Shotgun instance to be available (no modifications to `tests/config` are necessary).
Expand Down
39 changes: 39 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright (c) 2017 Shotgun Software Inc.
#
# CONFIDENTIAL AND PROPRIETARY
#
# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit
# Source Code License included in this distribution package. See LICENSE.
# By accessing, using, copying or modifying this work you indicate your
# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights
# not expressly granted therein are reserved by Shotgun Software Inc.

# https://www.appveyor.com/ Windows CI configuration file.

environment:
matrix:
- PYTHON: "C:\\Python27"

# To update these values, visit AppVeyor's site, click the user icon and scroll down to Encrypt Data.
SG_SERVER_URL:
secure: lIYAxmyz5GEvnbxqE1pAoNuU5+04RYsSzfjRxjqV7vI=
SG_HUMAN_LOGIN: appveyor
SG_HUMAN_NAME: App Veyor
SG_HUMAN_PASSWORD:
secure: 0/BofzMkXtzwtRqzC94FHt3lcyMBG0rr2w0rUropeT4=
SG_SCRIPT_NAME: python-api-test
SG_API_KEY:
secure: cTW+pBjl1H17hsjDOvLaspqkc3H9juXfOhoXMvdcA2l3b5FQeJVYUBWaJUxmqTw9gEzAHmUS6R4WVvw07IWOQ9on8UFHsHqv3JkL2Ji/Oeo=
SG_PROJECT_NAME: SG unittest project for AppVeyor

build: off

test_script:
# Put your test command here.
# If you don't need to build C extensions on 64-bit Python 3.3 or 3.4,
# you can remove "build.cmd" from the front of the command, as it's
# only needed to support those cases.
# Note that you must use the environment variable %PYTHON% to refer to
# the interpreter you're using - Appveyor does not do anything special
# to put the Python version you want to use on PATH.
- "tests\\run_appveyor.bat"
2 changes: 2 additions & 0 deletions tests/ci_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
coveralls==1.1
nose
17 changes: 17 additions & 0 deletions tests/run_appveyor.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
:: Copyright (c) 2018 Shotgun Software Inc.
::
:: CONFIDENTIAL AND PROPRIETARY
::
:: This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit
:: Source Code License included in this distribution package. See LICENSE.
:: By accessing, using, copying or modifying this work you indicate your
:: agreement to the Shotgun Pipeline Toolkit Source Code License. All rights
:: not expressly granted therein are reserved by Shotgun Software Inc.

::
:: This file is run by the appveyor builds.
::

copy tests\example_config tests\config
%PYTHON%\Scripts\pip install -r tests/ci_requirements.txt
%PYTHON%\Scripts\nosetests.exe -v
13 changes: 12 additions & 1 deletion tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,14 @@ def test_summary_values(self):
self.sg.batch(batch_data)

self.assertEqual(result['summaries'], count)
self.assertEqual(result['groups'], groups)
# Do not assume the order of the summarized results.
self.assertEqual(
sorted(
result['groups'],
key=lambda x: x["group_name"]
),
groups
)

def test_ensure_ascii(self):
'''test_ensure_ascii tests ensure_unicode flag.'''
Expand Down Expand Up @@ -1588,6 +1595,10 @@ def test_bad_auth(self):
sg = shotgun_api3.Shotgun(server_url, login=login, password='not a real password')
self.assertRaises(shotgun_api3.AuthenticationFault, sg.find_one, 'Shot',[])

# This may trigger an account lockdown. Make sure it is not locked anymore.
user = self.sg.find_one("HumanUser", [["login", "is", login]])
self.sg.update("HumanUser", user["id"], {"locked_until": None})

@patch('shotgun_api3.shotgun.Http.request')
def test_status_not_200(self, mock_request):
response = MagicMock(name="response mock", spec=dict)
Expand Down