Exemplo n.º 1
0
 def test_parse_missing_title_ascii(self):
     parser = LegacyParser(StringIO(DESTINATIONS_MISSING_TITLE_ASCII))
     count = 0
     for destination in parser.destinations():
         self.assertEqual(destination.name, 'africa')
         count += 1
     self.assertEqual(count, 1)
Exemplo n.º 2
0
 def test_parse_missing_attrib(self):
     parser = LegacyParser(StringIO(DESTINATIONS_MISSING_ATTRIB))
     count = 0
     for destination in parser.destinations():
         self.assertEqual(destination.name, 'africa')
         count += 1
     self.assertEqual(count, 1)
Exemplo n.º 3
0
 def test_parse_empty_destinations(self):
     parser = LegacyParser(StringIO(DESTINATIONS_EMPTY_SET))
     count = 0
     for destination in parser.destinations():
         self.assertIsInstance(destination, Destination)
         count += 1
     self.assertEqual(count, 0)
Exemplo n.º 4
0
 def test_cleanup_introduction(self):
     parser = LegacyParser(StringIO(DESTINATIONS_CLEANUP_INTRODUCTION))
     count = 0
     for destination in parser.destinations():
         count += 1
         self.assertEqual(destination.get_content('introduction'), 'An Introduction')
     self.assertEqual(count, 1)
Exemplo n.º 5
0
 def test_parse_missing_attrib(self):
     parser = LegacyParser(StringIO(DESTINATIONS_MISSING_ATTRIB))
     count = 0
     for destination in parser.destinations():
         self.assertEqual(destination.name, 'africa')
         count += 1
     self.assertEqual(count, 1)
Exemplo n.º 6
0
 def test_parse_missing_title_ascii(self):
     parser = LegacyParser(StringIO(DESTINATIONS_MISSING_TITLE_ASCII))
     count = 0
     for destination in parser.destinations():
         self.assertEqual(destination.name, 'africa')
         count += 1
     self.assertEqual(count, 1)
Exemplo n.º 7
0
 def test_parse_empty_destinations(self):
     parser = LegacyParser(StringIO(DESTINATIONS_EMPTY_SET))
     count = 0
     for destination in parser.destinations():
         self.assertIsInstance(destination, Destination)
         count += 1
     self.assertEqual(count, 0)
Exemplo n.º 8
0
 def test_cleanup_history(self):
     parser = LegacyParser(StringIO(DESTINATIONS_CLEANUP_HISTORY))
     count = 0
     for destination in parser.destinations():
         count += 1
         self.assertDictEqual(destination.get_content('history'), {'history': [u'Some History 1',
                                                                               u'Some History 2']})
     self.assertEqual(count, 1)
Exemplo n.º 9
0
 def test_cleanup_introduction(self):
     parser = LegacyParser(StringIO(DESTINATIONS_CLEANUP_INTRODUCTION))
     count = 0
     for destination in parser.destinations():
         count += 1
         self.assertEqual(destination.get_content('introduction'),
                          'An Introduction')
     self.assertEqual(count, 1)
Exemplo n.º 10
0
 def test_resolve_children(self):
     parser = LegacyParser(StringIO(DESTINATIONS_VALID), StringIO(TAXONOMY_VALID))
     children = [['south_africa'], []]
     count = 0
     for destination, check_children in zip(parser.destinations(), children):
         for child, check in zip(destination.children(), check_children):
             self.assertEqual(child['name'], check)
             count += 1
     self.assertEqual(count, 1)
Exemplo n.º 11
0
 def test_resolve_parents(self):
     parser = LegacyParser(StringIO(DESTINATIONS_VALID), StringIO(TAXONOMY_VALID))
     parents = [[], ['africa']]
     count = 0
     for destination, check_parents in zip(parser.destinations(), parents):
         for parent, check in zip(destination.parents(), check_parents):
             self.assertEqual(parent['name'], check)
             count += 1
     self.assertEqual(count, 1)
Exemplo n.º 12
0
 def test_cleanup_history(self):
     parser = LegacyParser(StringIO(DESTINATIONS_CLEANUP_HISTORY))
     count = 0
     for destination in parser.destinations():
         count += 1
         self.assertDictEqual(
             destination.get_content('history'),
             {'history': [u'Some History 1', u'Some History 2']})
     self.assertEqual(count, 1)
Exemplo n.º 13
0
 def test_resolve_parents(self):
     parser = LegacyParser(StringIO(DESTINATIONS_VALID),
                           StringIO(TAXONOMY_VALID))
     parents = [[], ['africa']]
     count = 0
     for destination, check_parents in zip(parser.destinations(), parents):
         for parent, check in zip(destination.parents(), check_parents):
             self.assertEqual(parent['name'], check)
             count += 1
     self.assertEqual(count, 1)
Exemplo n.º 14
0
 def test_parse_content(self):
     parser = LegacyParser(StringIO(DESTINATIONS_VALID))
     count = 0
     names = ['africa', 'south_africa']
     for destination in parser.destinations():
         self.assertIsInstance(destination, Destination)
         self.assertEqual(destination.name, names[count])
         self.assertEqual(destination.get_content('random'), 'Random String goes here')
         count += 1
     self.assertEqual(count, 2)
Exemplo n.º 15
0
 def test_parse_content(self):
     parser = LegacyParser(StringIO(DESTINATIONS_VALID))
     count = 0
     names = ['africa', 'south_africa']
     for destination in parser.destinations():
         self.assertIsInstance(destination, Destination)
         self.assertEqual(destination.name, names[count])
         self.assertEqual(destination.get_content('random'),
                          'Random String goes here')
         count += 1
     self.assertEqual(count, 2)
Exemplo n.º 16
0
 def test_resolve_children(self):
     parser = LegacyParser(StringIO(DESTINATIONS_VALID),
                           StringIO(TAXONOMY_VALID))
     children = [['south_africa'], []]
     count = 0
     for destination, check_children in zip(parser.destinations(),
                                            children):
         for child, check in zip(destination.children(), check_children):
             self.assertEqual(child['name'], check)
             count += 1
     self.assertEqual(count, 1)
Exemplo n.º 17
0
 def test_complex_content(self):
     parser = LegacyParser(StringIO(DESTINATIONS_COMPLEX_CONTENT))
     count = 0
     for destination in parser.destinations():
         count += 1
         self.assertDictEqual(destination.get_content(),
             {'section': {
                 'subsection_one': u'SS 1',
                 'subsection_two': {'has_a_list': [u'SS 2 El 1', u'SS 2 El 2', u'SS 2 El 3'],
                                    'and_something': u'A Something!', },
             },
              'another_section': u'Another Section',
             })
     self.assertEqual(count, 1)
Exemplo n.º 18
0
 def test_complex_content(self):
     parser = LegacyParser(StringIO(DESTINATIONS_COMPLEX_CONTENT))
     count = 0
     for destination in parser.destinations():
         count += 1
         self.assertDictEqual(
             destination.get_content(), {
                 'section': {
                     'subsection_one': u'SS 1',
                     'subsection_two': {
                         'has_a_list':
                         [u'SS 2 El 1', u'SS 2 El 2', u'SS 2 El 3'],
                         'and_something':
                         u'A Something!',
                     },
                 },
                 'another_section': u'Another Section',
             })
     self.assertEqual(count, 1)
Exemplo n.º 19
0
 def test_parse_metadata(self):
     parser = LegacyParser(StringIO(DESTINATIONS_VALID))
     self.assertDictEqual(
         parser.metadata, {
             'africa': {
                 'asset_id': '1-1',
                 'name': 'africa',
                 'title': 'Africa'
             },
             'south_africa': {
                 'asset_id': '2-1',
                 'name': 'south_africa',
                 'title': 'South Africa'
             },
         })
Exemplo n.º 20
0
 def test_parse_empty_content(self):
     parser = LegacyParser(StringIO(DESTINATIONS_EMPTY_CONTENT))
     for destination in parser.destinations():
         self.assertIsInstance(destination, Destination)
         self.assertEqual(destination.get_content(), {})
Exemplo n.º 21
0
 def test_parse_missing_title(self):
     parser = LegacyParser(StringIO(DESTINATIONS_MISSING_TITLE))
     count = 0
     for destination in parser.destinations():
         count += 1
     self.assertEqual(count, 0)
Exemplo n.º 22
0
 def test_parse_empty_xml(self):
     with self.assertRaises(XMLSyntaxError):
         parser = LegacyParser(StringIO(XML_EMPTY))
Exemplo n.º 23
0
 def test_parse_missing_title(self):
     parser = LegacyParser(StringIO(DESTINATIONS_MISSING_TITLE))
     count = 0
     for destination in parser.destinations():
         count += 1
     self.assertEqual(count, 0)
Exemplo n.º 24
0
 def test_parse_empty_content(self):
     parser = LegacyParser(StringIO(DESTINATIONS_EMPTY_CONTENT))
     for destination in parser.destinations():
         self.assertIsInstance(destination, Destination)
         self.assertEqual(destination.get_content(), {})