Example #1
0
class URLSourceTestCase(unittest.TestCase):
    """Test the URL source module."""

    def setUp(self):
        self.module = URLSourceModule()

    def test_network_required(self):
        """Test the property network_required."""
        assert self.module.network_required is False

        self.module.repo_configuration.url = "http://my/path"
        assert self.module.network_required is True

        self.module.repo_configuration.url = "https://my/path"
        assert self.module.network_required is True

        self.module.repo_configuration.url = "file://my/path"
        assert self.module.network_required is False

        self.module.repo_configuration.url = "ftp://my/path"
        assert self.module.network_required is True

    def test_required_space(self):
        """Test the required_space property."""
        assert self.module.required_space == 0

    def test_ready_state(self):
        """Check ready state of URL source.

        It will be always True there is no state.
        """
        assert self.module.get_state()

    def test_set_up_with_tasks(self):
        """Get set up tasks for url source.

        No task is required. Will be an empty list.
        """
        assert self.module.set_up_with_tasks() == []

    def test_tear_down_with_tasks(self):
        """Get tear down tasks for url source.

        No task is required. Will be an empty list.
        """
        assert self.module.tear_down_with_tasks() == []

    def test_repr(self):
        config = RepoConfigurationData()
        config.url = "http://some.example.com/repository"
        self.module.set_repo_configuration(config)
        assert repr(self.module) == \
            "Source(type='URL', url='http://some.example.com/repository')"
Example #2
0
class URLSourceTestCase(unittest.TestCase):
    """Test the URL source module."""
    def setUp(self):
        self.module = URLSourceModule()

    def network_required_test(self):
        """Test the property network_required."""
        self.assertEqual(self.module.network_required, False)

        self.module.repo_configuration.url = "http://my/path"
        self.assertEqual(self.module.network_required, True)

        self.module.repo_configuration.url = "https://my/path"
        self.assertEqual(self.module.network_required, True)

        self.module.repo_configuration.url = "file://my/path"
        self.assertEqual(self.module.network_required, False)

        self.module.repo_configuration.url = "ftp://my/path"
        self.assertEqual(self.module.network_required, True)

    def ready_state_test(self):
        """Check ready state of URL source.

        It will be always True there is no state.
        """
        self.assertTrue(self.module.get_state())

    def set_up_with_tasks_test(self):
        """Get set up tasks for url source.

        No task is required. Will be an empty list.
        """
        self.assertEqual(self.module.set_up_with_tasks(), [])

    def tear_down_with_tasks_test(self):
        """Get tear down tasks for url source.

        No task is required. Will be an empty list.
        """
        self.assertEqual(self.module.tear_down_with_tasks(), [])

    def repr_test(self):
        config = RepoConfigurationData()
        config.url = "http://some.example.com/repository"
        self.module.set_repo_configuration(config)
        self.assertEqual(
            repr(self.module),
            "Source(type='URL', url='http://some.example.com/repository')")