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:
parent
b2f25e97a4
commit
819f93fe0a
@ -120,7 +120,7 @@ class NodesToCsvExportTest(InstStructureTest, DbTest):
|
|||||||
exporter.get_node_keys_paths()
|
exporter.get_node_keys_paths()
|
||||||
flatten_nodes = exporter.get_flatten_nodes(
|
flatten_nodes = exporter.get_flatten_nodes(
|
||||||
structure_paths, cluster_paths, node_paths, inst_structures)
|
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_mn_uid = csv_paths.index(['master_node_uid'])
|
||||||
pos_cluster_id = csv_paths.index(['cluster_id'])
|
pos_cluster_id = csv_paths.index(['cluster_id'])
|
||||||
pos_status = csv_paths.index(['status'])
|
pos_status = csv_paths.index(['status'])
|
||||||
@ -139,7 +139,7 @@ class NodesToCsvExportTest(InstStructureTest, DbTest):
|
|||||||
installations_num=installations_num)
|
installations_num=installations_num)
|
||||||
# Filtering installation structures
|
# Filtering installation structures
|
||||||
result = exporter.export_nodes(inst_structures)
|
result = exporter.export_nodes(inst_structures)
|
||||||
self.assertTrue(isinstance(result, types.GeneratorType))
|
self.assertIsInstance(result, types.GeneratorType)
|
||||||
output = six.StringIO(list(result))
|
output = six.StringIO(list(result))
|
||||||
reader = csv.reader(output)
|
reader = csv.reader(output)
|
||||||
for _ in reader:
|
for _ in reader:
|
||||||
|
@ -68,7 +68,7 @@ class OswlStatsToCsvTest(OswlTest, DbTest):
|
|||||||
oswls = self.generate_oswls(2, resource_type)
|
oswls = self.generate_oswls(2, resource_type)
|
||||||
flatten_resources = exporter.get_flatten_resources(
|
flatten_resources = exporter.get_flatten_resources(
|
||||||
resource_type, oswl_keys_paths, resource_keys_paths, oswls, {})
|
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:
|
for _ in flatten_resources:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ class OswlStatsToCsvTest(OswlTest, DbTest):
|
|||||||
# Checking export
|
# Checking export
|
||||||
result = exporter.export(resource_type, oswls,
|
result = exporter.export(resource_type, oswls,
|
||||||
datetime.utcnow().date(), {})
|
datetime.utcnow().date(), {})
|
||||||
self.assertTrue(isinstance(result, types.GeneratorType))
|
self.assertIsInstance(result, types.GeneratorType)
|
||||||
output = six.StringIO(list(result))
|
output = six.StringIO(list(result))
|
||||||
reader = csv.reader(output)
|
reader = csv.reader(output)
|
||||||
for _ in reader:
|
for _ in reader:
|
||||||
@ -151,7 +151,7 @@ class OswlStatsToCsvTest(OswlTest, DbTest):
|
|||||||
exporter = OswlStatsToCsv()
|
exporter = OswlStatsToCsv()
|
||||||
for resource_type in self.RESOURCE_TYPES:
|
for resource_type in self.RESOURCE_TYPES:
|
||||||
result = exporter.export(resource_type, [], {}, None)
|
result = exporter.export(resource_type, [], {}, None)
|
||||||
self.assertTrue(isinstance(result, types.GeneratorType))
|
self.assertIsInstance(result, types.GeneratorType)
|
||||||
output = six.StringIO(list(result))
|
output = six.StringIO(list(result))
|
||||||
reader = csv.reader(output)
|
reader = csv.reader(output)
|
||||||
for _ in reader:
|
for _ in reader:
|
||||||
@ -262,7 +262,7 @@ class OswlStatsToCsvTest(OswlTest, DbTest):
|
|||||||
def test_fill_date_gaps_empty_data_is_not_failed(self):
|
def test_fill_date_gaps_empty_data_is_not_failed(self):
|
||||||
exporter = OswlStatsToCsv()
|
exporter = OswlStatsToCsv()
|
||||||
oswls = exporter.fill_date_gaps([], datetime.utcnow().date())
|
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):
|
def test_resource_data_on_oswl_duplication(self):
|
||||||
exporter = OswlStatsToCsv()
|
exporter = OswlStatsToCsv()
|
||||||
@ -347,7 +347,7 @@ class OswlStatsToCsvTest(OswlTest, DbTest):
|
|||||||
oswls = get_oswls(resource_type)
|
oswls = get_oswls(resource_type)
|
||||||
result = exporter.export(resource_type, oswls,
|
result = exporter.export(resource_type, oswls,
|
||||||
datetime.utcnow().date(), {})
|
datetime.utcnow().date(), {})
|
||||||
self.assertTrue(isinstance(result, types.GeneratorType))
|
self.assertIsInstance(result, types.GeneratorType)
|
||||||
output = six.StringIO(list(result))
|
output = six.StringIO(list(result))
|
||||||
reader = csv.reader(output)
|
reader = csv.reader(output)
|
||||||
for _ in reader:
|
for _ in reader:
|
||||||
|
@ -53,7 +53,7 @@ class PluginsToCsvExportTest(InstStructureTest, DbTest):
|
|||||||
exporter.get_plugin_keys_paths()
|
exporter.get_plugin_keys_paths()
|
||||||
flatten_plugins = exporter.get_flatten_plugins(
|
flatten_plugins = exporter.get_flatten_plugins(
|
||||||
structure_paths, cluster_paths, plugins_paths, inst_structures)
|
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_mn_uid = csv_paths.index(['master_node_uid'])
|
||||||
pos_cluster_id = csv_paths.index(['cluster_id'])
|
pos_cluster_id = csv_paths.index(['cluster_id'])
|
||||||
for flatten_plugin in flatten_plugins:
|
for flatten_plugin in flatten_plugins:
|
||||||
@ -70,7 +70,7 @@ class PluginsToCsvExportTest(InstStructureTest, DbTest):
|
|||||||
installations_num=installations_num)
|
installations_num=installations_num)
|
||||||
# Filtering installation structures
|
# Filtering installation structures
|
||||||
result = exporter.export_plugins(inst_structures)
|
result = exporter.export_plugins(inst_structures)
|
||||||
self.assertTrue(isinstance(result, types.GeneratorType))
|
self.assertIsInstance(result, types.GeneratorType)
|
||||||
output = six.StringIO(list(result))
|
output = six.StringIO(list(result))
|
||||||
reader = csv.reader(output)
|
reader = csv.reader(output)
|
||||||
for _ in reader:
|
for _ in reader:
|
||||||
|
@ -82,7 +82,7 @@ class StatsToCsvExportTest(InstStructureTest, DbTest):
|
|||||||
exporter.get_cluster_keys_paths()
|
exporter.get_cluster_keys_paths()
|
||||||
flatten_clusters = exporter.get_flatten_clusters(
|
flatten_clusters = exporter.get_flatten_clusters(
|
||||||
structure_paths, cluster_paths, inst_structures, [])
|
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:
|
for flatten_cluster in flatten_clusters:
|
||||||
self.assertEquals(len(csv_paths), len(flatten_cluster))
|
self.assertEquals(len(csv_paths), len(flatten_cluster))
|
||||||
|
|
||||||
@ -96,9 +96,9 @@ class StatsToCsvExportTest(InstStructureTest, DbTest):
|
|||||||
exporter.get_cluster_keys_paths()
|
exporter.get_cluster_keys_paths()
|
||||||
flatten_clusters = exporter.get_flatten_clusters(
|
flatten_clusters = exporter.get_flatten_clusters(
|
||||||
structure_paths, cluster_paths, inst_structures, [])
|
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)
|
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))
|
output = six.StringIO(list(result))
|
||||||
reader = csv.reader(output)
|
reader = csv.reader(output)
|
||||||
# Pop columns names from reader
|
# Pop columns names from reader
|
||||||
@ -128,7 +128,7 @@ class StatsToCsvExportTest(InstStructureTest, DbTest):
|
|||||||
installations_num=installations_num)
|
installations_num=installations_num)
|
||||||
exporter = StatsToCsv()
|
exporter = StatsToCsv()
|
||||||
result = exporter.export_clusters(inst_structures, [])
|
result = exporter.export_clusters(inst_structures, [])
|
||||||
self.assertTrue(isinstance(result, types.GeneratorType))
|
self.assertIsInstance(result, types.GeneratorType)
|
||||||
|
|
||||||
def test_filter_by_date(self):
|
def test_filter_by_date(self):
|
||||||
exporter = StatsToCsv()
|
exporter = StatsToCsv()
|
||||||
@ -140,7 +140,7 @@ class StatsToCsvExportTest(InstStructureTest, DbTest):
|
|||||||
installations_num=num)
|
installations_num=num)
|
||||||
# Filtering installation structures
|
# Filtering installation structures
|
||||||
result = exporter.export_clusters(inst_structures, [])
|
result = exporter.export_clusters(inst_structures, [])
|
||||||
self.assertTrue(isinstance(result, types.GeneratorType))
|
self.assertIsInstance(result, types.GeneratorType)
|
||||||
output = six.StringIO(list(result))
|
output = six.StringIO(list(result))
|
||||||
reader = csv.reader(output)
|
reader = csv.reader(output)
|
||||||
for _ in reader:
|
for _ in reader:
|
||||||
|
Loading…
Reference in New Issue
Block a user