(self, name, status=None, tags=None, count=None, at_least=1, hostname=None, message=None)
Assert a service check was processed by this stub
Assert a service check was processed by this stub
Assert a service check was processed by this stub
def assert_service_check(self, name, status=None, tags=None, count=None, at_least=1, hostname=None, message=None):
        """
        Assert a service check was processed by this stub
        """
        tags = normalize_tags(tags, sort=True)
        candidates = []
        for sc in self.service_checks(name):
            if status is not None and status != sc.status:
                continue

            if tags and tags != sorted(sc.tags):
                continue

            if hostname is not None and hostname != sc.hostname:
                continue

            if message is not None and message != sc.message:
                continue

            candidates.append(sc)

        expected_service_check = ServiceCheckStub(
            None, name=name, status=status, tags=tags, hostname=hostname, message=message
        )

        if count is not None:
            msg = "Needed exactly {} candidates for '{}', got {}".format(count, name, len(candidates))
            condition = len(candidates) == count
        else:
            msg = "Needed at least {} candidates for '{}', got {}".format(at_least, name, len(candidates))
            condition = len(candidates) >= at_least
        self._assert(
            condition=condition, msg=msg, expected_stub=expected_service_check, submitted_elements=self._service_checks
        )
def assert_service_check ( self , name , status = None , tags = None , count = None , at_least = 1 , hostname = None , message = None ) : tags = normalize_tags ( tags , sort = True ) candidates = [ ] for sc in self . service_checks ( name ) : if status is not None and status != sc . status : continue if tags and tags != sorted ( sc . tags ) : continue if hostname is not None and hostname != sc . hostname : continue if message is not None and message != sc . message : continue candidates . append ( sc ) expected_service_check = ServiceCheckStub ( None , name = name , status = status , tags = tags , hostname = hostname , message = message ) if count is not None : msg = "Needed exactly {} candidates for '{}', got {}" . format ( count , name , len ( candidates ) ) condition = len ( candidates ) == count else : msg = "Needed at least {} candidates for '{}', got {}" . format ( at_least , name , len ( candidates ) ) condition = len ( candidates ) >= at_least self . _assert ( condition = condition , msg = msg , expected_stub = expected_service_check , submitted_elements = self . _service_checks )