Esempio n. 1
0
 def test_parse(self):
     taxonomies = LegacyTaxonomies()
     taxonomies.parse_xml(StringIO(TAXONOMY_VALID))
     self.assertEqual(len(taxonomies._sets), 1)
     self.assertEqual(taxonomies._sets.keys()[0], 'World')
     self.assertDictEqual(taxonomies, {
         'africa': {'atlas_node_id': 111222,
                    'children': ['south_africa'],
                    'ethyl_content_object_id': 1,
                    'geo_id': 1,
                    'name': 'Africa',
                    'parents': []},
         'south_africa': {'atlas_node_id': 111333,
                          'children': [],
                          'ethyl_content_object_id': 3,
                          'geo_id': 4,
                          'name': 'South Africa',
                          'parents': ['africa']},
         })
Esempio n. 2
0
 def test_parse(self):
     taxonomies = LegacyTaxonomies()
     taxonomies.parse_xml(StringIO(TAXONOMY_VALID))
     self.assertEqual(len(taxonomies._sets), 1)
     self.assertEqual(taxonomies._sets.keys()[0], 'World')
     self.assertDictEqual(
         taxonomies, {
             'africa': {
                 'atlas_node_id': 111222,
                 'children': ['south_africa'],
                 'ethyl_content_object_id': 1,
                 'geo_id': 1,
                 'name': 'Africa',
                 'parents': []
             },
             'south_africa': {
                 'atlas_node_id': 111333,
                 'children': [],
                 'ethyl_content_object_id': 3,
                 'geo_id': 4,
                 'name': 'South Africa',
                 'parents': ['africa']
             },
         })
Esempio n. 3
0
 def test_parse_missing_attribs(self):
     taxonomies = LegacyTaxonomies()
     taxonomies.parse_xml(StringIO(TAXONOMY_NO_ATTRIBS))
     self.assertEqual(len(taxonomies._sets), 1)
     self.assertEqual(len(taxonomies), 2)
Esempio n. 4
0
 def test_parse_missing_node_name(self):
     taxonomies = LegacyTaxonomies()
     taxonomies.parse_xml(StringIO(TAXONOMY_NO_NAME))
     self.assertEqual(len(taxonomies._sets), 1)
     self.assertEqual(len(taxonomies), 1)
Esempio n. 5
0
 def test_parse_empty_set(self):
     taxonomies = LegacyTaxonomies()
     taxonomies.parse_xml(StringIO(TAXONOMY_EMPTY_SET))
     self.assertEqual(len(taxonomies._sets), 1)
     self.assertIsNone(taxonomies._sets.keys()[0])
     self.assertEqual(len(taxonomies), 0)
Esempio n. 6
0
 def test_parse_empty(self):
     taxonomies = LegacyTaxonomies()
     taxonomies.parse_xml(StringIO(TAXONOMY_EMPTY))
     self.assertEqual(len(taxonomies._sets), 0)
     self.assertEqual(len(taxonomies), 0)
Esempio n. 7
0
 def test_parse_empty_xml(self):
     taxonomies = LegacyTaxonomies()
     with self.assertRaises(XMLSyntaxError):
         taxonomies.parse_xml(StringIO(XML_EMPTY))
     self.assertEqual(len(taxonomies), 0)
Esempio n. 8
0
 def test_parse_invalid(self):
     taxonomies = LegacyTaxonomies()
     with self.assertRaises(XMLSyntaxError):
         taxonomies.parse_xml(StringIO('error>'))
     self.assertEqual(len(taxonomies), 0)
Esempio n. 9
0
 def test_parse_missing_attribs(self):
     taxonomies = LegacyTaxonomies()
     taxonomies.parse_xml(StringIO(TAXONOMY_NO_ATTRIBS))
     self.assertEqual(len(taxonomies._sets), 1)
     self.assertEqual(len(taxonomies), 2)
Esempio n. 10
0
 def test_parse_missing_node_name(self):
     taxonomies = LegacyTaxonomies()
     taxonomies.parse_xml(StringIO(TAXONOMY_NO_NAME))
     self.assertEqual(len(taxonomies._sets), 1)
     self.assertEqual(len(taxonomies), 1)
Esempio n. 11
0
 def test_parse_empty_set(self):
     taxonomies = LegacyTaxonomies()
     taxonomies.parse_xml(StringIO(TAXONOMY_EMPTY_SET))
     self.assertEqual(len(taxonomies._sets), 1)
     self.assertIsNone(taxonomies._sets.keys()[0])
     self.assertEqual(len(taxonomies), 0)
Esempio n. 12
0
 def test_parse_empty(self):
     taxonomies = LegacyTaxonomies()
     taxonomies.parse_xml(StringIO(TAXONOMY_EMPTY))
     self.assertEqual(len(taxonomies._sets), 0)
     self.assertEqual(len(taxonomies), 0)
Esempio n. 13
0
 def test_parse_empty_xml(self):
     taxonomies = LegacyTaxonomies()
     with self.assertRaises(XMLSyntaxError):
         taxonomies.parse_xml(StringIO(XML_EMPTY))
     self.assertEqual(len(taxonomies), 0)
Esempio n. 14
0
 def test_parse_invalid(self):
     taxonomies = LegacyTaxonomies()
     with self.assertRaises(XMLSyntaxError):
         taxonomies.parse_xml(StringIO('error>'))
     self.assertEqual(len(taxonomies), 0)