Exemplo n.º 1
0
 def test_file_dir_parser_results_match(self):
     parser = Parser()
     current_dir = os.path.dirname(os.path.realpath(__file__))
     file_path = current_dir + '/resources/parse_file_vs_dir/main.tf'
     dir_path = current_dir + '/resources/parse_file_vs_dir'
     tf_definitions_file = parser.parse_file(file_path)
     _, tf_definitions_dir = parser.parse_hcl_module(dir_path, 'terraform')
     self.assertDictEqual(tf_definitions_file, tf_definitions_dir.get(list(tf_definitions_dir.keys())[0]))
Exemplo n.º 2
0
    def _load_and_test(self, test_file, test_expected_file):
        current_dir = os.path.dirname(os.path.realpath(__file__))

        parser = Parser()
        parse_errors = {}
        result = parser.parse_file(f'{current_dir}/{test_file}', parse_errors)

        with open(f'{current_dir}/{test_expected_file}', 'r') as f:
            expected_result = json.load(f)
        self.assertEqual(len(parse_errors.keys()), 0)
        self.assertEqual(json.dumps(expected_result), json.dumps(result))