def _set_mock_session(self): # Must add Responses callbacks after activating @responses.activate mock_get.add_callback(d1_test.d1_test_case.MOCK_MN_BASE_URL) mock_list_nodes.add_callback(d1_test.d1_test_case.MOCK_CN_BASE_URL) mock_ping.add_callback(d1_test.d1_test_case.MOCK_MN_BASE_URL) mock_ping.add_callback(d1_test.d1_test_case.MOCK_CN_BASE_URL) mock_solr_search.add_callback(d1_test.d1_test_case.MOCK_CN_BASE_URL) mock_list_formats.add_callback(d1_test.d1_test_case.MOCK_CN_BASE_URL) mock_resolve.add_callback(d1_test.d1_test_case.MOCK_CN_BASE_URL) # Must set these session variables after activating Responses because # they implicitly call listNodes, etc. with d1_test.d1_test_case.mock_input('yes'): self.cp.get_session().set( session.CN_URL_NAME, d1_test.d1_test_case.MOCK_CN_BASE_URL ) self.cp.get_session().set( session.MN_URL_NAME, d1_test.d1_test_case.MOCK_MN_BASE_URL )
def test_1020(self, cn_client_v2): """mock_api.resolve(): Passing a trigger header triggers a DataONEException""" mock_resolve.add_callback(d1_test.d1_test_case.MOCK_CN_BASE_URL) with pytest.raises(d1_common.types.exceptions.NotFound): cn_client_v2.resolve('valid_pid', vendorSpecific={'trigger': '404'})
def test_1010(self, cn_client_v2): """mock_api.resolve(): Unknown PID returns D1 NotFound""" mock_resolve.add_callback(d1_test.d1_test_case.MOCK_CN_BASE_URL) with pytest.raises(d1_common.types.exceptions.NotFound): cn_client_v2.resolve('<NotFound>pid')
def test_1000(self, cn_client_v2): """mock_api.resolve(): Returns a valid ObjectLocationList""" mock_resolve.add_callback(d1_test.d1_test_case.MOCK_CN_BASE_URL) assert isinstance(cn_client_v2.resolve('valid_pid'), cn_client_v2.bindings.ObjectLocationList)