Exemplo n.º 1
0
def test_c2pk_md_mock(mocker: MockFixture) -> None:
    """Mock a call to CP2K."""
    s = SETTINGS.copy()
    s.specific.cp2k += md.specific.cp2k_mm

    job = cp2k_mm(s, MOL)
    run_mocked = mock_runner(mocker, settings=s, jobname="cp2k_mm_md")

    result = run_mocked(job)
    assertion.eq(result.status, 'successful')

    assertion.isfile(result.results['cp2k-1_1000.restart'])
Exemplo n.º 2
0
def test_md() -> None:
    """Test CP2K molecular dynamics calculations with the :class:`CP2K_MM` class."""
    mol = Molecule(
        PATH_MOLECULES /
        'Cd68Cl26Se55__26_acetate.freq.xyz')  # Optimized coordinates
    s = SETTINGS.copy()
    s.specific.cp2k += md.specific.cp2k_mm
    s.specific.cp2k.motion.md.steps = 1000

    job = cp2k_mm(settings=s, mol=mol, job_name='cp2k_mm_md')
    result = run(job, path=PATH)
    assertion.eq(result.status, 'successful')

    plams_results = result.results
    assertion.isfile(plams_results['cp2k-1_1000.restart'])
Exemplo n.º 3
0
    def test_passes(self, kwargs: Mapping[str, Any]) -> None:
        """Test that whether the code passes as expected."""
        # Can't use the pytest `tmp_path` paramater as the (absolute) filename
        # becomes too long for COSMO-RS
        tmp_path = PATH / "crs"
        try:
            os.mkdir(tmp_path)

            out = run_fast_sigma(SMILES,
                                 SOLVENTS,
                                 output_dir=tmp_path,
                                 **kwargs)
            if out is not None:
                compare_df(out, REF)

            csv_file = tmp_path / "cosmo-rs.csv"
            assertion.isfile(csv_file)

            df = read_csv(csv_file)
            compare_df(df, REF)
        finally:
            shutil.rmtree(tmp_path)
Exemplo n.º 4
0
def test_delete_finally() -> None:
    """Test :exc:`nanoutils.FileNotFoundWarning`."""
    assertion.isfile(FILE1, invert=True)
    assertion.isdir(DIR1, invert=True)

    os.mkdir(DIR1)
    with open(FILE1, 'w'):
        pass

    assertion.isfile(FILE1)
    assertion.isdir(DIR1)

    @delete_finally(DIR1, FILE1)
    def func() -> None:
        pass

    func()
    assertion.isfile(FILE1, invert=True)
    assertion.isdir(DIR1, invert=True)
Exemplo n.º 5
0
def test_isfile() -> None:
    """Test :meth:`AssertionManager.isfile`."""
    assertion.isfile(TEST_FILE)
    assertion.isfile(TEST_DIR, invert=True)
    assertion.isfile(TEST_DUMMY, invert=True)
    assertion.isfile('bob', invert=True)
    assertion.isfile(5, 6, 7, 8, exception=TypeError)
    assertion.isfile([5], exception=TypeError)