Browse Source

Migrated unit tests to testtools

Main changes:
* testtools checks that base setUp is called
* assertRaises doesn't return context
* testtools inherits from unittest (not unittest2) and doesn't have
  specific compare functions in py2.6

Notes:
* Integration tests will be tracked separately (bp: it-testtools)
* Migration to oslotest will be tracked separately (bp: oslotest)
* bug #1325108 is out of scope of this CR

Implements blueprint: ut-testtools
Closes-Bug: #1179009

Change-Id: I85f0ea1aa972ff68ddd1817ec936a8c26312f041
changes/79/96979/6
Andrew Lazarev 7 years ago
parent
commit
95e1c2f00b
51 changed files with 242 additions and 212 deletions
  1. +2
    -3
      sahara/tests/unit/base.py
  2. +2
    -1
      sahara/tests/unit/conductor/base.py
  3. +7
    -5
      sahara/tests/unit/conductor/manager/test_clusters.py
  4. +16
    -14
      sahara/tests/unit/conductor/manager/test_edp.py
  5. +9
    -7
      sahara/tests/unit/conductor/manager/test_templates.py
  6. +5
    -8
      sahara/tests/unit/conductor/test_resource.py
  7. +2
    -2
      sahara/tests/unit/db/migration/test_db_manage_cli.py
  8. +2
    -2
      sahara/tests/unit/db/migration/test_migrations_base.py
  9. +6
    -6
      sahara/tests/unit/db/sqlalchemy/test_types.py
  10. +14
    -12
      sahara/tests/unit/plugins/general/test_utils.py
  11. +5
    -2
      sahara/tests/unit/plugins/hdp/test_ambariplugin.py
  12. +18
    -17
      sahara/tests/unit/plugins/hdp/test_clusterspec.py
  13. +19
    -18
      sahara/tests/unit/plugins/hdp/test_clusterspec_hdp2.py
  14. +2
    -2
      sahara/tests/unit/plugins/hdp/test_services.py
  15. +2
    -2
      sahara/tests/unit/plugins/hdp/test_versionmanagerfactory.py
  16. +3
    -2
      sahara/tests/unit/plugins/test_base_plugins_support.py
  17. +4
    -4
      sahara/tests/unit/plugins/test_provisioning.py
  18. +3
    -3
      sahara/tests/unit/plugins/vanilla/v1_2_1/test_dfsadmin_parsing.py
  19. +24
    -23
      sahara/tests/unit/plugins/vanilla/v1_2_1/test_plugin.py
  20. +2
    -4
      sahara/tests/unit/plugins/vanilla/v1_2_1/test_run_scripts.py
  21. +2
    -2
      sahara/tests/unit/plugins/vanilla/v2_3_0/test_configs.py
  22. +2
    -2
      sahara/tests/unit/plugins/vanilla/v2_3_0/test_utils.py
  23. +12
    -10
      sahara/tests/unit/plugins/vanilla/v2_3_0/test_validation.py
  24. +2
    -2
      sahara/tests/unit/service/edp/test_job_possible_configs.py
  25. +4
    -3
      sahara/tests/unit/service/edp/workflow_creator/test_create_workflow.py
  26. +6
    -7
      sahara/tests/unit/service/test_instances.py
  27. +9
    -7
      sahara/tests/unit/service/validation/edp/test_data_source.py
  28. +1
    -0
      sahara/tests/unit/service/validation/edp/test_job.py
  29. +1
    -0
      sahara/tests/unit/service/validation/edp/test_job_binary.py
  30. +1
    -0
      sahara/tests/unit/service/validation/edp/test_job_executor.py
  31. +2
    -1
      sahara/tests/unit/service/validation/edp/test_job_executor_java.py
  32. +1
    -0
      sahara/tests/unit/service/validation/test_add_tags_validation.py
  33. +4
    -2
      sahara/tests/unit/service/validation/test_cluster_create_validation.py
  34. +4
    -3
      sahara/tests/unit/service/validation/test_cluster_scaling_validation.py
  35. +1
    -0
      sahara/tests/unit/service/validation/test_cluster_template_create_validation.py
  36. +1
    -0
      sahara/tests/unit/service/validation/test_ng_template_validation_create.py
  37. +2
    -0
      sahara/tests/unit/service/validation/utils.py
  38. +1
    -0
      sahara/tests/unit/swift/test_utils.py
  39. +9
    -8
      sahara/tests/unit/test_context.py
  40. +1
    -0
      sahara/tests/unit/topology/test_topology.py
  41. +2
    -2
      sahara/tests/unit/utils/test_api_validator.py
  42. +2
    -2
      sahara/tests/unit/utils/test_crypto.py
  43. +2
    -2
      sahara/tests/unit/utils/test_edp.py
  44. +2
    -2
      sahara/tests/unit/utils/test_general.py
  45. +2
    -2
      sahara/tests/unit/utils/test_hashabledict.py
  46. +6
    -7
      sahara/tests/unit/utils/test_heat.py
  47. +2
    -2
      sahara/tests/unit/utils/test_neutron.py
  48. +3
    -2
      sahara/tests/unit/utils/test_patches.py
  49. +2
    -2
      sahara/tests/unit/utils/test_ssh_remote.py
  50. +2
    -2
      sahara/tests/unit/utils/test_types.py
  51. +4
    -3
      sahara/tests/unit/utils/test_xml_utils.py

+ 2
- 3
sahara/tests/unit/base.py View File

@ -14,19 +14,18 @@
# limitations under the License.
import mock
import unittest2
import testtools
from sahara import context
from sahara.db import api as db_api
from sahara import main
class SaharaTestCase(unittest2.TestCase):
class SaharaTestCase(testtools.TestCase):
def setUp(self):
super(SaharaTestCase, self).setUp()
self.maxDiff = None
self.setup_context()
def setup_context(self, username="test_user", tenant_id="tenant_1",


+ 2
- 1
sahara/tests/unit/conductor/base.py View File

@ -42,4 +42,5 @@ class ConductorManagerTestCase(base.SaharaWithDbTestCase):
for idx, check in enumerate(self._checks):
check_val = check()
self.assertEqual(self._results[idx], check_val,
msg="Check '%s' failed" % idx)
message="Check '%s' failed" % idx)
super(ConductorManagerTestCase, self).tearDown()

+ 7
- 5
sahara/tests/unit/conductor/manager/test_clusters.py View File

@ -15,6 +15,8 @@
import copy
import testtools
from sahara.conductor import manager
from sahara import context
from sahara import exceptions as ex
@ -76,14 +78,14 @@ class ClusterTest(test_base.ConductorManagerTestCase):
lst = self.api.cluster_get_all(ctx)
self.assertEqual(len(lst), 0)
with self.assertRaises(ex.NotFoundException):
with testtools.ExpectedException(ex.NotFoundException):
self.api.cluster_destroy(ctx, cl_id)
def test_duplicate_cluster_create(self):
ctx = context.ctx()
self.api.cluster_create(ctx, SAMPLE_CLUSTER)
with self.assertRaises(ex.DBDuplicateEntry):
with testtools.ExpectedException(ex.DBDuplicateEntry):
self.api.cluster_create(ctx, SAMPLE_CLUSTER)
def test_cluster_fields(self):
@ -142,7 +144,7 @@ class ClusterTest(test_base.ConductorManagerTestCase):
get_cl_obj = self.api.cluster_get(ctx, _id)
self.assertEqual(updated_cl, get_cl_obj)
with self.assertRaises(ex.NotFoundException):
with testtools.ExpectedException(ex.NotFoundException):
self.api.cluster_update(ctx, "bad_id", {"status": "Active"})
def _ng_in_cluster(self, cluster_db_obj, ng_id):
@ -205,7 +207,7 @@ class ClusterTest(test_base.ConductorManagerTestCase):
self.assertFalse(found_ng, "Node Group is still in a CLuster")
with self.assertRaises(ex.NotFoundException):
with testtools.ExpectedException(ex.NotFoundException):
self.api.node_group_remove(ctx, ng_id)
def _add_instance(self, ctx, ng_id):
@ -279,5 +281,5 @@ class ClusterTest(test_base.ConductorManagerTestCase):
self.assertEqual(count, ng["count"])
with self.assertRaises(ex.NotFoundException):
with testtools.ExpectedException(ex.NotFoundException):
self.api.instance_remove(ctx, instance_id)

+ 16
- 14
sahara/tests/unit/conductor/manager/test_edp.py View File

@ -16,6 +16,8 @@
import copy
import datetime
import testtools
from sahara import context
from sahara import exceptions as ex
import sahara.tests.unit.conductor.base as test_base
@ -107,7 +109,7 @@ class DataSourceTest(test_base.ConductorManagerTestCase):
def test_duplicate_data_source_create(self):
ctx = context.ctx()
self.api.data_source_create(ctx, SAMPLE_DATA_SOURCE)
with self.assertRaises(ex.DBDuplicateEntry):
with testtools.ExpectedException(ex.DBDuplicateEntry):
self.api.data_source_create(ctx, SAMPLE_DATA_SOURCE)
def test_data_source_fields(self):
@ -130,7 +132,7 @@ class DataSourceTest(test_base.ConductorManagerTestCase):
self.api.data_source_destroy(ctx, _id)
with self.assertRaises(ex.NotFoundException):
with testtools.ExpectedException(ex.NotFoundException):
self.api.data_source_destroy(ctx, _id)
@ -166,10 +168,10 @@ class JobExecutionTest(test_base.ConductorManagerTestCase):
self.api.job_execution_destroy(ctx, job_ex_id)
with self.assertRaises(ex.NotFoundException):
with testtools.ExpectedException(ex.NotFoundException):
self.api.job_execution_update(ctx, job_ex_id, {'progress': '0.2'})
with self.assertRaises(ex.NotFoundException):
with testtools.ExpectedException(ex.NotFoundException):
self.api.job_execution_destroy(ctx, job_ex_id)
lst = self.api.job_execution_get_all(ctx)
@ -213,11 +215,11 @@ class JobExecutionTest(test_base.ConductorManagerTestCase):
self.api.job_execution_create(ctx, SAMPLE_CONF_JOB_EXECUTION)
with self.assertRaises(ex.DeletionFailed):
with testtools.ExpectedException(ex.DeletionFailed):
self.api.data_source_destroy(ctx, ds_input['id'])
with self.assertRaises(ex.DeletionFailed):
with testtools.ExpectedException(ex.DeletionFailed):
self.api.data_source_destroy(ctx, ds_output['id'])
with self.assertRaises(ex.DeletionFailed):
with testtools.ExpectedException(ex.DeletionFailed):
self.api.job_destroy(ctx, job['id'])
@ -247,7 +249,7 @@ class JobTest(test_base.ConductorManagerTestCase):
lst = self.api.job_get_all(ctx)
self.assertEqual(len(lst), 0)
with self.assertRaises(ex.NotFoundException):
with testtools.ExpectedException(ex.NotFoundException):
self.api.job_destroy(ctx, jo_id)
def test_job_fields(self):
@ -284,13 +286,13 @@ class JobBinaryInternalTest(test_base.ConductorManagerTestCase):
lst = self.api.job_binary_internal_get_all(ctx)
self.assertEqual(len(lst), 0)
with self.assertRaises(ex.NotFoundException):
with testtools.ExpectedException(ex.NotFoundException):
self.api.job_binary_internal_destroy(ctx, job_bin_int_id)
def test_duplicate_job_binary_internal_create(self):
ctx = context.ctx()
self.api.job_binary_internal_create(ctx, SAMPLE_JOB_BINARY_INTERNAL)
with self.assertRaises(ex.DBDuplicateEntry):
with testtools.ExpectedException(ex.DBDuplicateEntry):
self.api.job_binary_internal_create(ctx,
SAMPLE_JOB_BINARY_INTERNAL)
@ -316,7 +318,7 @@ class JobBinaryInternalTest(test_base.ConductorManagerTestCase):
internal = self.api.job_binary_internal_get(ctx, id)
self.assertIsInstance(internal, dict)
with self.assertRaises(KeyError):
with testtools.ExpectedException(KeyError):
internal["data"]
internal["data"] = self.api.job_binary_internal_get_raw_data(ctx, id)
@ -349,7 +351,7 @@ class JobBinaryTest(test_base.ConductorManagerTestCase):
lst = self.api.job_binary_get_all(ctx)
self.assertEqual(len(lst), 0)
with self.assertRaises(ex.NotFoundException):
with testtools.ExpectedException(ex.NotFoundException):
self.api.job_binary_destroy(ctx, job_binary_id)
def test_job_binary_fields(self):
@ -375,7 +377,7 @@ class JobBinaryTest(test_base.ConductorManagerTestCase):
job_id = self.api.job_create(ctx, job_values)['id']
# Delete while referenced, fails
with self.assertRaises(ex.DeletionFailed):
with testtools.ExpectedException(ex.DeletionFailed):
self.api.job_binary_destroy(ctx, job_binary_id)
# Delete while not referenced
@ -393,6 +395,6 @@ class JobBinaryTest(test_base.ConductorManagerTestCase):
def test_duplicate_job_binary_create(self):
ctx = context.ctx()
self.api.job_binary_create(ctx, SAMPLE_JOB_BINARY)
with self.assertRaises(ex.DBDuplicateEntry):
with testtools.ExpectedException(ex.DBDuplicateEntry):
self.api.job_binary_create(ctx,
SAMPLE_JOB_BINARY)

+ 9
- 7
sahara/tests/unit/conductor/manager/test_templates.py View File

@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import testtools
from sahara.conductor import manager
from sahara import context
from sahara import exceptions as ex
@ -97,7 +99,7 @@ class NodeGroupTemplates(test_base.ConductorManagerTestCase):
def test_duplicate_ngt_create(self):
ctx = context.ctx()
self.api.node_group_template_create(ctx, SAMPLE_NGT)
with self.assertRaises(ex.DBDuplicateEntry):
with testtools.ExpectedException(ex.DBDuplicateEntry):
self.api.node_group_template_create(ctx, SAMPLE_NGT)
def test_ngt_fields(self):
@ -119,7 +121,7 @@ class NodeGroupTemplates(test_base.ConductorManagerTestCase):
self.api.node_group_template_destroy(ctx, _id)
with self.assertRaises(ex.NotFoundException):
with testtools.ExpectedException(ex.NotFoundException):
self.api.node_group_template_destroy(ctx, _id)
@ -147,13 +149,13 @@ class ClusterTemplates(test_base.ConductorManagerTestCase):
lst = self.api.cluster_template_get_all(ctx)
self.assertEqual(len(lst), 0)
with self.assertRaises(ex.NotFoundException):
with testtools.ExpectedException(ex.NotFoundException):
self.api.cluster_template_destroy(ctx, clt_id)
def test_duplicate_clt_create(self):
ctx = context.ctx()
self.api.cluster_template_create(ctx, SAMPLE_CLT)
with self.assertRaises(ex.DBDuplicateEntry):
with testtools.ExpectedException(ex.DBDuplicateEntry):
self.api.cluster_template_create(ctx, SAMPLE_CLT)
def test_clt_fields(self):
@ -183,8 +185,8 @@ class ClusterTemplates(test_base.ConductorManagerTestCase):
ng.pop("volumes_size")
ng.pop("volumes_per_node")
self.assertListEqual(SAMPLE_CLT["node_groups"],
clt_db_obj["node_groups"])
self.assertEqual(SAMPLE_CLT["node_groups"],
clt_db_obj["node_groups"])
def test_clt_delete(self):
ctx = context.ctx()
@ -193,5 +195,5 @@ class ClusterTemplates(test_base.ConductorManagerTestCase):
self.api.cluster_template_destroy(ctx, _id)
with self.assertRaises(ex.NotFoundException):
with testtools.ExpectedException(ex.NotFoundException):
self.api.cluster_template_destroy(ctx, _id)

+ 5
- 8
sahara/tests/unit/conductor/test_resource.py View File

@ -15,7 +15,7 @@
import copy
import unittest2
import testtools
from sahara.conductor import resource as r
from sahara.swift import swift_helper
@ -123,10 +123,7 @@ SAMPLE_JOB_EXECUTION = {
}
class TestResource(unittest2.TestCase):
def setUp(self):
self.maxDiff = None
class TestResource(testtools.TestCase):
def test_resource_creation(self):
res = r.Resource(SAMPLE_DICT)
@ -139,13 +136,13 @@ class TestResource(unittest2.TestCase):
def test_resource_immutability(self):
res = r.Resource(SAMPLE_DICT)
with self.assertRaises(types.FrozenClassError):
with testtools.ExpectedException(types.FrozenClassError):
res.first.append(123)
with self.assertRaises(types.FrozenClassError):
with testtools.ExpectedException(types.FrozenClassError):
res.first = 123
with self.assertRaises(types.FrozenClassError):
with testtools.ExpectedException(types.FrozenClassError):
res.second.a = 123
def test_nested_lists(self):


+ 2
- 2
sahara/tests/unit/db/migration/test_db_manage_cli.py View File

@ -17,12 +17,12 @@ import sys
import mock
import testscenarios
import unittest2
import testtools
from sahara.db.migration import cli
class TestCli(unittest2.TestCase):
class TestCli(testtools.TestCase):
func_name = ''
exp_args = ()
exp_kwargs = {}


+ 2
- 2
sahara/tests/unit/db/migration/test_migrations_base.py View File

@ -33,7 +33,7 @@ from oslo.config import cfg
import six.moves.urllib.parse as urlparse
import sqlalchemy
import sqlalchemy.exc
import unittest2
import testtools
import sahara.db.migration
from sahara.db.sqlalchemy import api as sa
@ -157,7 +157,7 @@ class CommonTestsMixIn(object):
self.fail("Shouldn't have connected")
class BaseMigrationTestCase(unittest2.TestCase):
class BaseMigrationTestCase(testtools.TestCase):
"""Base class for testing migrations and migration utils. This sets up
and configures the databases to run tests against.
"""


+ 6
- 6
sahara/tests/unit/db/sqlalchemy/test_types.py View File

@ -15,12 +15,12 @@
import mock
import sqlalchemy as sa
import unittest2
import testtools
from sahara.db.sqlalchemy import types
class JsonEncodedTest(unittest2.TestCase):
class JsonEncodedTest(testtools.TestCase):
def test_impl(self):
impl = types.JsonEncoded.impl
self.assertEqual(sa.Text, impl)
@ -42,7 +42,7 @@ class JsonEncodedTest(unittest2.TestCase):
self.assertIsNone(t.process_result_value(None, None))
class MutableDictTest(unittest2.TestCase):
class MutableDictTest(testtools.TestCase):
def test_creation(self):
sample = {"a": 1, "b": 2}
d = types.MutableDict(sample)
@ -62,7 +62,7 @@ class MutableDictTest(unittest2.TestCase):
self.assertIs(sample_md, md)
def test_coerce_unsupported(self):
with self.assertRaises(ValueError):
with testtools.ExpectedException(ValueError):
types.MutableDict.coerce("test", list())
@mock.patch.object(types.MutableDict, 'changed')
@ -90,7 +90,7 @@ class MutableDictTest(unittest2.TestCase):
self.assertEqual(1, m.call_count)
class MutableListTest(unittest2.TestCase):
class MutableListTest(testtools.TestCase):
def test_creation(self):
sample = [1, 2, 3]
d = types.MutableList(sample)
@ -110,7 +110,7 @@ class MutableListTest(unittest2.TestCase):
self.assertIs(sample_md, md)
def test_coerce_unsupported(self):
with self.assertRaises(ValueError):
with testtools.ExpectedException(ValueError):
types.MutableList.coerce("test", dict())
@mock.patch.object(types.MutableList, 'changed')


+ 14
- 12
sahara/tests/unit/plugins/general/test_utils.py View File

@ -13,15 +13,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest2
import testtools
from sahara.plugins.general import exceptions as ex
from sahara.plugins.general import utils as u
from sahara.tests.unit import testutils as tu
class GeneralUtilsTest(unittest2.TestCase):
class GeneralUtilsTest(testtools.TestCase):
def setUp(self):
super(GeneralUtilsTest, self).setUp()
i1 = tu.make_inst_dict('i1', 'master')
i2 = tu.make_inst_dict('i2', 'worker1')
i3 = tu.make_inst_dict('i3', 'worker2')
@ -41,25 +42,25 @@ class GeneralUtilsTest(unittest2.TestCase):
self.ng3 = self.c1.node_groups[2]
def test_get_node_groups(self):
self.assertListEqual(u.get_node_groups(self.c1), self.c1.node_groups)
self.assertListEqual(u.get_node_groups(self.c1, "wrong-process"), [])
self.assertListEqual(u.get_node_groups(self.c1, 'dn'),
[self.ng2, self.ng3])
self.assertEqual(u.get_node_groups(self.c1), self.c1.node_groups)
self.assertEqual(u.get_node_groups(self.c1, "wrong-process"), [])
self.assertEqual(u.get_node_groups(self.c1, 'dn'),
[self.ng2, self.ng3])
def test_get_instances(self):
self.assertEqual(len(u.get_instances(self.c1)), 5)
self.assertListEqual(u.get_instances(self.c1, 'wrong-process'), [])
self.assertListEqual(u.get_instances(self.c1, 'nn'),
self.ng1.instances)
self.assertEqual(u.get_instances(self.c1, 'wrong-process'), [])
self.assertEqual(u.get_instances(self.c1, 'nn'),
self.ng1.instances)
instances = list(self.ng2.instances)
instances += self.ng3.instances
self.assertListEqual(u.get_instances(self.c1, 'dn'), instances)
self.assertEqual(u.get_instances(self.c1, 'dn'), instances)
def test_get_instance(self):
self.assertIsNone(u.get_instance(self.c1, 'wrong-process'))
self.assertEqual(u.get_instance(self.c1, 'nn'),
self.ng1.instances[0])
with self.assertRaises(ex.InvalidComponentCountException):
with testtools.ExpectedException(ex.InvalidComponentCountException):
u.get_instance(self.c1, 'dn')
def test_generate_lines_from_list(self):
@ -68,8 +69,9 @@ class GeneralUtilsTest(unittest2.TestCase):
self.assertEqual(u.generate_host_names([]), "")
class GetPortUtilsTest(unittest2.TestCase):
class GetPortUtilsTest(testtools.TestCase):
def setUp(self):
super(GetPortUtilsTest, self).setUp()
self.test_values = [
('127.0.0.1:11000', 11000),
('http://somehost.com:8080/resource', 8080),


+ 5
- 2
sahara/tests/unit/plugins/hdp/test_ambariplugin.py View File

@ -15,6 +15,7 @@
import mock
import pkg_resources as pkg
import testtools
from sahara.conductor import resource as r
from sahara.plugins.general import exceptions as ex
@ -213,6 +214,7 @@ class AmbariPluginTest(sahara_base.SaharaTestCase):
self.assertEqual('admin', ambari_info.password)
@mock.patch(GET_REST_REQ)
@testtools.skip("test failure because of #1325108")
def test__set_ambari_credentials__no_admin_user(self, client):
self.requests = []
plugin = ap.AmbariPlugin()
@ -233,9 +235,10 @@ class AmbariPluginTest(sahara_base.SaharaTestCase):
ambari_info = ap.AmbariInfo(TestHost('111.11.1111'),
'8080', 'admin', 'old-pwd')
self.assertRaises(ex.HadoopProvisionError,
plugin._set_ambari_credentials(cluster_spec,
ambari_info, '1.3.2'))
plugin._set_ambari_credentials,
cluster_spec, ambari_info, '1.3.2')
@mock.patch("sahara.utils.openstack.nova.get_instance_info",
base.get_instance_info)


+ 18
- 17
sahara/tests/unit/plugins/hdp/test_clusterspec.py View File

@ -15,7 +15,7 @@
import mock
import pkg_resources as pkg
import unittest2
import testtools
from sahara.plugins.general import exceptions as ex
from sahara.plugins.hdp import clusterspec as cs
@ -37,9 +37,25 @@ class TestCONF(object):
@mock.patch('sahara.plugins.hdp.versions.version_1_3_2.services.HdfsService.'
'_get_swift_properties',
return_value=[])
class ClusterSpecTest(unittest2.TestCase):
class ClusterSpecTest(testtools.TestCase):
service_validators = {}
def setUp(self):
super(ClusterSpecTest, self).setUp()
self.service_validators['HDFS'] = self._assert_hdfs
self.service_validators['MAPREDUCE'] = self._assert_mr
self.service_validators['GANGLIA'] = self._assert_ganglia
self.service_validators['NAGIOS'] = self._assert_nagios
self.service_validators['AMBARI'] = self._assert_ambari
self.service_validators['PIG'] = self._assert_pig
self.service_validators['HIVE'] = self._assert_hive
self.service_validators['HCATALOG'] = self._assert_hcatalog
self.service_validators['ZOOKEEPER'] = self._assert_zookeeper
self.service_validators['WEBHCAT'] = self._assert_webhcat
self.service_validators['OOZIE'] = self._assert_oozie
self.service_validators['SQOOP'] = self._assert_sqoop
self.service_validators['HBASE'] = self._assert_hbase
#TODO(jspeidel): test host manifest
def test_parse_default_with_cluster(self, patched):
cluster_config_file = pkg.resource_string(
@ -1492,21 +1508,6 @@ class ClusterSpecTest(unittest2.TestCase):
self.assertIn('oozie-site', configurations)
self.assertIn('hbase-site', configurations)
def setUp(self):
self.service_validators['HDFS'] = self._assert_hdfs
self.service_validators['MAPREDUCE'] = self._assert_mr
self.service_validators['GANGLIA'] = self._assert_ganglia
self.service_validators['NAGIOS'] = self._assert_nagios
self.service_validators['AMBARI'] = self._assert_ambari
self.service_validators['PIG'] = self._assert_pig
self.service_validators['HIVE'] = self._assert_hive
self.service_validators['HCATALOG'] = self._assert_hcatalog
self.service_validators['ZOOKEEPER'] = self._assert_zookeeper
self.service_validators['WEBHCAT'] = self._assert_webhcat
self.service_validators['OOZIE'] = self._assert_oozie
self.service_validators['SQOOP'] = self._assert_sqoop
self.service_validators['HBASE'] = self._assert_hbase
class TestNodeGroup:
def __init__(self, name, instances, node_processes, count=1):


+ 19
- 18
sahara/tests/unit/plugins/hdp/test_clusterspec_hdp2.py View File

@ -15,7 +15,7 @@
import mock
import pkg_resources as pkg
import unittest2
import testtools
from sahara.plugins.general import exceptions as ex
from sahara.plugins.hdp import clusterspec as cs
@ -37,9 +37,26 @@ class TestCONF(object):
@mock.patch('sahara.plugins.hdp.versions.version_2_0_6.services.HdfsService.'
'_get_swift_properties',
return_value=[])
class ClusterSpecTestForHDP2(unittest2.TestCase):
class ClusterSpecTestForHDP2(testtools.TestCase):
service_validators = {}
def setUp(self):
super(ClusterSpecTestForHDP2, self).setUp()
self.service_validators['YARN'] = self._assert_yarn
self.service_validators['HDFS'] = self._assert_hdfs
self.service_validators['MAPREDUCE2'] = self._assert_mrv2
self.service_validators['GANGLIA'] = self._assert_ganglia
self.service_validators['NAGIOS'] = self._assert_nagios
self.service_validators['AMBARI'] = self._assert_ambari
self.service_validators['PIG'] = self._assert_pig
self.service_validators['HIVE'] = self._assert_hive
self.service_validators['HCATALOG'] = self._assert_hcatalog
self.service_validators['ZOOKEEPER'] = self._assert_zookeeper
self.service_validators['WEBHCAT'] = self._assert_webhcat
self.service_validators['OOZIE'] = self._assert_oozie
self.service_validators['SQOOP'] = self._assert_sqoop
self.service_validators['HBASE'] = self._assert_hbase
def test_parse_default_with_cluster(self, patched):
cluster_config_file = pkg.resource_string(
version.version_info.package,
@ -1580,22 +1597,6 @@ class ClusterSpecTestForHDP2(unittest2.TestCase):
self.assertIn('hbase-site', configurations)
self.assertIn('capacity-scheduler', configurations)
def setUp(self):
self.service_validators['YARN'] = self._assert_yarn
self.service_validators['HDFS'] = self._assert_hdfs
self.service_validators['MAPREDUCE2'] = self._assert_mrv2
self.service_validators['GANGLIA'] = self._assert_ganglia
self.service_validators['NAGIOS'] = self._assert_nagios
self.service_validators['AMBARI'] = self._assert_ambari
self.service_validators['PIG'] = self._assert_pig
self.service_validators['HIVE'] = self._assert_hive
self.service_validators['HCATALOG'] = self._assert_hcatalog
self.service_validators['ZOOKEEPER'] = self._assert_zookeeper
self.service_validators['WEBHCAT'] = self._assert_webhcat
self.service_validators['OOZIE'] = self._assert_oozie
self.service_validators['SQOOP'] = self._assert_sqoop
self.service_validators['HBASE'] = self._assert_hbase
class TestNodeGroup:
def __init__(self, name, instances, node_processes, count=1):


+ 2
- 2
sahara/tests/unit/plugins/hdp/test_services.py View File

@ -14,7 +14,7 @@
# limitations under the License.
import mock
import unittest2
import testtools
from sahara import exceptions as e
from sahara.plugins.general import exceptions as ex
@ -24,7 +24,7 @@ from sahara.tests.unit.plugins.hdp import hdp_test_base
versions = ['1.3.2', '2.0.6']
class ServicesTest(unittest2.TestCase):
class ServicesTest(testtools.TestCase):
#TODO(jspeidel): test remaining service functionality which isn't
# tested by coarser grained unit tests.


+ 2
- 2
sahara/tests/unit/plugins/hdp/test_versionmanagerfactory.py View File

@ -13,12 +13,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest2
import testtools
from sahara.plugins.hdp.versions import versionhandlerfactory
class VersionManagerFactoryTest(unittest2.TestCase):
class VersionManagerFactoryTest(testtools.TestCase):
def test_get_versions(self):
factory = versionhandlerfactory.VersionHandlerFactory.get_instance()


+ 3
- 2
sahara/tests/unit/plugins/test_base_plugins_support.py View File

@ -13,14 +13,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest2
import testtools
from sahara.plugins import base as pb
class BasePluginsSupportTest(unittest2.TestCase):
class BasePluginsSupportTest(testtools.TestCase):
def setUp(self):
super(BasePluginsSupportTest, self).setUp()
pb.setup_plugins()
def test_plugins_loaded(self):


+ 4
- 4
sahara/tests/unit/plugins/test_provisioning.py View File

@ -13,13 +13,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest2
import testtools
from sahara import exceptions as ex
from sahara.plugins import provisioning as p
class ProvisioningPluginBaseTest(unittest2.TestCase):
class ProvisioningPluginBaseTest(testtools.TestCase):
def test__map_to_user_inputs_success(self):
c1, c2, c3, plugin = _build_configs_and_plugin()
@ -42,14 +42,14 @@ class ProvisioningPluginBaseTest(unittest2.TestCase):
def test__map_to_user_inputs_failure(self):
c1, c2, c3, plugin = _build_configs_and_plugin()
with self.assertRaises(ex.ConfigurationError):
with testtools.ExpectedException(ex.ConfigurationError):
plugin._map_to_user_inputs(None, {
'at-X': {
'n-1': 'v-1',
},
})
with self.assertRaises(ex.ConfigurationError):
with testtools.ExpectedException(ex.ConfigurationError):
plugin._map_to_user_inputs(None, {
'at-1': {
'n-X': 'v-1',


+ 3
- 3
sahara/tests/unit/plugins/vanilla/v1_2_1/test_dfsadmin_parsing.py View File

@ -14,13 +14,13 @@
# limitations under the License.
import pkg_resources as pkg
import unittest2
import testtools
from sahara.plugins.vanilla.v1_2_1 import scaling as sc
from sahara import version
class ProvisioningPluginBaseTest(unittest2.TestCase):
class ProvisioningPluginBaseTest(testtools.TestCase):
def test_result_for_3_nodes(self):
ins = open(pkg.resource_filename(
version.version_info.package, "tests/unit/resources/"
@ -34,7 +34,7 @@ class ProvisioningPluginBaseTest(unittest2.TestCase):
"Remaining%": "93.42%"}
expected = [exp1, exp2, exp3]
res = sc.parse_dfs_report(big_string)
self.assertItemsEqual(expected, res)
self.assertEqual(expected, res)
def test_result_for_0_nodes(self):
ins = open(pkg.resource_filename(


+ 24
- 23
sahara/tests/unit/plugins/vanilla/v1_2_1/test_plugin.py View File

@ -14,6 +14,7 @@
# limitations under the License.
import mock
import testtools
from sahara import conductor as cond
from sahara import context
@ -44,19 +45,19 @@ class VanillaPluginTest(base.SaharaWithDbTestCase):
self._validate_case(1, 1, 10, 1)
with self.assertRaises(ex.InvalidComponentCountException):
with testtools.ExpectedException(ex.InvalidComponentCountException):
self._validate_case(0, 1, 10, 1)
with self.assertRaises(ex.InvalidComponentCountException):
with testtools.ExpectedException(ex.InvalidComponentCountException):
self._validate_case(2, 1, 10, 1)
with self.assertRaises(ex.RequiredServiceMissingException):
with testtools.ExpectedException(ex.RequiredServiceMissingException):
self._validate_case(1, 0, 10, 1)
with self.assertRaises(ex.InvalidComponentCountException):
with testtools.ExpectedException(ex.InvalidComponentCountException):
self._validate_case(1, 2, 10, 1)
with self.assertRaises(ex.InvalidComponentCountException):
with testtools.ExpectedException(ex.InvalidComponentCountException):
self._validate_case(1, 1, 0, 2)
with self.assertRaises(ex.RequiredServiceMissingException):
with testtools.ExpectedException(ex.RequiredServiceMissingException):
self._validate_case(1, 0, 0, 1)
def _validate_case(self, *args):
@ -96,12 +97,12 @@ class VanillaPluginTest(base.SaharaWithDbTestCase):
"Wrong-applicable-target": {
't1': 4
}}
self.assertListEqual(c_h.extract_environment_confs(env_configs),
['HADOOP_NAMENODE_OPTS=\\"-Xmx3000m\\"',
'HADOOP_DATANODE_OPTS=\\"-Xmx4000m\\"',
'CATALINA_OPTS -Xmx4000m',
'HADOOP_JOBTRACKER_OPTS=\\"-Xmx1000m\\"',
'HADOOP_TASKTRACKER_OPTS=\\"-Xmx2000m\\"'])
self.assertEqual(c_h.extract_environment_confs(env_configs),
['HADOOP_NAMENODE_OPTS=\\"-Xmx3000m\\"',
'HADOOP_DATANODE_OPTS=\\"-Xmx4000m\\"',
'CATALINA_OPTS -Xmx4000m',
'HADOOP_JOBTRACKER_OPTS=\\"-Xmx1000m\\"',
'HADOOP_TASKTRACKER_OPTS=\\"-Xmx2000m\\"'])
def test_extract_xml_configs(self):
xml_configs = {
@ -119,11 +120,11 @@ class VanillaPluginTest(base.SaharaWithDbTestCase):
}
}
self.assertListEqual(c_h.extract_xml_confs(xml_configs),
[('fs.default.name', 'hdfs://'),
('dfs.replication', 3),
('mapred.reduce.tasks', 2),
('io.sort.factor', 10)])
self.assertEqual(c_h.extract_xml_confs(xml_configs),
[('fs.default.name', 'hdfs://'),
('dfs.replication', 3),
('mapred.reduce.tasks', 2),
('io.sort.factor', 10)])
def test_general_configs(self):
gen_config = {
@ -150,28 +151,28 @@ class VanillaPluginTest(base.SaharaWithDbTestCase):
}
}
cfg = c_h.generate_cfg_from_general({}, configs, gen_config)
self.assertDictEqual(cfg, all_configured)
self.assertEqual(cfg, all_configured)
configs['general'].update({'Enable MySQL': False})
cfg = c_h.generate_cfg_from_general({}, configs, gen_config)
self.assertDictEqual(cfg, {'fs.swift.enabled': True})
self.assertEqual(cfg, {'fs.swift.enabled': True})
configs['general'].update({
'Enable Swift': False,
'Enable MySQL': False
})
cfg = c_h.generate_cfg_from_general({}, configs, gen_config)
self.assertDictEqual(cfg, {})
self.assertEqual(cfg, {})
configs = {}
cfg = c_h.generate_cfg_from_general({}, configs, gen_config)
self.assertDictEqual(cfg, all_configured)
self.assertEqual(cfg, all_configured)
def test_get_mysql_configs(self):
cfg = m_h.get_required_mysql_configs(None, None)
self.assertDictEqual(cfg, m_h.get_oozie_mysql_configs())
self.assertEqual(cfg, m_h.get_oozie_mysql_configs())
cfg = m_h.get_required_mysql_configs("metastore_host", "passwd")
cfg_to_compare = m_h.get_oozie_mysql_configs()
cfg_to_compare.update(m_h.get_hive_mysql_configs(
"metastore_host", "passwd"))
self.assertDictEqual(cfg, cfg_to_compare)
self.assertEqual(cfg, cfg_to_compare)
@mock.patch('sahara.conductor.api.LocalApi.cluster_get')
def test_get_config_value(self, cond_get_cluster):


+ 2
- 4
sahara/tests/unit/plugins/vanilla/v1_2_1/test_run_scripts.py View File

@ -14,14 +14,12 @@
# limitations under the License.
import mock
import unittest2
import testtools
from sahara.plugins.vanilla.v1_2_1 import run_scripts
class RunScriptsTest(unittest2.TestCase):
def setUp(self):
pass
class RunScriptsTest(testtools.TestCase):
def test_check_datanodes_count_positive(self):
remote = mock.Mock()


+ 2
- 2
sahara/tests/unit/plugins/vanilla/v2_3_0/test_configs.py View File

@ -30,7 +30,7 @@ class VanillaTwoConfigTestCase(base.SaharaTestCase):
'hadoop_secure_dn_log_dir': '/vol1/hadoop/logs/secure',
'yarn_log_dir': '/vol1/yarn/logs'
}
self.assertDictEqual(dirs, expected)
self.assertEqual(dirs, expected)
def test_merge_configs(self):
a = {
@ -60,7 +60,7 @@ class VanillaTwoConfigTestCase(base.SaharaTestCase):
'param5': 'value5'
}
}
self.assertDictEqual(res, expected)
self.assertEqual(res, expected)
class FakeNG():


+ 2
- 2
sahara/tests/unit/plugins/vanilla/v2_3_0/test_utils.py View File

@ -36,7 +36,7 @@ class UtilsTestCase(base.SaharaTestCase):
'cluster-worker-004.novalocal': 'decommissioned'
}
self.assertDictEqual(statuses, expected)
self.assertEqual(statuses, expected)
@mock.patch('sahara.plugins.vanilla.utils.get_resourcemanager')
def test_nodemanagers_status(self, rm):
@ -53,7 +53,7 @@ class UtilsTestCase(base.SaharaTestCase):
'cluster-worker-004.novalocal': 'decommissioned'
}
self.assertDictEqual(statuses, expected)
self.assertEqual(statuses, expected)
def _get_instance(self, out):
inst_remote = mock.MagicMock()


+ 12
- 10
sahara/tests/unit/plugins/vanilla/v2_3_0/test_validation.py View File

@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import testtools
from sahara.plugins.general import exceptions as ex
from sahara.plugins.vanilla import plugin as p
from sahara.tests.unit import base
@ -42,28 +44,28 @@ class ValidationTest(base.SaharaTestCase):
self._validate_case(1, 0, 1, 1, 1, 1, 1)
self._validate_case(1, 1, 1, 1, 1, 1, 0)
with self.assertRaises(ex.InvalidComponentCountException):
with testtools.ExpectedException(ex.InvalidComponentCountException):
self._validate_case(0, 0, 1, 10, 1, 0, 0)
with self.assertRaises(ex.InvalidComponentCountException):
with testtools.ExpectedException(ex.InvalidComponentCountException):
self._validate_case(2, 0, 1, 10, 1, 0, 0)
with self.assertRaises(ex.InvalidComponentCountException):
with testtools.ExpectedException(ex.InvalidComponentCountException):
self._validate_case(1, 2, 1, 1, 1, 1, 1)
with self.assertRaises(ex.RequiredServiceMissingException):
with testtools.ExpectedException(ex.RequiredServiceMissingException):
self._validate_case(1, 0, 0, 10, 1, 0, 0)
with self.assertRaises(ex.InvalidComponentCountException):
with testtools.ExpectedException(ex.InvalidComponentCountException):
self._validate_case(1, 0, 2, 10, 1, 0, 0)
with self.assertRaises(ex.InvalidComponentCountException):
with testtools.ExpectedException(ex.InvalidComponentCountException):
self._validate_case(1, 0, 1, 1, 1, 2, 1)
with self.assertRaises(ex.InvalidComponentCountException):
with testtools.ExpectedException(ex.InvalidComponentCountException):
self._validate_case(1, 0, 1, 1, 1, 1, 2)
with self.assertRaises(ex.RequiredServiceMissingException):
with testtools.ExpectedException(ex.RequiredServiceMissingException):
self._validate_case(1, 0, 1, 1, 1, 0, 1)
with self.assertRaises(ex.RequiredServiceMissingException):
with testtools.ExpectedException(ex.RequiredServiceMissingException):
self._validate_case(1, 0, 1, 0, 1, 1, 1)
with self.assertRaises(ex.RequiredServiceMissingException):
with testtools.ExpectedException(ex.RequiredServiceMissingException):
self._validate_case(1, 0, 1, 1, 0, 1, 1)
def _validate_case(self, *args):


+ 2
- 2
sahara/tests/unit/service/edp/test_job_possible_configs.py View File

@ -13,13 +13,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest2
import testtools
from sahara.service.edp.workflow_creator import workflow_factory as w_f
from sahara.utils import edp
class TestJobPossibleConfigs(unittest2.TestCase):
class TestJobPossibleConfigs(testtools.TestCase):
def test_possible_configs(self):
res = w_f.get_possible_job_config(edp.JOB_TYPE_MAPREDUCE)


+ 4
- 3
sahara/tests/unit/service/edp/workflow_creator/test_create_workflow.py View File

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest2
import testtools
import sahara.exceptions as ex
from sahara.service.edp.workflow_creator import hive_workflow as hw
@ -23,9 +23,10 @@ from sahara.service.edp.workflow_creator import pig_workflow as pw
from sahara.utils import patches as p
class TestPigWorkflowCreator(unittest2.TestCase):
class TestPigWorkflowCreator(testtools.TestCase):
def setUp(self):
super(TestPigWorkflowCreator, self).setUp()
p.patch_minidom_writexml()
self.prepare = {'delete': ['delete_dir_1', 'delete_dir_2'],
'mkdir': ['mkdir_1']}
@ -59,7 +60,7 @@ class TestPigWorkflowCreator(unittest2.TestCase):
self.assertNotIn(mr_action, res)
mr_workflow = mrw.MapReduceWorkFlowCreator()
with self.assertRaises(ex.NotFoundException):
with testtools.ExpectedException(ex.NotFoundException):
mr_workflow.build_workflow_xml(self.prepare, self.job_xml,
self.configuration, self.files,
self.archives, {'bogus': 'element'})


+ 6
- 7
sahara/tests/unit/service/test_instances.py View File

@ -14,9 +14,9 @@
# limitations under the License.
import mock
from novaclient import exceptions as nova_exceptions
import six
import testtools
from sahara import conductor as cond
from sahara import context
@ -68,7 +68,7 @@ class TestClusterRollBack(AbstractInstanceTest):
self.nova.servers.list.return_value = [_mock_instance(1)]
with self.assertRaises(MockException):
with testtools.ExpectedException(MockException):
self.engine.create_cluster(cluster)
ctx = context.ctx()
@ -172,11 +172,10 @@ class NodePlacementTest(AbstractInstanceTest):
instance_names.append(instance_name)
self.assertEqual(3, len(instance_names))
self.assertItemsEqual([
'test_cluster-test_group_1-001',
'test_cluster-test_group_1-002',
'test_cluster-test_group_2-001',
], instance_names)
self.assertEqual(set(['test_cluster-test_group_1-001',
'test_cluster-test_group_1-002',
'test_cluster-test_group_2-001']),
set(instance_names))
self.nova.servers.create.assert_has_calls(
[mock.call(instance_names[0],


+ 9
- 7
sahara/tests/unit/service/validation/edp/test_data_source.py View File

@ -14,6 +14,7 @@
# limitations under the License.
import mock
import testtools
import sahara.exceptions as ex
from sahara.service import api
@ -27,6 +28,7 @@ SAMPLE_SWIFT_URL_WITH_SUFFIX = "swift://1234%s/object" % su.SWIFT_URL_SUFFIX
class TestDataSourceValidation(u.ValidationTestCase):
def setUp(self):
super(TestDataSourceValidation, self).setUp()
self._create_object_fun = ds.check_data_source_create
self.scheme = ds.DATA_SOURCE_SCHEMA
api.plugin_base.setup_plugins()
@ -56,7 +58,7 @@ class TestDataSourceValidation(u.ValidationTestCase):
"type": "swift",
"description": "long description"
}
with self.assertRaises(ex.InvalidCredentials):
with testtools.ExpectedException(ex.InvalidCredentials):
ds.check_data_source_create(data)
@mock.patch("sahara.service.validations."
@ -75,7 +77,7 @@ class TestDataSourceValidation(u.ValidationTestCase):
},
"description": "long description"
}
with self.assertRaises(ex.InvalidCredentials):
with testtools.ExpectedException(ex.InvalidCredentials):
ds.check_data_source_create(data)
@mock.patch("sahara.service.validations."
@ -94,7 +96,7 @@ class TestDataSourceValidation(u.ValidationTestCase):
},
"description": "long description"
}
with self.assertRaises(ex.InvalidCredentials):
with testtools.ExpectedException(ex.InvalidCredentials):
ds.check_data_source_create(data)
@mock.patch("sahara.service.validations."
@ -108,7 +110,7 @@ class TestDataSourceValidation(u.ValidationTestCase):
"type": "swift",
"description": "incorrect url schema"
}
with self.assertRaises(ex.InvalidException):
with testtools.ExpectedException(ex.InvalidException):
ds.check_data_source_create(data)
@mock.patch("sahara.service.validations."
@ -141,7 +143,7 @@ class TestDataSourceValidation(u.ValidationTestCase):
"type": "swift",
"description": "incorrect url schema"
}
with self.assertRaises(ex.InvalidException):
with testtools.ExpectedException(ex.InvalidException):
ds.check_data_source_create(data)
@mock.patch("sahara.service.validations."
@ -156,7 +158,7 @@ class TestDataSourceValidation(u.ValidationTestCase):
"type": "swift",
"description": "incorrect url schema"
}
with self.assertRaises(ex.InvalidException):
with testtools.ExpectedException(ex.InvalidException):
ds.check_data_source_create(data)
@mock.patch("sahara.service.validations."
@ -170,7 +172,7 @@ class TestDataSourceValidation(u.ValidationTestCase):
"type": "hdfs",
"description": "incorrect url schema"
}
with self.assertRaises(ex.InvalidException):
with testtools.ExpectedException(ex.InvalidException):
ds.check_data_source_create(data)
@mock.patch("sahara.service.validations."


+ 1
- 0
sahara/tests/unit/service/validation/edp/test_job.py View File

@ -21,6 +21,7 @@ from sahara.utils import edp
class TestJobValidation(u.ValidationTestCase):
def setUp(self):
super(TestJobValidation, self).setUp()
self._create_object_fun = j.check_mains_libs
self.scheme = j.JOB_SCHEMA


+ 1
- 0
sahara/tests/unit/service/validation/edp/test_job_binary.py View File

@ -21,6 +21,7 @@ from sahara.tests.unit.service.validation import utils as u
class TestJobBinaryValidation(u.ValidationTestCase):
def setUp(self):
super(TestJobBinaryValidation, self).setUp()
self._create_object_fun = b.check_job_binary
self.scheme = b.JOB_BINARY_SCHEMA
api.plugin_base.setup_plugins()


+ 1
- 0
sahara/tests/unit/service/validation/edp/test_job_executor.py View File

@ -38,6 +38,7 @@ class FakeJob(object):
class TestJobExecValidation(u.ValidationTestCase):
def setUp(self):
super(TestJobExecValidation, self).setUp()
self._create_object_fun = wrap_it
self.scheme = je.JOB_EXEC_SCHEMA
api.plugin_base.setup_plugins()


+ 2
- 1
sahara/tests/unit/service/validation/edp/test_job_executor_java.py View File

@ -32,9 +32,10 @@ class FakeJob(object):
libs = []
class TestJobExecValidation(u.ValidationTestCase):
class TestJobExecJavaValidation(u.ValidationTestCase):
def setUp(self):
super(TestJobExecJavaValidation, self).setUp()
self._create_object_fun = wrap_it
self.scheme = je.JOB_EXEC_SCHEMA


+ 1
- 0
sahara/tests/unit/service/validation/test_add_tags_validation.py View File

@ -19,6 +19,7 @@ from sahara.tests.unit.service.validation import utils as u
class TestTagsAddingValidation(u.ValidationTestCase):
def setUp(self):
super(TestTagsAddingValidation, self).setUp()
self._create_object_fun = im.check_tags
self.scheme = im.image_tags_schema


+ 4
- 2
sahara/tests/unit/service/validation/test_cluster_create_validation.py View File

@ -15,6 +15,7 @@
import mock
import six
import testtools
from sahara import exceptions
from sahara import main
@ -26,6 +27,7 @@ from sahara.tests.unit.service.validation import utils as u
class TestClusterCreateValidation(u.ValidationTestCase):
def setUp(self):
super(TestClusterCreateValidation, self).setUp()
self._create_object_fun = c.check_cluster_create
self.scheme = c.CLUSTER_SCHEMA
api.plugin_base.setup_plugins()
@ -387,7 +389,7 @@ class TestClusterCreateFlavorValidation(base.SaharaWithDbTestCase):
'default_image_id': '550e8400-e29b-41d4-a716-446655440000'
}
for values in [data, data1]:
with self.assertRaises(exceptions.InvalidException):
with testtools.ExpectedException(exceptions.InvalidException):
try:
patchers = u.start_patch(False)
c.check_cluster_create(values)
@ -447,7 +449,7 @@ class TestClusterCreateFlavorValidation(base.SaharaWithDbTestCase):
],
'default_image_id': '550e8400-e29b-41d4-a716-446655440000'
}
with self.assertRaises(exceptions.InvalidException):
with testtools.ExpectedException(exceptions.InvalidException):
try:
patchers = u.start_patch(False)
c.check_cluster_create(data)


+ 4
- 3
sahara/tests/unit/service/validation/test_cluster_scaling_validation.py View File

@ -15,7 +15,7 @@
import mock
import six
import unittest2
import testtools
from sahara import exceptions as ex
from sahara.plugins.vanilla import plugin
@ -32,8 +32,9 @@ def _get_plugin(plugin_name):
return None
class TestScalingValidation(unittest2.TestCase):
class TestScalingValidation(testtools.TestCase):
def setUp(self):
super(TestScalingValidation, self).setUp()
api.plugin_base.setup_plugins()
self._create_object_fun = mock.Mock()
@ -48,7 +49,7 @@ class TestScalingValidation(unittest2.TestCase):
get_cluster_p.return_value = cluster
get_plugin_p.side_effect = _get_plugin
with self.assertRaises(ex.InvalidException):
with testtools.ExpectedException(ex.InvalidException):
try:
c_s.check_cluster_scaling(data, cluster.id)
except ex.InvalidException as e:


+ 1
- 0
sahara/tests/unit/service/validation/test_cluster_template_create_validation.py View File

@ -20,6 +20,7 @@ from sahara.tests.unit.service.validation import utils as u
class TestClusterTemplateCreateValidation(u.ValidationTestCase):
def setUp(self):
super(TestClusterTemplateCreateValidation, self).setUp()
self._create_object_fun = ct.check_cluster_template_create
self.scheme = ct.CLUSTER_TEMPLATE_SCHEMA
api.plugin_base.setup_plugins()


+ 1
- 0
sahara/tests/unit/service/validation/test_ng_template_validation_create.py View File

@ -20,6 +20,7 @@ from sahara.tests.unit.service.validation import utils as u
class TestNGTemplateCreateValidation(u.ValidationTestCase):
def setUp(self):
super(TestNGTemplateCreateValidation, self).setUp()
self._create_object_fun = nt.check_node_group_template_create
self.scheme = nt.NODE_GROUP_TEMPLATE_SCHEMA
api.plugin_base.setup_plugins()