Change assertTrue(isinstance()) by optimal assert

Some of tests use different method of
assertTrue(isinstance(A, B)) or assertEqual(type(A), B).
The correct way is to use assertIsInstance(A, B) provided
by testtools

Change-Id: I6bb51ecec188847f67b579694bd47bf7599bfbd6
This commit is contained in:
gecong1973 2016-11-17 10:50:57 +08:00
parent b2f25e97a4
commit 819f93fe0a
4 changed files with 14 additions and 14 deletions

View File

@ -120,7 +120,7 @@ class NodesToCsvExportTest(InstStructureTest, DbTest):
exporter.get_node_keys_paths()
flatten_nodes = exporter.get_flatten_nodes(
structure_paths, cluster_paths, node_paths, inst_structures)
self.assertTrue(isinstance(flatten_nodes, types.GeneratorType))
self.assertIsInstance(flatten_nodes, types.GeneratorType)
pos_mn_uid = csv_paths.index(['master_node_uid'])
pos_cluster_id = csv_paths.index(['cluster_id'])
pos_status = csv_paths.index(['status'])
@ -139,7 +139,7 @@ class NodesToCsvExportTest(InstStructureTest, DbTest):
installations_num=installations_num)
# Filtering installation structures
result = exporter.export_nodes(inst_structures)
self.assertTrue(isinstance(result, types.GeneratorType))
self.assertIsInstance(result, types.GeneratorType)
output = six.StringIO(list(result))
reader = csv.reader(output)
for _ in reader:

View File

@ -68,7 +68,7 @@ class OswlStatsToCsvTest(OswlTest, DbTest):
oswls = self.generate_oswls(2, resource_type)
flatten_resources = exporter.get_flatten_resources(
resource_type, oswl_keys_paths, resource_keys_paths, oswls, {})
self.assertTrue(isinstance(flatten_resources, types.GeneratorType))
self.assertIsInstance(flatten_resources, types.GeneratorType)
for _ in flatten_resources:
pass
@ -141,7 +141,7 @@ class OswlStatsToCsvTest(OswlTest, DbTest):
# Checking export
result = exporter.export(resource_type, oswls,
datetime.utcnow().date(), {})
self.assertTrue(isinstance(result, types.GeneratorType))
self.assertIsInstance(result, types.GeneratorType)
output = six.StringIO(list(result))
reader = csv.reader(output)
for _ in reader:
@ -151,7 +151,7 @@ class OswlStatsToCsvTest(OswlTest, DbTest):
exporter = OswlStatsToCsv()
for resource_type in self.RESOURCE_TYPES:
result = exporter.export(resource_type, [], {}, None)
self.assertTrue(isinstance(result, types.GeneratorType))
self.assertIsInstance(result, types.GeneratorType)
output = six.StringIO(list(result))
reader = csv.reader(output)
for _ in reader:
@ -262,7 +262,7 @@ class OswlStatsToCsvTest(OswlTest, DbTest):
def test_fill_date_gaps_empty_data_is_not_failed(self):
exporter = OswlStatsToCsv()
oswls = exporter.fill_date_gaps([], datetime.utcnow().date())
self.assertTrue(isinstance(oswls, types.GeneratorType))
self.assertIsInstance(oswls, types.GeneratorType)
def test_resource_data_on_oswl_duplication(self):
exporter = OswlStatsToCsv()
@ -347,7 +347,7 @@ class OswlStatsToCsvTest(OswlTest, DbTest):
oswls = get_oswls(resource_type)
result = exporter.export(resource_type, oswls,
datetime.utcnow().date(), {})
self.assertTrue(isinstance(result, types.GeneratorType))
self.assertIsInstance(result, types.GeneratorType)
output = six.StringIO(list(result))
reader = csv.reader(output)
for _ in reader:

View File

@ -53,7 +53,7 @@ class PluginsToCsvExportTest(InstStructureTest, DbTest):
exporter.get_plugin_keys_paths()
flatten_plugins = exporter.get_flatten_plugins(
structure_paths, cluster_paths, plugins_paths, inst_structures)
self.assertTrue(isinstance(flatten_plugins, types.GeneratorType))
self.assertIsInstance(flatten_plugins, types.GeneratorType)
pos_mn_uid = csv_paths.index(['master_node_uid'])
pos_cluster_id = csv_paths.index(['cluster_id'])
for flatten_plugin in flatten_plugins:
@ -70,7 +70,7 @@ class PluginsToCsvExportTest(InstStructureTest, DbTest):
installations_num=installations_num)
# Filtering installation structures
result = exporter.export_plugins(inst_structures)
self.assertTrue(isinstance(result, types.GeneratorType))
self.assertIsInstance(result, types.GeneratorType)
output = six.StringIO(list(result))
reader = csv.reader(output)
for _ in reader:

View File

@ -82,7 +82,7 @@ class StatsToCsvExportTest(InstStructureTest, DbTest):
exporter.get_cluster_keys_paths()
flatten_clusters = exporter.get_flatten_clusters(
structure_paths, cluster_paths, inst_structures, [])
self.assertTrue(isinstance(flatten_clusters, types.GeneratorType))
self.assertIsInstance(flatten_clusters, types.GeneratorType)
for flatten_cluster in flatten_clusters:
self.assertEquals(len(csv_paths), len(flatten_cluster))
@ -96,9 +96,9 @@ class StatsToCsvExportTest(InstStructureTest, DbTest):
exporter.get_cluster_keys_paths()
flatten_clusters = exporter.get_flatten_clusters(
structure_paths, cluster_paths, inst_structures, [])
self.assertTrue(isinstance(flatten_clusters, types.GeneratorType))
self.assertIsInstance(flatten_clusters, types.GeneratorType)
result = export_utils.flatten_data_as_csv(csv_paths, flatten_clusters)
self.assertTrue(isinstance(result, types.GeneratorType))
self.assertIsInstance(result, types.GeneratorType)
output = six.StringIO(list(result))
reader = csv.reader(output)
# Pop columns names from reader
@ -128,7 +128,7 @@ class StatsToCsvExportTest(InstStructureTest, DbTest):
installations_num=installations_num)
exporter = StatsToCsv()
result = exporter.export_clusters(inst_structures, [])
self.assertTrue(isinstance(result, types.GeneratorType))
self.assertIsInstance(result, types.GeneratorType)
def test_filter_by_date(self):
exporter = StatsToCsv()
@ -140,7 +140,7 @@ class StatsToCsvExportTest(InstStructureTest, DbTest):
installations_num=num)
# Filtering installation structures
result = exporter.export_clusters(inst_structures, [])
self.assertTrue(isinstance(result, types.GeneratorType))
self.assertIsInstance(result, types.GeneratorType)
output = six.StringIO(list(result))
reader = csv.reader(output)
for _ in reader: