def test_protein_to_transcript_cache(accession, version, match_version, expected_forward, expected_reverse): """ Get transcript for protein and check the resulting cache state. """ try: ncbi.protein_to_transcript(accession, version, match_version) except ncbi.NoLinkError: pass forward = [(key.split(':')[-1], redis.get(key) or None) for key in redis.keys('ncbi:transcript-to-protein:*')] assert sorted(forward) == sorted(expected_forward) reverse = [(redis.get(key) or None, key.split(':')[-1]) for key in redis.keys('ncbi:protein-to-transcript:*')] assert sorted(reverse) == sorted(expected_reverse)
def test_protein_to_transcript(accession, version, match_version, expected): """ Get transcript for protein. Both the Entrez API and our cache are fixed with a set of transcript-protein links. This test is parametrized with a list of arguments for the :func:`ncbi.transcript_to_protein` function and the corresponding expected result. Fixtures and parameters of this test mirror those of the `test_transcript_to_protein` test. """ if expected is None: with pytest.raises(ncbi.NoLinkError): ncbi.protein_to_transcript(accession, version, match_version) else: assert ncbi.protein_to_transcript(accession, version, match_version) == expected
def test_protein_to_transcript(accession, version, match_version, expected): """ Get transcript for protein. Both the Entrez API and our cache are fixed with a set of transcript-protein links. This test is parametrized with a list of arguments for the :func:`ncbi.transcript_to_protein` function and the corresponding expected result. Fixtures and parameters of this test mirror those of the `test_transcript_to_protein` test. """ if expected is None: with pytest.raises(ncbi.NoLinkError): ncbi.protein_to_transcript(accession, version, match_version) else: assert ncbi.protein_to_transcript( accession, version, match_version) == expected