Exemple #1
0
 def test_1020(self):
   """ping(): With list of hosts, pings each host"""
   host_list = [
     d1_test.d1_test_case.MOCK_BASE_URL + '/{}'.format(i) for i in range(10)
   ]
   for host_base_url in host_list:
     mock_ping.add_callback(host_base_url)
   stdout_str = self._ping(hosts=host_list)
   for host_base_url in host_list:
     assert re.search(r'Responded:.*{}'.format(host_base_url), stdout_str)
 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
     )
Exemple #3
0
 def test_1010(self, mn_client_v1_v2):
     """mock_api.ping(): Passing a trigger header triggers a DataONEException"""
     mock_ping.add_callback(d1_test.d1_test_case.MOCK_BASE_URL)
     with pytest.raises(d1_common.types.exceptions.NotFound):
         mn_client_v1_v2.ping(vendorSpecific={'trigger': '404'})
Exemple #4
0
 def test_1000(self, mn_client_v1_v2):
     """mock_api.ping() returns 200"""
     mock_ping.add_callback(d1_test.d1_test_case.MOCK_BASE_URL)
     assert mn_client_v1_v2.ping()