Ejemplo n.º 1
0
    def test_output(self):
        """Test to see if bundle file gets generated"""
        try:
            os.remove(BUNDLE_ZIP_FILE)
        except OSError:
            pass

        metadata = module_packer.set_defaults(MODULE_FILE_PATH)
        module_packer.archive(MODULE_FILE_PATH, metadata)
        self.assertTrue(os.path.isfile(BUNDLE_ZIP_FILE))
Ejemplo n.º 2
0
    def test_bad_bundle(self):
        """
        test malformed bundle is detected
        """
        path_to_bundle = os.path.join(os.getcwd(), BUNDLE_ZIP_FILE)

        module = discover_modules_commands(MODULE_FILE_PATH)
        metadata = module_metadata.create_default_metadata(module, MODULE_FILE_PATH)

        fields = ["Module_name", "Architecture", "Version", "SHA256"]
        for field in fields:
            tmp = metadata[field]
            metadata[field] = ""
            module_packer.archive(MODULE_FILE_PATH, metadata)
            self.assertIsNone(module_unpacker.unpack(path_to_bundle))
            metadata[field] = tmp
            os.remove(path_to_bundle)
Ejemplo n.º 3
0
    def test_valid_bundle(self):
        """
        test bundle extraction
        """
        module_path = os.path.join(os.getcwd(), MODULE_FILE)
        path_to_bundle = os.path.join(os.getcwd(), BUNDLE_ZIP_FILE)
        path_to_metadata = os.path.join(os.getcwd(), "module.json")
        module = discover_modules_commands(module_path)
        metadata = module_metadata.create_default_metadata(module, module_path)

        module_packer.archive(module_path, metadata)
        metadata, path_to_module = module_unpacker.unpack(path_to_bundle)
        self.assertIsNotNone(metadata)

        self.assertTrue(os.path.isfile(path_to_module))
        self.assertTrue(os.path.isfile(path_to_metadata))

        os.remove(path_to_bundle)
        os.remove(path_to_metadata)
        os.remove(module_path)