Beispiel #1
0
 def test_success(self):
     """CompatibilityResult available for all packages and pairs."""
     packages = [PACKAGE_1, PACKAGE_2]
     store = fake_compatibility_store.CompatibilityStore()
     store.save_compatibility_statuses([
         compatibility_store.CompatibilityResult(
             packages=[PACKAGE_1],
             python_major_version=3,
             status=compatibility_store.Status.SUCCESS),
         compatibility_store.CompatibilityResult(
             packages=[PACKAGE_2],
             python_major_version=3,
             status=compatibility_store.Status.SUCCESS),
         compatibility_store.CompatibilityResult(
             packages=[PACKAGE_1, PACKAGE_2],
             python_major_version=3,
             status=compatibility_store.Status.SUCCESS),
     ])
     with self.patch_finder, self.patch_highlighter:
         package_to_results = store.get_self_compatibilities(packages)
         pairwise_to_results = store.get_compatibility_combinations(
             packages)
         results = dashboard_builder._ResultHolder(package_to_results,
                                                   pairwise_to_results)
         builder = dashboard_builder.DashboardBuilder(packages, results)
         builder.build_dashboard('dashboard/grid-template.html')
Beispiel #2
0
    def test_pairwise_failure(self):
        """CompatibilityResult failure between pair of packages."""
        packages = [PACKAGE_1, PACKAGE_2]
        store = fake_compatibility_store.CompatibilityStore()
        store.save_compatibility_statuses([
            compatibility_store.CompatibilityResult(
                packages=[PACKAGE_1],
                python_major_version=3,
                status=compatibility_store.Status.SUCCESS),
            compatibility_store.CompatibilityResult(
                packages=[PACKAGE_2],
                python_major_version=3,
                status=compatibility_store.Status.SUCCESS),
            compatibility_store.CompatibilityResult(
                packages=[PACKAGE_1, PACKAGE_2],
                python_major_version=3,
                status=compatibility_store.Status.INSTALL_ERROR,
                details="Installation failure"),
        ])

        with self.patch_finder, self.patch_highlighter:
            package_to_results = store.get_self_compatibilities(packages)
            pairwise_to_results = store.get_compatibility_combinations(
                packages)
            results = dashboard_builder._ResultHolder(package_to_results,
                                                      pairwise_to_results)
            builder = dashboard_builder.DashboardBuilder(packages, results)
            html_grid = builder.build_dashboard('dashboard/grid-template.html')
            self.assertIn("Installation failure", html_grid)
Beispiel #3
0
    def test_escape(self):
        """Test that the arguments to showDialog() are escaped."""
        packages = [PACKAGE_1, PACKAGE_2]
        store = fake_compatibility_store.CompatibilityStore()
        store.save_compatibility_statuses([
            compatibility_store.CompatibilityResult(
                packages=[PACKAGE_1],
                python_major_version=3,
                status=compatibility_store.Status.INSTALL_ERROR,
                details=r"This \ has a ' in it < >"),
            compatibility_store.CompatibilityResult(
                packages=[PACKAGE_2],
                python_major_version=3,
                status=compatibility_store.Status.SUCCESS),
        ])

        with self.patch_finder, self.patch_highlighter:
            package_to_results = store.get_self_compatibilities(packages)
            pairwise_to_results = store.get_compatibility_combinations(
                packages)
            results = dashboard_builder._ResultHolder(package_to_results,
                                                      pairwise_to_results)
            builder = dashboard_builder.DashboardBuilder(packages, results)
            html_grid = builder.build_dashboard('dashboard/grid-template.html')
            with open('/tmp/foo.html', 'w+') as f:
                f.write(html_grid)

            self.assertIn("This \\\\ has a \\&#39; in it &lt; &gt;", html_grid)
Beispiel #4
0
    def test_not_show_py_ver_incompatible_results(self):
        """CompatibilityResult failure between pair of packages. Do not display
        the packages that are incompatible with a specific Python version.
        """
        packages = [PACKAGE_1, PACKAGE_2]
        store = fake_compatibility_store.CompatibilityStore()
        store.save_compatibility_statuses([
            compatibility_store.CompatibilityResult(
                packages=[PACKAGE_1],
                python_major_version=3,
                status=compatibility_store.Status.SUCCESS),
            compatibility_store.CompatibilityResult(
                packages=[PACKAGE_3],
                python_major_version=3,
                status=compatibility_store.Status.INSTALL_ERROR),
            compatibility_store.CompatibilityResult(
                packages=[PACKAGE_1, PACKAGE_3],
                python_major_version=3,
                status=compatibility_store.Status.INSTALL_ERROR,
                details="Installation failure"),
        ])
        patch = mock.patch(
            'compatibility_lib.configs.PKG_PY_VERSION_NOT_SUPPORTED', {
                2: ['package4'],
                3: ['package3'],
            })

        with patch, self.patch_finder, self.patch_highlighter:
            package_to_results = store.get_self_compatibilities(packages)
            pairwise_to_results = store.get_compatibility_combinations(
                packages)
            results = dashboard_builder._ResultHolder(package_to_results,
                                                      pairwise_to_results)

            builder = dashboard_builder.DashboardBuilder(packages, results)
            html_grid = builder.build_dashboard('dashboard/grid-template.html')

        self.assertNotIn("Installation failure", html_grid)