Exemplo n.º 1
0
    def test_construct_cgi_ecitmatch(self):
        citation = {
            "journal_title": "proc natl acad sci u s a",
            "year": "1991",
            "volume": "88",
            "first_page": "3248",
            "author_name": "mann bj",
            "key": "citation_1",
        }
        variables = Entrez._update_ecitmatch_variables({
            "db": "pubmed",
            "bdata": [citation]
        })

        with patch_urlopen() as patched:
            Entrez.ecitmatch(**variables)

        result_url = get_patched_get_url(patched, self)
        parsed = urlparse(result_url)
        query = parse_qs(parsed.query)

        self.assertEqual(get_base_url(parsed), URL_HEAD + "ecitmatch.cgi")
        query.pop("bdata")  # TODO
        self.assertDictEqual(
            query,
            {
                "retmode": ["xml"],
                "db": [variables["db"]],
                **QUERY_DEFAULTS
            },
        )
Exemplo n.º 2
0
    def test_construct_cgi_ecitmatch(self):
        citation = {
            "journal_title": "proc natl acad sci u s a",
            "year": "1991", "volume": "88", "first_page": "3248",
            "author_name": "mann bj", "key": "citation_1"
        }
        cgi = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/ecitmatch.cgi'
        variables = Entrez._update_ecitmatch_variables({'db': 'pubmed',
                                                        'bdata': [citation]})
        post = False

        params = Entrez._construct_params(variables)
        options = Entrez._encode_options(ecitmatch=True, params=params)
        result_url = Entrez._construct_cgi(cgi, post=post, options=options)
        self.assertIn("retmode=xml", result_url)