| 1 |
# Copyright (c) 2013 Red Hat, Inc. |
| 2 |
# |
| 3 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
# you may not use this file except in compliance with the License. |
| 5 |
# You may obtain a copy of the License at |
| 6 |
# |
| 7 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
# |
| 9 |
# Unless required by applicable law or agreed to in writing, software |
| 10 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| 12 |
# implied. |
| 13 |
# See the License for the specific language governing permissions and |
| 14 |
# limitations under the License. |
| 15 |
|
| 16 |
from zaqarclient import errors |
| 17 |
from zaqarclient.tests import base |
| 18 |
from zaqarclient.tests.transport import api as tapi |
| 19 |
|
| 20 |
|
| 21 |
class TestApi(base.TestBase): |
| 22 |
|
| 23 |
def setUp(self): |
| 24 |
super().setUp() |
| 25 |
self.api = tapi.FakeApi() |
| 26 |
|
| 27 |
def test_valid_params(self): |
| 28 |
self.assertTrue(self.api.validate('test_operation', |
| 29 |
{'name': 'Sauron'})) |
| 30 |
|
| 31 |
def test_invalid_params(self): |
| 32 |
self.assertFalse(self.api.validate('test_operation', |
| 33 |
{'name': 'Sauron', |
| 34 |
'lastname': 'From Mordor'})) |
| 35 |
|
| 36 |
def test_missing_params(self): |
| 37 |
self.assertFalse(self.api.validate('test_operation', {})) |
| 38 |
|
| 39 |
def test_invalid_operation(self): |
| 40 |
self.assertRaises(errors.InvalidOperation, self.api.validate, |
| 41 |
'super_secret_op', {}) |