Example #1
0
    def test_calculate_required_space(self, free_space_getter):
        """Test the calculate_required_space function."""
        download_size = Size(100)
        installation_size = Size(200)
        total_size = Size(300)

        dnf_manager = Mock()
        dnf_manager.get_download_size.return_value = download_size
        dnf_manager.get_installation_size.return_value = installation_size

        # No mount point to use.
        # The total size is required.
        free_space_getter.return_value = {}
        assert calculate_required_space(dnf_manager) == total_size

        # Found a mount point for download and install.
        # The total size is required.
        free_space_getter.return_value = {"/mnt/sysroot/home": total_size}
        assert calculate_required_space(dnf_manager) == total_size

        # Found a mount point for download.
        # The installation size is required.
        free_space_getter.return_value = {"/var/tmp": download_size}
        assert calculate_required_space(dnf_manager) == installation_size

        # The biggest mount point can be used for download and install.
        # The total size is required.
        free_space_getter.return_value = {
            "/var/tmp": download_size,
            "/mnt/sysroot": total_size
        }
        assert calculate_required_space(dnf_manager) == total_size
Example #2
0
 def space_required(self):
     return calculate_required_space(self._dnf_manager)