Reformat common to standardized format
[osm/common.git] / osm_common / tests / test_sol004_package.py
index b9f13af..dc71d91 100644 (file)
@@ -28,82 +28,124 @@ import unittest
 
 class SOL004ValidatorTest(unittest.TestCase):
     def test_get_package_file_hash_algorithm_from_manifest_with_metadata_dir(self):
-        package = SOL004Package('osm_common/tests/packages/native_charm_with_metadata_dir_vnf')
-        algorithm = package.get_package_file_hash_algorithm_from_manifest('Scripts/charms/simple/src/charm.py')
-        self.assertEqual(algorithm, 'SHA-256')
+        package = SOL004Package(
+            "osm_common/tests/packages/native_charm_with_metadata_dir_vnf"
+        )
+        algorithm = package.get_package_file_hash_algorithm_from_manifest(
+            "Scripts/charms/simple/src/charm.py"
+        )
+        self.assertEqual(algorithm, "SHA-256")
 
     def test_get_package_file_hash_algorithm_from_manifest_without_metadata_dir(self):
-        package = SOL004Package('osm_common/tests/packages/native_charm_without_metadata_dir_vnf')
-        algorithm = package.get_package_file_hash_algorithm_from_manifest('Scripts/charms/simple/src/charm.py')
-        self.assertEqual(algorithm, 'SHA-256')
+        package = SOL004Package(
+            "osm_common/tests/packages/native_charm_without_metadata_dir_vnf"
+        )
+        algorithm = package.get_package_file_hash_algorithm_from_manifest(
+            "Scripts/charms/simple/src/charm.py"
+        )
+        self.assertEqual(algorithm, "SHA-256")
 
     def test_get_package_file_hash_algorithm_from_manifest_on_non_existent_file(self):
-        package = SOL004Package('osm_common/tests/packages/native_charm_with_metadata_dir_vnf')
+        package = SOL004Package(
+            "osm_common/tests/packages/native_charm_with_metadata_dir_vnf"
+        )
         with self.assertRaises(SOL004PackageException):
-            package.get_package_file_hash_algorithm_from_manifest('Non/Existing/file')
+            package.get_package_file_hash_algorithm_from_manifest("Non/Existing/file")
 
     def test_get_package_file_hash_digest_from_manifest_with_metadata_dir(self):
-        package = SOL004Package('osm_common/tests/packages/native_charm_with_metadata_dir_vnf')
-        digest = package.get_package_file_hash_digest_from_manifest('Scripts/charms/simple/src/charm.py')
-        self.assertEqual(digest, '7895f7b9e1b7ed5b5bcd64398950ca95b456d7fc973334351474eed466c2f480')
+        package = SOL004Package(
+            "osm_common/tests/packages/native_charm_with_metadata_dir_vnf"
+        )
+        digest = package.get_package_file_hash_digest_from_manifest(
+            "Scripts/charms/simple/src/charm.py"
+        )
+        self.assertEqual(
+            digest, "ea72f897a966e6174ed9164fabc3c500df5a2f712eb6b22ab2408afb07d04d14"
+        )
 
     def test_get_package_file_hash_digest_from_manifest_without_metadata_dir(self):
-        package = SOL004Package('osm_common/tests/packages/native_charm_without_metadata_dir_vnf')
-        digest = package.get_package_file_hash_digest_from_manifest('Scripts/charms/simple/src/charm.py')
-        self.assertEqual(digest, '7895f7b9e1b7ed5b5bcd64398950ca95b456d7fc973334351474eed466c2f480')
+        package = SOL004Package(
+            "osm_common/tests/packages/native_charm_without_metadata_dir_vnf"
+        )
+        digest = package.get_package_file_hash_digest_from_manifest(
+            "Scripts/charms/simple/src/charm.py"
+        )
+        self.assertEqual(
+            digest, "ea72f897a966e6174ed9164fabc3c500df5a2f712eb6b22ab2408afb07d04d14"
+        )
 
     def test_get_package_file_hash_digest_from_manifest_on_non_existent_file(self):
-        package = SOL004Package('osm_common/tests/packages/native_charm_with_metadata_dir_vnf')
+        package = SOL004Package(
+            "osm_common/tests/packages/native_charm_with_metadata_dir_vnf"
+        )
         with self.assertRaises(SOL004PackageException):
-            package.get_package_file_hash_digest_from_manifest('Non/Existing/file')
+            package.get_package_file_hash_digest_from_manifest("Non/Existing/file")
 
-    def test_get_package_file_hash_digest_from_manifest_on_non_existing_hash_entry(self):
-        package = SOL004Package('osm_common/tests/packages/invalid_package_vnf')
+    def test_get_package_file_hash_digest_from_manifest_on_non_existing_hash_entry(
+        self,
+    ):
+        package = SOL004Package("osm_common/tests/packages/invalid_package_vnf")
         with self.assertRaises(SOL004PackageException):
-            package.get_package_file_hash_digest_from_manifest('Scripts/charms/simple/hooks/upgrade-charm')
+            package.get_package_file_hash_digest_from_manifest(
+                "Scripts/charms/simple/hooks/upgrade-charm"
+            )
 
     def test_validate_package_file_hash_with_metadata_dir(self):
-        package = SOL004Package('osm_common/tests/packages/native_charm_with_metadata_dir_vnf')
-        package.validate_package_file_hash('Scripts/charms/simple/src/charm.py')
+        package = SOL004Package(
+            "osm_common/tests/packages/native_charm_with_metadata_dir_vnf"
+        )
+        package.validate_package_file_hash("Scripts/charms/simple/src/charm.py")
 
     def test_validate_package_file_hash_without_metadata_dir(self):
-        package = SOL004Package('osm_common/tests/packages/native_charm_without_metadata_dir_vnf')
-        package.validate_package_file_hash('Scripts/charms/simple/src/charm.py')
+        package = SOL004Package(
+            "osm_common/tests/packages/native_charm_without_metadata_dir_vnf"
+        )
+        package.validate_package_file_hash("Scripts/charms/simple/src/charm.py")
 
     def test_validate_package_file_hash_on_non_existing_file(self):
-        package = SOL004Package('osm_common/tests/packages/native_charm_with_metadata_dir_vnf')
+        package = SOL004Package(
+            "osm_common/tests/packages/native_charm_with_metadata_dir_vnf"
+        )
         with self.assertRaises(SOL004PackageException):
-            package.validate_package_file_hash('Non/Existing/file')
+            package.validate_package_file_hash("Non/Existing/file")
 
     def test_validate_package_file_hash_on_wrong_manifest_hash(self):
-        package = SOL004Package('osm_common/tests/packages/invalid_package_vnf')
+        package = SOL004Package("osm_common/tests/packages/invalid_package_vnf")
         with self.assertRaises(SOL004PackageException):
-            package.validate_package_file_hash('Scripts/charms/simple/hooks/start')
+            package.validate_package_file_hash("Scripts/charms/simple/hooks/start")
 
     def test_validate_package_file_hash_on_unsupported_hash_algorithm(self):
-        package = SOL004Package('osm_common/tests/packages/invalid_package_vnf')
+        package = SOL004Package("osm_common/tests/packages/invalid_package_vnf")
         with self.assertRaises(SOL004PackageException):
-            package.validate_package_file_hash('Scripts/charms/simple/src/charm.py')
+            package.validate_package_file_hash("Scripts/charms/simple/src/charm.py")
 
     def test_validate_package_hashes_with_metadata_dir(self):
-        package = SOL004Package('osm_common/tests/packages/native_charm_with_metadata_dir_vnf')
+        package = SOL004Package(
+            "osm_common/tests/packages/native_charm_with_metadata_dir_vnf"
+        )
         package.validate_package_hashes()
 
     def test_validate_package_hashes_without_metadata_dir(self):
-        package = SOL004Package('osm_common/tests/packages/native_charm_without_metadata_dir_vnf')
+        package = SOL004Package(
+            "osm_common/tests/packages/native_charm_without_metadata_dir_vnf"
+        )
         package.validate_package_hashes()
 
     def test_validate_package_hashes_on_invalid_package(self):
-        package = SOL004Package('osm_common/tests/packages/invalid_package_vnf')
+        package = SOL004Package("osm_common/tests/packages/invalid_package_vnf")
         with self.assertRaises(SOL004PackageException):
             package.validate_package_hashes()
 
     def test_get_descriptor_location_with_metadata_dir(self):
-        package = SOL004Package('osm_common/tests/packages/native_charm_with_metadata_dir_vnf')
+        package = SOL004Package(
+            "osm_common/tests/packages/native_charm_with_metadata_dir_vnf"
+        )
         descriptor_path = package.get_descriptor_location()
-        self.assertEqual(descriptor_path, 'Definitions/native_charm_vnfd.yaml')
+        self.assertEqual(descriptor_path, "Definitions/native_charm_vnfd.yaml")
 
     def test_get_descriptor_location_without_metadata_dir(self):
-        package = SOL004Package('osm_common/tests/packages/native_charm_without_metadata_dir_vnf')
+        package = SOL004Package(
+            "osm_common/tests/packages/native_charm_without_metadata_dir_vnf"
+        )
         descriptor_path = package.get_descriptor_location()
-        self.assertEqual(descriptor_path, 'native_charm_vnfd.yaml')
+        self.assertEqual(descriptor_path, "native_charm_vnfd.yaml")