Repository: uccser/verto

Issue:
Fix 'required-glossary-terms' in documentation
In the documentation the key `required-glossary-terms` does not exist in the result object, the correct value is `required_glossary_terms`.

Discussion:

Patch:
diff --git a/verto/processors/GlossaryLinkPattern.py b/verto/processors/GlossaryLinkPattern.py
index b9b25b5..502a632 100644
--- a/verto/processors/GlossaryLinkPattern.py
+++ b/verto/processors/GlossaryLinkPattern.py
@@ -51,9 +51,10 @@ class GlossaryLinkPattern(Pattern):
             'text': text
         }
 
+        glossary_reference = self.ext_glossary_terms[term]
         if reference is not None:
             identifier = self.unique_slugify('glossary-' + term)
-            self.ext_glossary_terms[term].append((reference, identifier))
+            glossary_reference.append((reference, identifier))
             context['id'] = identifier
 
         html_string = self.template.render(context)


Test patch:
diff --git a/verto/tests/ConfigurationTest.py b/verto/tests/ConfigurationTest.py
index 8d26a45..f4405d2 100644
--- a/verto/tests/ConfigurationTest.py
+++ b/verto/tests/ConfigurationTest.py
@@ -64,7 +64,9 @@ class ConfigurationTest(BaseTest):
                             children=()
                         ),
                     ),
-                    required_glossary_terms=defaultdict(list)
+                    required_glossary_terms={
+                        'algorithm': []
+                    }
                 )
             ),
             ('some_processors.md',
@@ -116,6 +118,7 @@ class ConfigurationTest(BaseTest):
                         children=(),
                     ),),
                     required_glossary_terms={
+                        'hello': [],
                         'algorithm':
                             [('computer program', 'glossary-algorithm'),
                              ('algorithm cost', 'glossary-algorithm-2'),
@@ -126,15 +129,15 @@ class ConfigurationTest(BaseTest):
             )
         ]
 
-        for test in test_cases:
+        for filename, expected_result in test_cases:
             verto = Verto()
-            test_string = self.read_test_file(self.test_name, test[0])
+            test_string = self.read_test_file(self.test_name, filename)
             verto_result = verto.convert(test_string)
 
-            self.assertEqual(verto_result.title, test[1].title)
-            self.assertEqual(verto_result.required_files, test[1].required_files)
-            self.assertTupleEqual(verto_result.heading_tree, test[1].heading_tree)
-            self.assertDictEqual(verto_result.required_glossary_terms, test[1].required_glossary_terms)
+            self.assertEqual(verto_result.title, expected_result.title)
+            self.assertEqual(verto_result.required_files, expected_result.required_files)
+            self.assertTupleEqual(verto_result.heading_tree, expected_result.heading_tree)
+            self.assertDictEqual(verto_result.required_glossary_terms, expected_result.required_glossary_terms)
 
     def test_custom_processors_and_custom_templates_on_creation(self):
         '''Checks if custom processors and custom templates work
diff --git a/verto/tests/GlossaryLinkTest.py b/verto/tests/GlossaryLinkTest.py
index f019f5d..c1a9267 100644
--- a/verto/tests/GlossaryLinkTest.py
+++ b/verto/tests/GlossaryLinkTest.py
@@ -35,7 +35,9 @@ class GlossaryLinkTest(ProcessorTest):
         self.assertEqual(expected_string, converted_test_string)
 
         glossary_terms = self.verto_extension.glossary_terms
-        expected_glossary_terms = dict()
+        expected_glossary_terms = {
+            'quicksort': []
+        }
         self.assertDictEqual(expected_glossary_terms, glossary_terms)
 
     def test_multiple_word_term(self):
@@ -51,7 +53,9 @@ class GlossaryLinkTest(ProcessorTest):
         self.assertEqual(expected_string, converted_test_string)
 
         glossary_terms = self.verto_extension.glossary_terms
-        expected_glossary_terms = dict()
+        expected_glossary_terms = {
+            'digital-signature': []
+        }
         self.assertDictEqual(expected_glossary_terms, glossary_terms)
 
     def test_reference_text_given(self):
@@ -88,7 +92,9 @@ class GlossaryLinkTest(ProcessorTest):
         self.assertEqual(expected_string, converted_test_string)
 
         glossary_terms = self.verto_extension.glossary_terms
-        expected_glossary_terms = dict()
+        expected_glossary_terms = {
+            'grammar': []
+        }
         self.assertDictEqual(expected_glossary_terms, glossary_terms)
 
     def test_trailing_inline_text(self):
@@ -105,7 +111,9 @@ class GlossaryLinkTest(ProcessorTest):
         self.assertEqual(expected_string, converted_test_string)
 
         glossary_terms = self.verto_extension.glossary_terms
-        expected_glossary_terms = dict()
+        expected_glossary_terms = {
+            'finite state automaton': []
+        }
         self.assertDictEqual(expected_glossary_terms, glossary_terms)
 
     def test_leading_and_trailing_inline_text(self):
@@ -122,7 +130,9 @@ class GlossaryLinkTest(ProcessorTest):
         self.assertEqual(expected_string, converted_test_string)
 
         glossary_terms = self.verto_extension.glossary_terms
-        expected_glossary_terms = dict()
+        expected_glossary_terms = {
+            'Regular expression': []
+        }
         self.assertDictEqual(expected_glossary_terms, glossary_terms)
 
     def test_multiple_terms(self):
@@ -141,6 +151,8 @@ class GlossaryLinkTest(ProcessorTest):
 
         glossary_terms = self.verto_extension.glossary_terms
         expected_glossary_terms = {
+            'grammar': [],
+            'regular-expression': [],
             'finite-state-automaton':
                 [('Formal languages', 'glossary-finite-state-automaton')]
         }
@@ -162,6 +174,7 @@ class GlossaryLinkTest(ProcessorTest):
 
         glossary_terms = self.verto_extension.glossary_terms
         expected_glossary_terms = {
+            'hello': [],
             'algorithm':
                 [('computer program', 'glossary-algorithm'),
                  ('algorithm cost', 'glossary-algorithm-2'),
@@ -187,7 +200,9 @@ class GlossaryLinkTest(ProcessorTest):
         self.assertEqual(expected_string, converted_test_string)
 
         glossary_terms = self.verto_extension.glossary_terms
-        expected_glossary_terms = dict()
+        expected_glossary_terms = {
+            'algorithm': []
+        }
         self.assertDictEqual(expected_glossary_terms, glossary_terms)
 
     def test_doc_example_override_html(self):