Ejemplo n.º 1
0
 def test_different_annotations_02(self):
     # Make sure that an XSD with different comments produces the same hash
     with open(
         join(RESOURCES_PATH, "chemical-element-annot-02.xsd"), "r", encoding="utf-8"
     ) as xsd_file:
         content = xsd_file.read()
         content_hash = xsd_hash.get_hash(content)
     self.assertEqual(self.hash, content_hash)
Ejemplo n.º 2
0
 def test_same(self):
     # Make sure that the same XSD produces the same hash
     with open(
         join(RESOURCES_PATH, "diffusion.xsd"), "r", encoding="utf-8"
     ) as xsd_file:
         content = xsd_file.read()
         content_hash = xsd_hash.get_hash(content)
     self.assertEqual(self.hash, content_hash)
Ejemplo n.º 3
0
 def test_same_file(self):
     # Make sure that the same XSD produces the same hash
     xsd_file = codecs.open(join(RESOURCES_PATH, 'chemical-element.xsd'),
                            'r',
                            encoding="utf-8")
     content = xsd_file.read()
     content_hash = xsd_hash.get_hash(content)
     self.assertEqual(self.hash, content_hash)
Ejemplo n.º 4
0
 def test_mixed_order(self):
     # Make sure that an XSD with elements in a different order produces the same hash
     xsd_file = codecs.open(join(RESOURCES_PATH, 'diffusion-mixed.xsd'),
                            'r',
                            encoding="utf-8")
     content = xsd_file.read()
     content_hash = xsd_hash.get_hash(content)
     self.assertEqual(self.hash, content_hash)
Ejemplo n.º 5
0
 def test_different_type(self):
     # Make sure that an XSD with different type names does not produce the same hash
     xsd_file = codecs.open(join(RESOURCES_PATH,
                                 'composition-type-name.xsd'),
                            'r',
                            encoding="utf-8")
     content = xsd_file.read()
     content_hash = xsd_hash.get_hash(content)
     self.assertNotEqual(self.hash, content_hash)
Ejemplo n.º 6
0
    def test_ammd_hash_value(self):
        ammd_hash = "b056869f2e87adbf6b56b0ec19e65f9761cc6826"

        with open(
            join(RESOURCES_PATH, "ammd-r2018a.xsd"), "r", encoding="utf-8"
        ) as xsd_file:
            content = xsd_file.read()
            content_hash = xsd_hash.get_hash(content)
        self.assertEqual(ammd_hash, content_hash)
Ejemplo n.º 7
0
    def test_registry_hash_value(self):
        res_md_hash = "4735069b4332ee196e95b4db7877b6dcea9692ec"

        with open(
            join(RESOURCES_PATH, "res-md.xsd"), "r", encoding="utf-8"
        ) as xsd_file:
            content = xsd_file.read()
            content_hash = xsd_hash.get_hash(content)
        self.assertEqual(res_md_hash, content_hash)
Ejemplo n.º 8
0
 def test_mixed_order(self):
     # Make sure that an XSD with elements in a different order produces
     # the same hash
     with open(
         join(RESOURCES_PATH, "diffusion-mixed.xsd"), "r", encoding="utf-8"
     ) as xsd_file:
         content = xsd_file.read()
         content_hash = xsd_hash.get_hash(content)
     self.assertEqual(self.hash, content_hash)
Ejemplo n.º 9
0
 def test_different_namespace(self):
     # Make sure that an XSD with different comments produces the same hash
     xsd_file = codecs.open(join(RESOURCES_PATH,
                                 'chemical-element-namespace.xsd'),
                            'r',
                            encoding="utf-8")
     content = xsd_file.read()
     content_hash = xsd_hash.get_hash(content)
     self.assertNotEqual(self.hash, content_hash)
Ejemplo n.º 10
0
 def test_different_root(self):
     # Make sure that an XSD with different root names does not produce
     # the same hash
     with open(
         join(RESOURCES_PATH, "composition-root-name.xsd"), "r", encoding="utf-8"
     ) as xsd_file:
         content = xsd_file.read()
         content_hash = xsd_hash.get_hash(content)
     self.assertNotEqual(self.hash, content_hash)
Ejemplo n.º 11
0
 def test_different_documentation(self):
     # Make sure that an XSD with documentation tags produces different hash
     xsd_file = codecs.open(join(RESOURCES_PATH,
                                 'chemical-element-documentation.xsd'),
                            'r',
                            encoding="utf-8")
     content = xsd_file.read()
     content_hash = xsd_hash.get_hash(content)
     self.assertEqual(self.hash, content_hash)
Ejemplo n.º 12
0
 def test_wrong_enum(self):
     # Make sure that an XSD with different enumeration does not produce the same hash
     xsd_file = codecs.open(join(RESOURCES_PATH,
                                 'chemical-element-enum.xsd'),
                            'r',
                            encoding="utf-8")
     content = xsd_file.read()
     content_hash = xsd_hash.get_hash(content)
     self.assertNotEqual(self.hash, content_hash)
Ejemplo n.º 13
0
 def test_different_spaces_02(self):
     # Make sure that an XSD with additional spaces, returns,tabs produces the same hash
     xsd_file = codecs.open(join(RESOURCES_PATH,
                                 'chemical-element-spaces-02.xsd'),
                            'r',
                            encoding="utf-8")
     content = xsd_file.read()
     content_hash = xsd_hash.get_hash(content)
     self.assertEqual(self.hash, content_hash)
Ejemplo n.º 14
0
    def test_ammd_hash_value(self):
        ammd_hash = "b056869f2e87adbf6b56b0ec19e65f9761cc6826"

        xsd_file = codecs.open(join(RESOURCES_PATH, 'ammd-r2018a.xsd'),
                               'r',
                               encoding="utf-8")
        # xsd_file = open(join(RESOURCES_PATH, 'ammd-r2018a.xsd'), 'r')
        content = xsd_file.read()
        content_hash = xsd_hash.get_hash(content)
        self.assertEqual(ammd_hash, content_hash)
Ejemplo n.º 15
0
    def test_registry_hash_value(self):
        res_md_hash = "4735069b4332ee196e95b4db7877b6dcea9692ec"

        xsd_file = codecs.open(join(RESOURCES_PATH, 'res-md.xsd'),
                               'r',
                               encoding="utf-8")
        # xsd_file = open(join(RESOURCES_PATH, 'res-md.xsd'), 'r')
        content = xsd_file.read()
        content_hash = xsd_hash.get_hash(content)
        self.assertEqual(res_md_hash, content_hash)
Ejemplo n.º 16
0
 def test_different_documentation(self):
     # Make sure that an XSD with documentation tags produces different hash
     with open(
         join(RESOURCES_PATH, "chemical-element-documentation.xsd"),
         "r",
         encoding="utf-8",
     ) as xsd_file:
         content = xsd_file.read()
         content_hash = xsd_hash.get_hash(content)
     self.assertEqual(self.hash, content_hash)
Ejemplo n.º 17
0
    def test_different_spaces_01(self):
        # Make sure that an XSD with additional spaces produces the same hash
        with open(
            join(RESOURCES_PATH, "chemical-element-spaces-01.xsd"),
            "r",
            encoding="utf-8",
        ) as xsd_file:
            content = xsd_file.read()
            content_hash = xsd_hash.get_hash(content)

        self.assertEqual(self.hash, content_hash)
Ejemplo n.º 18
0
def get_hash(xml_string):
    """Get the hash of an XML string.

    Args:
        xml_string:

    Returns:

    """
    try:
        return xsd_hash.get_hash(xml_string)
    except Exception:
        raise exceptions.XSDError("Something wrong happened during the hashing.")
Ejemplo n.º 19
0
 def test_comments(self):
     # makes sure that an XSD with documentation tags produces different hash
     xsd_file = open(join(RESOURCES_PATH, 'different-comments.xsd'), 'r')
     content = xsd_file.read()
     content_hash = xsd_hash.get_hash(content)
     self.assertEqual(self.hash, content_hash)
Ejemplo n.º 20
0
 def test_order(self):
     # makes sure that an XSD with elements in a different order produces the same hash
     xsd_file = open(join(RESOURCES_PATH, 'order.xsd'), 'r')
     content = xsd_file.read()
     content_hash = xsd_hash.get_hash(content)
     self.assertEqual(self.hash, content_hash)
Ejemplo n.º 21
0
 def test_type(self):
     # makes sure that an XSD with different type names does not produce the same hash
     xsd_file = open(join(RESOURCES_PATH, 'type-name.xsd'), 'r')
     content = xsd_file.read()
     content_hash = xsd_hash.get_hash(content)
     self.assertNotEqual(self.hash, content_hash)
Ejemplo n.º 22
0
 def test_same(self):
     # makes sure that the same XSD produces the same hash
     xsd_file = open(join(RESOURCES_PATH, 'composition.xsd'), 'r')
     content = xsd_file.read()
     content_hash = xsd_hash.get_hash(content)
     self.assertEqual(self.hash, content_hash)
Ejemplo n.º 23
0
 def setUp(self):
     xsd_file = open(join(RESOURCES_PATH, 'chemical-element.xsd'), 'r')
     self.content = xsd_file.read()
     self.hash = xsd_hash.get_hash(self.content)
Ejemplo n.º 24
0
 def test_wrong_enum(self):
     # makes sure that an XSD with different enumeration does not produce the same hash
     xsd_file = open(join(RESOURCES_PATH, 'wrong-enum.xsd'), 'r')
     content = xsd_file.read()
     content_hash = xsd_hash.get_hash(content)
     self.assertNotEqual(self.hash, content_hash)
Ejemplo n.º 25
0
 def setUp(self):
     xsd_file = open(join(RESOURCES_PATH, 'composition.xsd'), 'r')
     self.content = xsd_file.read()
     self.hash = xsd_hash.get_hash(self.content)
Ejemplo n.º 26
0
 def test_different_namespace(self):
     # makes sure that an XSD with different comments produces the same hash
     xsd_file = open(join(RESOURCES_PATH, 'namespace.xsd'), 'r')
     content = xsd_file.read()
     content_hash = xsd_hash.get_hash(content)
     self.assertNotEqual(self.hash, content_hash)
Ejemplo n.º 27
0
 def test_different_annotations_levels(self):
     # makes sure that an XSD with different comments produces the same hash
     xsd_file = open(join(RESOURCES_PATH, 'annotations-levels.xsd'), 'r')
     content = xsd_file.read()
     content_hash = xsd_hash.get_hash(content)
     self.assertEqual(self.hash, content_hash)
Ejemplo n.º 28
0
 def setUp(self):
     print "In method", self._testMethodName
     xsd_file = open(join(RESOURCES_PATH, 'demo.diffusion.xsd'), 'r')
     self.content = xsd_file.read()
     self.hash = xsd_hash.get_hash(self.content)
Ejemplo n.º 29
0
 def test_spaces2(self):
     # makes sure that an XSD with additional spaces, returns,tabs produces the same hash
     xsd_file = open(join(RESOURCES_PATH, 'spaces-return-tab.xsd'), 'r')
     content = xsd_file.read()
     content_hash = xsd_hash.get_hash(content)
     self.assertEqual(self.hash, content_hash)
Ejemplo n.º 30
0
 def setUp(self):
     print "In method", self._testMethodName
     xsd_file = open(join(RESOURCES_PATH, 'chemical-element.xsd'), 'r')
     self.content = xsd_file.read()
     self.hash = xsd_hash.get_hash(self.content)