def __get_resources(self, source_resources: list): resources = list() for resource in source_resources or []: temp_resource = TfStateResource(resource) resources.append(temp_resource) self.__resources = resources
def test_print_htmltable(self): table = HtmlTableHelper([TfStateResource(self.valid_module_resource)]) captured_output = io.StringIO() sys.stdout = captured_output table.print() self.assertEqual(captured_output.getvalue().replace('\n', ''), self.print_htmltable_output.replace('\n', ''))
def test_write_html_file(self): table = HtmlTableHelper([TfStateResource(self.valid_module_resource)]) table.write_html_file() with open('.tflens/terraform.tfstate.html', 'r') as html_file: html_file_content = html_file.read() self.assertEqual(html_file_content.replace('\n', ''), self.file_htmltable_output.replace('\n', ''))
def test_write_markdowntable_file(self): table = MarkdownTableHelper( [TfStateResource(self.valid_module_resource)]) table.write_markdown_file() with open('.tflens/terraform.tfstate.md', 'r') as markdown_file: markdown_file_content = markdown_file.read() self.assertEqual(markdown_file_content.replace('\n', ''), self.print_markdowntable_output.replace('\n', ''))
def __init__(self, filter_expression: str, resource: TfStateResource): super().__init__(filter_expression=filter_expression, object_attribute_value=resource.get_mode())
def test_instances_count_empty_resource(self): tfstate_resource = TfStateResource(self.valid_module_resource) self.assertEqual(tfstate_resource.get_instances_count(), 0)
def test_valid_non_module_resource(self): tfstate_resource = TfStateResource(self.valid_non_module_resource) self.assertEqual(tfstate_resource.get_parent_module(), '-')
def test_set_table_non_valid_style(self): table = TableHelper([TfStateResource(self.valid_module_resource)]) self.assertRaises(ValueError, table.set_style, style="test")
def test_set_table_valid_style(self): table = TableHelper([TfStateResource(self.valid_module_resource)]) table.set_style(style=BeautifulTable.STYLE_MARKDOWN)
def test_valid_table_with_multiple_rows(self): TableHelper([ TfStateResource(self.valid_module_resource), TfStateResource(self.valid_non_module_resource) ])
def test_valid_table_with_one_row(self): TableHelper([TfStateResource(self.valid_module_resource)])