From 048fcbf92759ae8331b96ec2ab36be4d0ab3fd53 Mon Sep 17 00:00:00 2001 From: Serg Melikyan Date: Wed, 15 May 2013 16:48:19 +0400 Subject: [PATCH] Added .gitreview file Change-Id: I3245862dffd095f2d263bd53b46ba31f3cf6a7ed --- .gitreview | 4 ++ tests/__init__.py | 2 +- tests/muranoclient/__init__.py | 2 +- .../test_client_with_fake_http.py | 50 +++++++++---------- tests/muranoclient/test_methods.py | 15 +++--- tox.ini | 14 +++++- 6 files changed, 51 insertions(+), 36 deletions(-) create mode 100644 .gitreview diff --git a/.gitreview b/.gitreview new file mode 100644 index 00000000..ff44003a --- /dev/null +++ b/.gitreview @@ -0,0 +1,4 @@ +[gerrit] +host=review.openstack.org +port=29418 +project=stackforge/python-muranoclient.git diff --git a/tests/__init__.py b/tests/__init__.py index 207fa154..7d93825c 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -10,4 +10,4 @@ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations -# under the License. \ No newline at end of file +# under the License. diff --git a/tests/muranoclient/__init__.py b/tests/muranoclient/__init__.py index 207fa154..7d93825c 100644 --- a/tests/muranoclient/__init__.py +++ b/tests/muranoclient/__init__.py @@ -10,4 +10,4 @@ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations -# under the License. \ No newline at end of file +# under the License. diff --git a/tests/muranoclient/test_client_with_fake_http.py b/tests/muranoclient/test_client_with_fake_http.py index aac196e2..e8d2b3f7 100644 --- a/tests/muranoclient/test_client_with_fake_http.py +++ b/tests/muranoclient/test_client_with_fake_http.py @@ -22,15 +22,14 @@ LOG = logging.getLogger('Unit tests') class UnitTestsForClassesAndFunctions(unittest.TestCase): - @httprettified def test_client_env_list_with_empty_list(self): HTTPretty.register_uri(HTTPretty.GET, "http://no-resolved-host:8001/environments", body='{"environments": []}', adding_headers={ - 'Content-Type': 'application/json',}) - endpoint = 'http://no-resolved-host:8001' + 'Content-Type': 'application/json', }) + endpoint = 'http://no-resolved-host:8001' test_client = Client('1', endpoint=endpoint, token='1', timeout=10) result = test_client.environments.list() @@ -54,8 +53,8 @@ class UnitTestsForClassesAndFunctions(unittest.TestCase): "http://no-resolved-host:8001/environments", body=body, adding_headers={ - 'Content-Type': 'application/json',}) - endpoint = 'http://no-resolved-host:8001' + 'Content-Type': 'application/json', }) + endpoint = 'http://no-resolved-host:8001' test_client = Client('1', endpoint=endpoint, token='1', timeout=10) result = test_client.environments.list() @@ -65,17 +64,16 @@ class UnitTestsForClassesAndFunctions(unittest.TestCase): @httprettified def test_client_env_create(self): body = ('{"id": "0ce373a477f211e187a55404a662f968",' - '"name": "test",' - '"created": "2010-11-30T03:23:42Z",' - '"updated": "2010-11-30T03:23:44Z",' - '"tenant-id": "0849006f7ce94961b3aab4e46d6f229a"}' - ) + '"name": "test",' + '"created": "2010-11-30T03:23:42Z",' + '"updated": "2010-11-30T03:23:44Z",' + '"tenant-id": "0849006f7ce94961b3aab4e46d6f229a"}') HTTPretty.register_uri(HTTPretty.POST, "http://no-resolved-host:8001/environments", body=body, adding_headers={ - 'Content-Type': 'application/json',}) - endpoint = 'http://no-resolved-host:8001' + 'Content-Type': 'application/json', }) + endpoint = 'http://no-resolved-host:8001' test_client = Client('1', endpoint=endpoint, token='1', timeout=10) result = test_client.environments.create('test') @@ -98,8 +96,8 @@ class UnitTestsForClassesAndFunctions(unittest.TestCase): HTTPretty.register_uri(HTTPretty.GET, url, body=body, adding_headers={ - 'Content-Type': 'application/json',}) - endpoint = 'http://no-resolved-host:8001' + 'Content-Type': 'application/json', }) + endpoint = 'http://no-resolved-host:8001' test_client = Client('1', endpoint=endpoint, token='1', timeout=10) result = test_client.activeDirectories.list('1', 'test') @@ -122,8 +120,8 @@ class UnitTestsForClassesAndFunctions(unittest.TestCase): HTTPretty.register_uri(HTTPretty.POST, url, body=body, adding_headers={ - 'Content-Type': 'application/json',}) - endpoint = 'http://no-resolved-host:8001' + 'Content-Type': 'application/json', }) + endpoint = 'http://no-resolved-host:8001' test_client = Client('1', endpoint=endpoint, token='1', timeout=10) result = test_client.activeDirectories.create('1', 'test', 'ad1') @@ -131,14 +129,14 @@ class UnitTestsForClassesAndFunctions(unittest.TestCase): @httprettified def test_client_ad_list_without_elements(self): - body = ('{"activeDirectories": []}') + body = '{"activeDirectories": []}' url = ("http://no-resolved-host:8001/environments" "/1/activeDirectories") HTTPretty.register_uri(HTTPretty.GET, url, body=body, adding_headers={ - 'Content-Type': 'application/json',}) - endpoint = 'http://no-resolved-host:8001' + 'Content-Type': 'application/json', }) + endpoint = 'http://no-resolved-host:8001' test_client = Client('1', endpoint=endpoint, token='1', timeout=10) result = test_client.activeDirectories.list('1', 'test') @@ -161,8 +159,8 @@ class UnitTestsForClassesAndFunctions(unittest.TestCase): HTTPretty.register_uri(HTTPretty.GET, url, body=body, adding_headers={ - 'Content-Type': 'application/json',}) - endpoint = 'http://no-resolved-host:8001' + 'Content-Type': 'application/json', }) + endpoint = 'http://no-resolved-host:8001' test_client = Client('1', endpoint=endpoint, token='1', timeout=10) result = test_client.webServers.list('1', 'test') @@ -185,8 +183,8 @@ class UnitTestsForClassesAndFunctions(unittest.TestCase): HTTPretty.register_uri(HTTPretty.POST, url, body=body, adding_headers={ - 'Content-Type': 'application/json',}) - endpoint = 'http://no-resolved-host:8001' + 'Content-Type': 'application/json', }) + endpoint = 'http://no-resolved-host:8001' test_client = Client('1', endpoint=endpoint, token='1', timeout=10) result = test_client.webServers.create('1', 'test', 'iis12') @@ -194,14 +192,14 @@ class UnitTestsForClassesAndFunctions(unittest.TestCase): @httprettified def test_client_iis_list_without_elements(self): - body = ('{"webServers": []}') + body = '{"webServers": []}' url = ("http://no-resolved-host:8001/environments" "/1/webServers") HTTPretty.register_uri(HTTPretty.GET, url, body=body, adding_headers={ - 'Content-Type': 'application/json',}) - endpoint = 'http://no-resolved-host:8001' + 'Content-Type': 'application/json', }) + endpoint = 'http://no-resolved-host:8001' test_client = Client('1', endpoint=endpoint, token='1', timeout=10) result = test_client.webServers.list('1', 'test') diff --git a/tests/muranoclient/test_methods.py b/tests/muranoclient/test_methods.py index 5083ce63..334c99a1 100644 --- a/tests/muranoclient/test_methods.py +++ b/tests/muranoclient/test_methods.py @@ -21,15 +21,16 @@ import muranoclient.v1.environments as environments import muranoclient.v1.services as services import muranoclient.v1.sessions as sessions + def my_mock(*a, **b): return [a, b] + LOG = logging.getLogger('Unit tests') api = MagicMock(json_request=my_mock) class UnitTestsForClassesAndFunctions(unittest.TestCase): - def test_create_client_instance(self): endpoint = 'http://no-resolved-host:8001' @@ -117,7 +118,7 @@ class UnitTestsForClassesAndFunctions(unittest.TestCase): result = manager.get('test') ## WTF? assert result.manager is not None - + def test_env(self): environment = environments.Environment(api, api) assert environment.data() is not None @@ -230,7 +231,7 @@ class UnitTestsForClassesAndFunctions(unittest.TestCase): except TypeError: pass assert result == 'Exception' - + def test_iis_manager_list_with_one_parameter(self): manager = services.WebServerManager(api) result = manager.list('datacenter1') @@ -344,11 +345,11 @@ class UnitTestsForClassesAndFunctions(unittest.TestCase): def test_service_ad(self): service_ad = services.ActiveDirectory(api, api) assert service_ad.data() is not None - + def test_service_iis(self): service_iis = services.ActiveDirectory(api, api) assert service_iis.data() is not None - + def test_session_manager_list(self): manager = sessions.SessionManager(api) result = manager.list('datacenter1') @@ -396,13 +397,13 @@ class UnitTestsForClassesAndFunctions(unittest.TestCase): except TypeError: pass assert result == 'Exception' - + def test_session_manager_get(self): manager = sessions.SessionManager(api) result = manager.get('datacenter1', 'session1') # WTF? assert result.manager is not None - + def test_session_manager_configure(self): manager = sessions.SessionManager(api) result = manager.configure('datacenter1') diff --git a/tox.ini b/tox.ini index 7d3cde38..9e6ecbbf 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,pep8 +envlist = py27,pep8,pep8,pyflakes [testenv] setenv = VIRTUAL_ENV={envdir} @@ -44,3 +44,15 @@ commands = nosetests --cover-erase --cover-package=muranoclient --with-xcoverage deps = file://{toxinidir}/.cache.bundle setenv = NOSE_WITH_XUNIT=1 commands = {posargs} + +[testenv:pyflakes] +deps = flake8 +commands = flake8 + +[flake8] +# H301 one import per line +# H302 import only modules +ignore = H301,H302,F401 +show-source = true +builtins = _ +exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,tools