Beispiel #1
0
    def test_valid_doi_with_request_timeout(self):
        import requests

        _requests = self.mocker.replace("requests.get")
        _requests('http://dx.doi.org/10.1590/S2179-975X2012005000031', timeout=2.5)
        self.mocker.throw(requests.exceptions.Timeout)

        self.mocker.replay()

        self.assertRaises(requests.exceptions.Timeout, lambda: utils.is_valid_doi('10.1590/S2179-975X2012005000031'))
Beispiel #2
0
    def test_valid_doi_with_request_timeout(self):
        import requests

        _requests = self.mocker.replace("requests.get")
        _requests('http://dx.doi.org/10.1590/S2179-975X2012005000031',
                  timeout=2.5)
        self.mocker.throw(requests.exceptions.Timeout)

        self.mocker.replay()

        self.assertRaises(
            requests.exceptions.Timeout,
            lambda: utils.is_valid_doi('10.1590/S2179-975X2012005000031'))
Beispiel #3
0
    def test_valid_doi_status_500(self):
        mock_is_valid = self.mocker.mock()

        mock_is_valid.status_code
        self.mocker.result(500)

        requests = self.mocker.replace("requests.get")
        requests('http://dx.doi.org/10.1590/S2179-975X2012005XXXX', timeout=2.5)
        self.mocker.result(mock_is_valid)

        self.mocker.replay()

        self.assertFalse(utils.is_valid_doi('10.1590/S2179-975X2012005XXXX'))
Beispiel #4
0
    def test_valid_doi_status_500(self):
        mock_is_valid = self.mocker.mock()

        mock_is_valid.status_code
        self.mocker.result(500)

        requests = self.mocker.replace("requests.get")
        requests('http://dx.doi.org/10.1590/S2179-975X2012005XXXX',
                 timeout=2.5)
        self.mocker.result(mock_is_valid)

        self.mocker.replay()

        self.assertFalse(utils.is_valid_doi('10.1590/S2179-975X2012005XXXX'))