From 80c44388b15d9bc61c309d274f386d980da99add Mon Sep 17 00:00:00 2001 From: Radoslav Gerganov Date: Wed, 22 Feb 2017 10:18:26 -0500 Subject: [PATCH] Fix the gate jobs Enable unit tests and fix gate jobs. Change-Id: Ie9c4b2357820b0180cabcbc9de196d09f7e0b6a8 --- .testr.conf | 4 ++++ test-requirements.txt | 4 +++- tox.ini | 2 +- vspc/tests/__init__.py | 0 vspc/tests/test_server.py | 29 +++++++++++++++++++++++++++++ 5 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 .testr.conf create mode 100644 vspc/tests/__init__.py create mode 100644 vspc/tests/test_server.py diff --git a/.testr.conf b/.testr.conf new file mode 100644 index 0000000..b99ef0a --- /dev/null +++ b/.testr.conf @@ -0,0 +1,4 @@ +[DEFAULT] +test_command=python -m subunit.run discover -t ./ ./vspc/tests $LISTOPT $IDOPTION +test_id_option=--load-list $IDFILE +test_list_option=--list diff --git a/test-requirements.txt b/test-requirements.txt index c59a0e9..997a708 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,2 +1,4 @@ flake8 - +testrepository +testtools +mock diff --git a/tox.ini b/tox.ini index c1c17b8..a8a534a 100644 --- a/tox.ini +++ b/tox.ini @@ -5,7 +5,7 @@ skipsdist = True [testenv] deps = -rrequirements.txt -rtest-requirements.txt -#commands = python setup.py testr --slowest --testr-args='{posargs}' +commands = python setup.py testr --slowest --testr-args='{posargs}' [testenv:pep8] basepython = /usr/bin/python3 diff --git a/vspc/tests/__init__.py b/vspc/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/vspc/tests/test_server.py b/vspc/tests/test_server.py new file mode 100644 index 0000000..3220d89 --- /dev/null +++ b/vspc/tests/test_server.py @@ -0,0 +1,29 @@ +# Copyright (c) 2017 VMware Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# 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. +import mock +import testtools + +from vspc import server + + +class VspcServerTest(testtools.TestCase): + + def test_handle_vm_vc_uuid(self): + mock_socket = mock.Mock() + srv = server.VspcServer() + data = b'11 22 33 44 55' + srv.handle_vm_vc_uuid(mock_socket, data) + actual_uuid = srv.sock_to_uuid[mock_socket] + self.assertEqual('1122334455', actual_uuid)