# Path: f8a_worker/workers/new_metadata.py
# class NewMetaDataTask(BaseTask):
#     """Initialize package-version-level analysis for metadata."""
# 
#     def execute(self, arguments):
#         """Task code.
# 
#         :param arguments: dictionary with task arguments
#         :return: {}, results
#         """
#         result_data = {'status': 'success',
#                        'details': []}
# 
#         metadata_dict = {
#             'description': '',
#             'name': arguments.get('name'),
#             'version': arguments.get('version'),
#             'ecosystem': arguments.get('ecosystem')
#         }
# 
#         result_data['details'].append(metadata_dict)
# 
#         # Store base file required by Data importer
#         store_data_to_s3(arguments,
#                          StoragePool.get_connected_storage('S3InItData'),
#                          result_data)
# 
#         # Get the license for package
#         golang_util = GolangUtils(arguments.get('name'))
#         license = golang_util.get_license()
# 
#         if license is not None:
#             metadata_dict['declared_licenses'] = license
#         else:
#             metadata_dict['declared_licenses'] = []
# 
#         # Store metadata file for being used in Data-Importer
#         store_data_to_s3(arguments,
#                          StoragePool.get_connected_storage('S3MetaData'),
#                          result_data)
# 
#         return arguments


from unittest import TestCase, mock
from f8a_worker.workers.new_metadata import NewMetaDataTask

class TestNewMetaDataTask(TestCase):
    """Tests for the NewInitPackageFlow task."""

    def store_data_to_s3(self, arguments, s3, result):
        """Test Function."""
        if not arguments:
            raise
        if not s3:
            raise
        if not result:
            raise
        pass

    @mock.patch('f8a_worker.workers.new_metadata.StoragePool.get_connected_storage',
                return_value='')
    @mock.patch('f8a_worker.workers.new_metadata.GolangUtils',
                return_value=GolangUtils(data_v1['name']))
    def test_execute(self, _mock1, _mock2):
        """Tests for 'execute'."""
        result = NewMetaDataTask.execute(self, data_v1)
        expected = {'ecosystem': 'dummy_eco', 'name': 'dummy_name', 'version': 'dummy_version'}
        assert result == expected

    @mock.patch('f8a_worker.workers.new_metadata.StoragePool.get_connected_storage',
                return_value='')
    @mock.patch('f8a_worker.workers.new_metadata.GolangUtils',
                return_value=GolangUtils(data_v2['name']))
    def test_execute1(self, _mock1, _mock2):
        """Tests for 'execute'."""

# Path: f8a_worker/workers/new_metadata.py
# class NewMetaDataTask(BaseTask):
#     """Initialize package-version-level analysis for metadata."""
# 
#     def execute(self, arguments):
#         """Task code.
# 
#         :param arguments: dictionary with task arguments
#         :return: {}, results
#         """
#         result_data = {'status': 'success',
#                        'details': []}
# 
#         metadata_dict = {
#             'description': '',
#             'name': arguments.get('name'),
#             'version': arguments.get('version'),
#             'ecosystem': arguments.get('ecosystem')
#         }
# 
#         result_data['details'].append(metadata_dict)
# 
#         # Store base file required by Data importer
#         store_data_to_s3(arguments,
#                          StoragePool.get_connected_storage('S3InItData'),
#                          result_data)
# 
#         # Get the license for package
#         golang_util = GolangUtils(arguments.get('name'))
#         license = golang_util.get_license()
# 
#         if license is not None:
#             metadata_dict['declared_licenses'] = license
#         else:
#             metadata_dict['declared_licenses'] = []
# 
#         # Store metadata file for being used in Data-Importer
#         store_data_to_s3(arguments,
#                          StoragePool.get_connected_storage('S3MetaData'),
#                          result_data)
# 
#         return arguments


# Path: tests/workers/test_new_metadata.py
from unittest import TestCase, mock
from f8a_worker.workers.new_metadata import NewMetaDataTask


class TestNewMetaDataTask(TestCase):
    """Tests for the NewInitPackageFlow task."""

    def store_data_to_s3(self, arguments, s3, result):
        """Test Function."""
        if not arguments:
            raise
        if not s3:
            raise
        if not result:
            raise
        pass

    @mock.patch('f8a_worker.workers.new_metadata.StoragePool.get_connected_storage',
                return_value='')
    @mock.patch('f8a_worker.workers.new_metadata.GolangUtils',
                return_value=GolangUtils(data_v1['name']))
    def test_execute(self, _mock1, _mock2):
        """Tests for 'execute'."""
        result = NewMetaDataTask.execute(self, data_v1)
        expected = {'ecosystem': 'dummy_eco', 'name': 'dummy_name', 'version': 'dummy_version'}
        assert result == expected

    @mock.patch('f8a_worker.workers.new_metadata.StoragePool.get_connected_storage',
                return_value='')
    @mock.patch('f8a_worker.workers.new_metadata.GolangUtils',
                return_value=GolangUtils(data_v2['name']))
    def test_execute1(self, _mock1, _mock2):
        """Tests for 'execute'."""

        result = NewMetaDataTask.execute(self, data_v2)