diff --git a/.coveragerc b/.coveragerc index 3e35ad8a..5878223d 100644 --- a/.coveragerc +++ b/.coveragerc @@ -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 diff --git a/.flake8 b/.flake8 new file mode 100644 index 00000000..bbe740df --- /dev/null +++ b/.flake8 @@ -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 + diff --git a/.hound.yml b/.hound.yml new file mode 100644 index 00000000..18025a11 --- /dev/null +++ b/.hound.yml @@ -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 + diff --git a/.travis.yml b/.travis.yml index 7caeb2ff..d8bfa73f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/README.md b/README.md index 8272db41..761006f5 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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). diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000..bd71103b --- /dev/null +++ b/appveyor.yml @@ -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" diff --git a/tests/ci_requirements.txt b/tests/ci_requirements.txt new file mode 100644 index 00000000..8bde5710 --- /dev/null +++ b/tests/ci_requirements.txt @@ -0,0 +1,2 @@ +coveralls==1.1 +nose \ No newline at end of file diff --git a/tests/run_appveyor.bat b/tests/run_appveyor.bat new file mode 100644 index 00000000..7b65b4c8 --- /dev/null +++ b/tests/run_appveyor.bat @@ -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 diff --git a/tests/test_api.py b/tests/test_api.py index a6bd6aa5..e83674d4 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -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.''' @@ -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)