Add basic tests for Kuryr

This patch adds unit tests for Kuryr and examine if it satisfies
libnetwork's remote driver specifications.

Change-Id: Ic8ab9944a5ed884db518c840b75917261583e53e
Signed-off-by: Taku Fukushima <f.tac.mac@gmail.com>
This commit is contained in:
Taku Fukushima 2015-07-22 17:12:41 +09:00
parent 3de2404d92
commit 8c73ab3079
4 changed files with 43 additions and 16 deletions

View File

@ -1,8 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2010-2011 OpenStack Foundation
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
#
# 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
@ -17,7 +12,13 @@
from oslotest import base
from kuryr import app
class TestCase(base.BaseTestCase):
"""Test case base class for all unit tests."""
def setUp(self):
super(TestCase, self).setUp()
app.config['TESTING'] = True
self.app = app.test_client()

View File

@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
# 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
@ -12,17 +10,42 @@
# License for the specific language governing permissions and limitations
# under the License.
"""
test_kuryr
----------------------------------
Tests for `kuryr` module.
"""
from ddt import ddt, data, unpack
from oslo_serialization import jsonutils
from kuryr.constants import SCHEMA
from kuryr.tests import base
@ddt
class TestKuryr(base.TestCase):
"""Basic unitests for libnetwork remote driver URI endpoints.
def test_something(self):
pass
This test class covers the following HTTP methods and URIs as described in
the remote driver specification as below:
https://github.com/docker/libnetwork/blob/3c8e06bc0580a2a1b2440fe0792fbfcd43a9feca/docs/remote.md # noqa
- POST /Plugin.Activate
- POST /NetworkDriver.CreateNetwork
- POST /NetworkDriver.DeleteNetwork
- POST /NetworkDriver.CreateEndpoint
- POST /NetworkDriver.EndpointOperInfo
- POST /NetworkDriver.DeleteEndpoint
- POST /NetworkDriver.Join
- POST /NetworkDriver.Leave
"""
@data(('/Plugin.Activate', SCHEMA['PLUGIN_ACTIVATE']),
('/NetworkDriver.CreateNetwork', SCHEMA['SUCCESS']),
('/NetworkDriver.DeleteNetwork', SCHEMA['SUCCESS']),
('/NetworkDriver.CreateEndpoint', SCHEMA['CREATE_ENDPOINT']),
('/NetworkDriver.EndpointOperInfo', SCHEMA['ENDPOINT_OPER_INFO']),
('/NetworkDriver.DeleteEndpoint', SCHEMA['SUCCESS']),
('/NetworkDriver.Join', SCHEMA['JOIN']),
('/NetworkDriver.Leave', SCHEMA['SUCCESS']))
@unpack
def test_remote_driver_endpoint(self, endpoint, expected):
response = self.app.post(endpoint)
decoded_json = jsonutils.loads(response.data)
self.assertEqual(expected, decoded_json)

View File

@ -5,3 +5,5 @@
pbr<2.0,>=1.3
Babel>=1.3
Flask>=0.10,<1.0
oslo.serialization>=1.4.0 # Apache-2.0

View File

@ -7,6 +7,7 @@ hacking<0.11,>=0.10.0
coverage>=3.6
discover
ddt>=0.7.0
python-subunit>=0.0.18
sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2
oslosphinx>=2.5.0 # Apache-2.0