# Path: f8a_worker/workers/new_init_package_flow.py
# class NewInitPackageFlow(BaseTask):
#     """Initialize package-version-level analysis."""
# 
#     def execute(self, arguments):
#         """Task code.
# 
#         :param arguments: dictionary with task arguments
#         :return: {}, results
#         """
#         self._strict_assert(isinstance(arguments.get('ecosystem'), str))
#         self._strict_assert(isinstance(arguments.get('name'), str))
#         self._strict_assert(isinstance(arguments.get('version'), str))
# 
#         if arguments['ecosystem'] not in _SUPPORTED_ECOSYSTEMS:
#             raise FatalTaskError('Unknown ecosystem: %r' % arguments['ecosystem'])
# 
#         # Don't ingest for private packages
#         if not is_pkg_public(arguments['ecosystem'], arguments['name']):
#             logger.info("Private package ingestion ignored %s %s",
#                         arguments['ecosystem'], arguments['name'])
#             raise NotABugFatalTaskError("Private package alert {} {}".format(
#                 arguments['ecosystem'], arguments['name']))
# 
#         return arguments


from unittest import TestCase
from selinon import FatalTaskError
from f8a_worker.workers.new_init_package_flow import NewInitPackageFlow
from unittest import mock
        "version": "dummy_version"
}

data_v5 = {
        "ecosystem": "golang",
        "name": "dummy_name",
}


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

    def _strict_assert(self, assert_cond):
        if not assert_cond:
            raise FatalTaskError("Strict assert failed.")

    def test_execute(self):
        """Tests for 'execute'."""
        self.assertRaises(FatalTaskError, NewInitPackageFlow.execute, self, data_v1)

    @mock.patch('f8a_worker.workers.new_init_package_flow.is_pkg_public',
                return_value=True)
    def test_execute1(self, _mock):
        """Tests for 'execute'."""
        result = NewInitPackageFlow.execute(self, data_v2)
        expected = {'ecosystem': 'golang', 'name': 'dummy_name', 'version': 'dummy_version'}
        assert result == expected

    def test_execute2(self):
        """Tests for 'execute'."""

# Path: f8a_worker/workers/new_init_package_flow.py
# class NewInitPackageFlow(BaseTask):
#     """Initialize package-version-level analysis."""
# 
#     def execute(self, arguments):
#         """Task code.
# 
#         :param arguments: dictionary with task arguments
#         :return: {}, results
#         """
#         self._strict_assert(isinstance(arguments.get('ecosystem'), str))
#         self._strict_assert(isinstance(arguments.get('name'), str))
#         self._strict_assert(isinstance(arguments.get('version'), str))
# 
#         if arguments['ecosystem'] not in _SUPPORTED_ECOSYSTEMS:
#             raise FatalTaskError('Unknown ecosystem: %r' % arguments['ecosystem'])
# 
#         # Don't ingest for private packages
#         if not is_pkg_public(arguments['ecosystem'], arguments['name']):
#             logger.info("Private package ingestion ignored %s %s",
#                         arguments['ecosystem'], arguments['name'])
#             raise NotABugFatalTaskError("Private package alert {} {}".format(
#                 arguments['ecosystem'], arguments['name']))
# 
#         return arguments


# Path: tests/workers/test_new_init_package_flow.py
from unittest import TestCase
from selinon import FatalTaskError
from f8a_worker.workers.new_init_package_flow import NewInitPackageFlow
from unittest import mock

        "version": "dummy_version"
}

data_v5 = {
        "ecosystem": "golang",
        "name": "dummy_name",
}


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

    def _strict_assert(self, assert_cond):
        if not assert_cond:
            raise FatalTaskError("Strict assert failed.")

    def test_execute(self):
        """Tests for 'execute'."""
        self.assertRaises(FatalTaskError, NewInitPackageFlow.execute, self, data_v1)

    @mock.patch('f8a_worker.workers.new_init_package_flow.is_pkg_public',
                return_value=True)
    def test_execute1(self, _mock):
        """Tests for 'execute'."""
        result = NewInitPackageFlow.execute(self, data_v2)
        expected = {'ecosystem': 'golang', 'name': 'dummy_name', 'version': 'dummy_version'}
        assert result == expected

    def test_execute2(self):
        """Tests for 'execute'."""

        self.assertRaises(FatalTaskError, NewInitPackageFlow.execute, self, data_v3)