<commit_before># -*- coding: utf-8; -*-
from __future__ import unicode_literals, absolute_import

from tests import unittest, mock
from tests.factories.injector_factory import InjectorFactory

from freight_forwarder.container.config import Config
from freight_forwarder.container_ship import ContainerShip
from freight_forwarder.container_ship import Injector
from freight_forwarder.commercial_invoice.service import Service


class ContainerShipTest(unittest.TestCase):

    def setUp(self):
        self.patch_host_config = mock.patch('freight_forwarder.container.host_config')
        self.patch_logger = mock.patch('freight_forwarder.container_ship.logger')
        self.patch_urlparse = mock.patch('freight_forwarder.container_ship.urlparse')
        self.patch_utils = mock.patch('freight_forwarder.container_ship.utils')
        self.patch_urllib = mock.patch('freight_forwarder.container_ship.urllib3')
        self.patch_docker_client = mock.patch('freight_forwarder.container_ship.docker.Client')
        self.patch_container = mock.patch('freight_forwarder.container_ship.Container')
        self.patch_image = mock.patch('freight_forwarder.container_ship.Image')

        self.mock_host_config = self.patch_host_config.start()
        self.mock_logger = self.patch_logger.start()
        self.mock_urlparse = self.patch_urlparse.start()
        self.mock_utils = self.patch_utils.start()
        self.mock_urllib = self.patch_urllib.start()
        self.mock_docker_client = self.patch_docker_client.start()
        self.mock_container = self.patch_container.start()
        self.mock_image = self.patch_image.start()

        self.mock_service = mock.Mock(spec=Service)

        self.injector = InjectorFactory()

    def tearDown(self):
        self.patch_host_config.stop()
        self.patch_logger.stop()
        self.patch_urlparse.stop()
        self.patch_utils.stop()
        self.patch_urllib.stop()
        self.patch_docker_client.stop()
        self.patch_container.stop()
        self.patch_image.stop()

        del self.mock_service
        del self.injector

    @mock.patch('freight_forwarder.container_ship.docker.tls.TLSConfig')
    def test_create_container_ship(self, mock_docker_tlsconfig):
        self.mock_utils.validate_path.return_value = '/'
        self.mock_urlparse.return_value.scheme = 'https'
        kwargs = {'ssl_cert_path': '/', 'services': None, 'verify': False}
        container_ship = ContainerShip(address='https://127.0.0.1:2376', **kwargs)
        self.assertIsInstance(container_ship, ContainerShip)

    def test_injector(self):
        self.mock_urlparse.return_value.scheme = 'http'
        container_ship = ContainerShip(address='http://127.0.0.1:2376', **{})
        container_ship.injector = self.injector
        self.assertIsInstance(container_ship.injector, Injector)

    def test_injector_failure(self):
        self.mock_urlparse.return_value.scheme = 'http'
        with self.assertRaises(TypeError):
            container_ship = ContainerShip(address='http://127.0.0.1:2376', **{})
            container_ship.injector = False

    def test_report(self):
        pass

    def test_healthy(self):
        pass

    def test_inspect(self):
        pass

    def test_manifest(self):
        pass

    def test_recall_service(self, mock_service_map):
        pass

    def test_recall_service_failure(self):
        self.mock_urlparse.return_value.scheme = 'http'
        with self.assertRaises(TypeError):
            container_ship = ContainerShip(address='http://127.0.0.1:2376', **{})<commit_msg>Fixed typo<commit_after># -*- coding: utf-8; -*-
from __future__ import unicode_literals, absolute_import

from tests import unittest, mock
from tests.factories.injector_factory import InjectorFactory

from freight_forwarder.container.config import Config
from freight_forwarder.container_ship import ContainerShip
from freight_forwarder.container_ship import Injector
from freight_forwarder.commercial_invoice.service import Service


class ContainerShipTest(unittest.TestCase):

    def setUp(self):
        self.patch_host_config = mock.patch('freight_forwarder.container.host_config')
        self.patch_logger = mock.patch('freight_forwarder.container_ship.logger')
        self.patch_urlparse = mock.patch('freight_forwarder.container_ship.urlparse')
        self.patch_utils = mock.patch('freight_forwarder.container_ship.utils')
        self.patch_urllib = mock.patch('freight_forwarder.container_ship.urllib3')
        self.patch_docker_client = mock.patch('freight_forwarder.container_ship.docker.Client')
        self.patch_container = mock.patch('freight_forwarder.container_ship.Container')
        self.patch_image = mock.patch('freight_forwarder.container_ship.Image')

        self.mock_host_config = self.patch_host_config.start()
        self.mock_logger = self.patch_logger.start()
        self.mock_urlparse = self.patch_urlparse.start()
        self.mock_utils = self.patch_utils.start()
        self.mock_urllib = self.patch_urllib.start()
        self.mock_docker_client = self.patch_docker_client.start()
        self.mock_container = self.patch_container.start()
        self.mock_image = self.patch_image.start()

        self.mock_service = mock.Mock(spec=Service)

        self.injector = InjectorFactory()

    def tearDown(self):
        self.patch_host_config.stop()
        self.patch_logger.stop()
        self.patch_urlparse.stop()
        self.patch_utils.stop()
        self.patch_urllib.stop()
        self.patch_docker_client.stop()
        self.patch_container.stop()
        self.patch_image.stop()

        del self.mock_service
        del self.injector

    @mock.patch('freight_forwarder.container_ship.docker.tls.TLSConfig')
    def test_create_container_ship(self, mock_docker_tlsconfig):
        self.mock_utils.validate_path.return_value = '/'
        self.mock_urlparse.return_value.scheme = 'https'
        kwargs = {'ssl_cert_path': '/', 'services': None, 'verify': False}
        container_ship = ContainerShip(address='https://127.0.0.1:2376', **kwargs)
        self.assertIsInstance(container_ship, ContainerShip)

    def test_injector(self):
        self.mock_urlparse.return_value.scheme = 'http'
        container_ship = ContainerShip(address='http://127.0.0.1:2376', **{})
        container_ship.injector = self.injector
        self.assertIsInstance(container_ship.injector, Injector)

    def test_injector_failure(self):
        self.mock_urlparse.return_value.scheme = 'http'
        with self.assertRaises(TypeError):
            container_ship = ContainerShip(address='http://127.0.0.1:2376', **{})
            container_ship.injector = False

    def test_report(self):
        pass

    def test_healthy(self):
        pass

    def test_inspect(self):
        pass

    def test_manifest(self):
        pass

    def test_recall_service(self):
        pass

    def test_recall_service_failure(self):
        self.mock_urlparse.return_value.scheme = 'http'
        with self.assertRaises(TypeError):
            container_ship = ContainerShip(address='http://127.0.0.1:2376', **{})
{'fraction_non_alphanumeric': 0.10577328276443321, 'fraction_numerical': 0.011799410029498525, 'mean_word_length': 3.4583594239198496, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 8, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4103099', 'n_tokens_mistral': 2221, 'n_tokens_neox': 2140, 'n_words': 298}