def test_works(self, tmp_path):

        work_dir = tmp_path / 'sub'

        work_dir.mkdir()

        output = download_pdb.download('5aol', 'cif', work_dir)

        assert output == work_dir / '5aol.cif'
Esempio n. 2
0
    def test_raises_FileNotFoundError(self, mocker):

        m_retrieve = mocker.patch.object(Bio.PDB.PDBList,
                                         'retrieve_pdb_file',
                                         return_value='TEST_PATH')

        m_exists = mocker.patch.object(Path, 'exists', return_value=False)

        m_cwd = mocker.patch.object(Path, 'cwd')

        with pytest.raises(FileNotFoundError):

            download_pdb.download('5aol', 'pdb', 'SOME_WORK_DIR')

        m_retrieve.assert_called_once_with('5aol',
                                           False,
                                           'SOME_WORK_DIR',
                                           file_format='pdb',
                                           overwrite=True)

        m_exists.assert_called_once()

        m_cwd.assert_not_called()
Esempio n. 3
0
    def test_works_pdb(self, mocker):

        m_retrieve = mocker.patch.object(Bio.PDB.PDBList,
                                         'retrieve_pdb_file',
                                         return_value='TEST_PATH')

        m_exists = mocker.patch.object(Path, 'exists', return_value=True)

        m_cwd = mocker.patch.object(Path, 'cwd')

        output = download_pdb.download('5aol', 'pdb', 'SOME_WORK_DIR')

        m_retrieve.assert_called_once_with('5aol',
                                           False,
                                           'SOME_WORK_DIR',
                                           file_format='pdb',
                                           overwrite=True)

        m_exists.assert_called_once()

        m_cwd.assert_not_called()

        assert isinstance(output, Path)
Esempio n. 4
0
    def test_raises_ValueError(self):

        with pytest.raises(ValueError):

            download_pdb.download('5aol', 'WRONG FILE TYPE')