Exemplo n.º 1
0
    def test_get_available_solutions(self):
        problem_spec = core.get_entity("4ZZ9J")
        problem_sol1 = core.get_entity("UKJZI")

        res = problem_spec.available_solutions_list()

        self.assertEqual(res, [problem_sol1])
Exemplo n.º 2
0
    def test_resolve_keys(self):
        entity = core.get_entity("UKJZI")

        # ensure that the object container does not yet exist
        self.assertFalse(hasattr(entity, "oc"))

        core.resolve_keys(entity)

        self.assertTrue(hasattr(entity, "oc"))

        self.assertTrue(isinstance(entity.oc.solved_problem_list, list))
        self.assertEquals(len(entity.oc.solved_problem_list), 1)
        self.assertEquals(entity.oc.solved_problem_list[0].key, "4ZZ9J")
        self.assertTrue(isinstance(entity.oc.method_package_list, list))
        self.assertEquals(entity.oc.method_package_list[0].key, "UENQQ")
        self.assertTrue(entity.oc.predecessor_key is None)

        default_env = core.get_entity("YJBOX")
        # TODO: this should be activated when ackrep_data is fixed
        if 0:
            self.assertTrue(
                isinstance(entity.oc.compatible_environment,
                           core.models.EnvironmentSpecification))
            self.assertTrue(entity.oc.compatible_environment, default_env)
Exemplo n.º 3
0
    def get(self, request, key):

        try:
            entity = core.get_entity(key)
        except ValueError as ve:
            raise Http404(ve)

        c = core.Container()

        c.entity = entity
        c.view_type = "detail"
        c.view_type_title = "Details for:"

        context = {"c": c}

        # create an object container (entity.oc) where for each string-keys the real object is available
        core.resolve_keys(entity)

        return TemplateResponse(request, "ackrep_web/entity_detail.html",
                                context)
Exemplo n.º 4
0
    def test_get_solution_data_files(self):
        res = core.check_solution("UKJZI")
        self.assertEqual(res.returncode, 0, msg=utf8decode(res.stderr))
        sol_entity = core.get_entity("UKJZI")

        all_files = core.get_solution_data_files(sol_entity.base_path)
        png_files = core.get_solution_data_files(sol_entity.base_path,
                                                 endswith_str=".png")
        txt_files = core.get_solution_data_files(sol_entity.base_path,
                                                 endswith_str=".txt")

        self.assertEqual(len(all_files), 1)
        self.assertEqual(len(png_files), 1)
        self.assertEqual(len(txt_files), 0)

        plot_file_path = png_files[0]
        self.assertTrue(plot_file_path.endswith("plot.png"))

        self.assertTrue(
            os.path.isfile(os.path.join(core.root_path, plot_file_path)))
Exemplo n.º 5
0
    def get(self, request, key):

        try:
            sol_entity = core.get_entity(key)
        except ValueError as ve:
            raise Http404(ve)

        # TODO: spawn a new container and shown some status updates while the user is waiting

        core.resolve_keys(sol_entity)

        c = core.Container()
        ts1 = timezone.now()
        cs_result = core.check_solution(key)
        c.diff_time_str = util.smooth_timedelta(ts1)

        c.entity = sol_entity
        c.view_type = "check-solution"
        c.view_type_title = "Check Solution for:"
        c.cs_result = cs_result

        c.image_list = core.get_solution_data_files(sol_entity.base_path,
                                                    endswith_str=".png",
                                                    create_media_links=True)

        if cs_result.returncode == 0:
            c.cs_result_css_class = "cs_success"
            c.cs_verbal_result = "Success"
            # c.debug = cs_result
        else:
            c.cs_result_css_class = "cs_fail"
            c.cs_verbal_result = "Fail"
            c.debug = cs_result

        context = {"c": c}

        # create an object container (entity.oc) where for each string-key the real object is available

        return TemplateResponse(request, "ackrep_web/entity_detail.html",
                                context)