async def get_dispatches(
     self, payload: Payload, request: Request
 ) -> Optional[DispatcherResponse]:
     dr = DispatcherResponse()
     if any(
         self.CONDITIONAL_DISPATCH_WORKER in request_payload.results.plugins_run['workers']
         for request_payload in request.payloads
     ):
         dr.plugin_names.extend(self.WORKERS)
     dr.meta['test_key'] = 'Useful metadata info'
     return dr
Exemple #2
0
 async def get_dispatches(self, payload: Payload,
                          request: Request) -> Optional[DispatcherResponse]:
     if self.RAISE_EXCEPTION:
         raise Exception('Test exception please ignore')
     dr = DispatcherResponse()
     if self.RETURN_ERRORS:
         dr.errors.append('Test error please ignore')
     dr.plugin_names.extend(self.WORKERS)
     dr.meta['test_key'] = 'Useful metadata info'
     payload.results.payload_meta.should_archive = self.SHOULD_ARCHIVE
     return dr
Exemple #3
0
 async def get_dispatches(self, payload: Payload,
                          request: Request) -> Optional[DispatcherResponse]:
     if self.RAISE_EXCEPTION:
         raise Exception('Test exception please ignore')
     dr = DispatcherResponse()
     for worker in self.WORKERS:
         for count in range(0, self.RULE_COUNT):
             dr.plugin_names.append(worker)
             dr.meta[worker] = {f'rule{count}': worker}
             payload.results.payload_meta.should_archive = self.SHOULD_ARCHIVE
             if self.RETURN_ERRORS:
                 dr.errors += ['Test error please ignore']
     return dr
Exemple #4
0
 def test_dispatcherresponse_to_str(self):
     response = DispatcherResponse()
     response_str = str(response)
     response_dict = json.loads(response_str)
     self.assertIsInstance(response_str, str)
     self.assertIsInstance(response_dict, dict)