def test_get_status_reports_running(running_status): """ Test that status code 202 is interpreted as query running or queued. """ con_mock = Mock() con_mock.get_url.return_value = Mock(status_code=202) con_mock.get_url.return_value.json.return_value = { "status": running_status } status = get_status(connection=con_mock, query_id="foo") assert status == running_status
def status(self) -> str: """ Status of this query. Returns ------- str One of: - "not_running" - "queued" - "executing" - "completed" """ if not hasattr(self, "_query_id"): return "not_running" return get_status(connection=self.connection, query_id=self._query_id)
def test_get_status_reports_finished(): """ Test that status code 303 is interpreted as query finished. """ con_mock = Mock() con_mock.session.get.return_value = Mock(status_code=303) status = get_status(con_mock, "foo") assert status == "Finished"
def test_get_status_reports_running(): """ Test that status code 202 is interpreted as query running. """ con_mock = Mock() con_mock.session.get.return_value = Mock(status_code=202) status = get_status(con_mock, "foo") assert status == "Running"
def test_get_status_raises(): """Test that get_status raises an error for a status code other than 202, 303 or 404.""" con_mock = Mock() con_mock.get_url.return_value = Mock(status_code=500) with pytest.raises(FlowclientConnectionError): get_status(connection=con_mock, query_id="foo")
def test_get_status_404(): """Test that get_status reports that a query is not running.""" con_mock = Mock() con_mock.get_url.side_effect = FileNotFoundError("DUMMY_404") status_returned = get_status(connection=con_mock, query_id="foo") assert status_returned == "not_running"
def test_get_status_reports_finished(): """Test that status code 303 is interpreted as query finished.""" con_mock = Mock() con_mock.get_url.return_value = Mock(status_code=303) status = get_status(connection=con_mock, query_id="foo") assert status == "completed"