Beispiel #1
0
    def test_ScfFireTask(self):
        task = abinit_tasks.ScfFWTask(self.si_scf_input)
        task.to_dict()
        self.assertFwSerializable(task)

        task = abinit_tasks.ScfFWTask(self.si_scf_factory)
        task.to_dict()
        self.assertFwSerializable(task)
Beispiel #2
0
    def test_generic_error(self, report):
        scf_task = abinit_tasks.ScfFWTask(self.si_scf_input)

        report.return_value = mock_objects.report_AbinitError()

        fake_spec = {'test': 1}
        with self.assertRaises(abinit_tasks.AbinitRuntimeError):
            # set the returncode to avoid logging problems
            scf_task.returncode = 10
            scf_task.task_analysis(fake_spec)
Beispiel #3
0
    def test_no_report_no_err(self, report):
        scf_task = abinit_tasks.ScfFWTask(self.si_scf_input)
        scf_task.set_workdir(os.getcwd())

        report.return_value = None

        fake_spec = {'test': 1}
        with self.assertRaises(abinit_tasks.AbinitRuntimeError):
            # set the returncode to avoid logging problems
            scf_task.returncode = 10
            scf_task.task_analysis(fake_spec)
Beispiel #4
0
    def test_scf_unconverged(self, report):
        scf_task = abinit_tasks.ScfFWTask(self.si_scf_input)
        ftm_path = os.path.join(test_dir, "fw_manager_ok.yaml")
        scf_task.ftm = abiflows.fireworks.utils.fw_utils.FWTaskManager.from_file(ftm_path)

        report.return_value = mock_objects.report_ScfConvergenceWarning()

        with mock.patch.object(abinit_tasks.AbiFireTask, 'prepare_restart',
                               return_value=(False, mock_objects.fake_fw, {})) as pr:
            fake_spec = {'test': 1}
            action = scf_task.task_analysis(fake_spec)
            pr.assert_called_once_with(fake_spec)
            self.assertIsInstance(action, FWAction)

            scf_task.restart_info = abinit_tasks.RestartInfo(
                previous_dir='.', num_restarts=scf_task.ftm.fw_policy.max_restarts)
            with self.assertRaises(abinit_tasks.UnconvergedError):
                scf_task.task_analysis(fake_spec)
Beispiel #5
0
    def test_abinit_runtime_error(self, report):
        err = abinit_tasks.AbinitRuntimeError(msg="test error", num_errors=5)
        err.to_dict()
        new_err = abinit_tasks.AbinitRuntimeError.from_dict(err.as_dict())

        scf_task = abinit_tasks.ScfFWTask(self.si_scf_input)

        report.return_value = mock_objects.report_AbinitError()

        fake_spec = {'test': 1}

        try:
            # set the returncode to avoid logging problems
            scf_task.returncode = 10
            scf_task.task_analysis(fake_spec)
        except abinit_tasks.AbinitRuntimeError as e:
            e.to_dict()
            assert e.num_errors == 1