def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer): self.api = hs.get_application_service_api() self.service = ApplicationService( id="unique_identifier", sender="@as:test", url=URL, token="unused", hs_token=TOKEN, )
def prepare(self, reactor: MemoryReactor, clock: Clock, hs: HomeServer) -> None: # Allow us to modify cached feature flags mid-test self.as_handler = hs.get_application_service_handler() # Mock ApplicationServiceApi's put_json, so we can verify the raw JSON that # will be sent over the wire self.put_json = simple_async_mock() hs.get_application_service_api( ).put_json = self.put_json # type: ignore[assignment] # Mock out application services, and allow defining our own in tests self._services: List[ApplicationService] = [] self.hs.get_datastores().main.get_app_services = Mock( return_value=self._services)