Skip to content

Commit

Permalink
Try to improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
mohierf committed Mar 25, 2018
1 parent 3a48363 commit 07a8b1e
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 155 deletions.
2 changes: 1 addition & 1 deletion alignak/objects/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2770,7 +2770,7 @@ def prepare_for_sending(self):
# Now serialize the whole configuration, for sending to spare arbiters
self.spare_arbiter_conf = serialize(self)

def dump(self, dump_file=None):
def dump(self, dump_file=None): # pragma: no cover, not for unit tests...
"""Dump configuration to a file in a JSON format
:param dump_file: the file to dump
Expand Down
84 changes: 28 additions & 56 deletions alignak/objects/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,34 +435,6 @@ def get_hostgroups(self):
"""
return self.hostgroups

def get_host_tags(self):
"""Accessor to tags attribute
:return: tag list of host
:rtype: list
"""
return self.tags

# def get_realm_name(self):
# """Accessor to realm attribute
# :return: realm object of host
# :rtype: alignak.objects.realm.Realm
# """
# return self.realm_name
#
def is_linked_with_host(self, other):
"""Check if other is in act_depend_of host attribute
:param other: other host to search
:type other: alignak.objects.host.Host
:return: True if other in act_depend_of list, otherwise False
:rtype: bool
"""
for (host, _, _, _) in self.act_depend_of:
if host == other:
return True
return False

def add_service_link(self, service):
"""Add a service to the service list of this host
Expand Down Expand Up @@ -908,34 +880,34 @@ def manage_stalking(self, check):
if need_stalk:
logger.info("Stalking %s: %s", self.get_name(), self.output)

def get_data_for_checks(self):
"""Get data for a check
:return: list containing a single host (this one)
:rtype: list
"""
return [self]

def get_data_for_event_handler(self):
"""Get data for an event handler
:return: list containing a single host (this one)
:rtype: list
"""
return [self]

def get_data_for_notifications(self, contact, notif):
"""Get data for a notification
:param contact: The contact to return
:type contact:
:param notif: the notification to return
:type notif:
:return: list containing a the host and the given parameters
:rtype: list
"""
return [self, contact, notif]

# def get_data_for_checks(self):
# """Get data for a check
#
# :return: list containing a single host (this one)
# :rtype: list
# """
# return [self]
#
# def get_data_for_event_handler(self):
# """Get data for an event handler
#
# :return: list containing a single host (this one)
# :rtype: list
# """
# return [self]
#
# def get_data_for_notifications(self, contact, notif):
# """Get data for a notification
#
# :param contact: The contact to return
# :type contact:
# :param notif: the notification to return
# :type notif:
# :return: list containing a the host and the given parameters
# :rtype: list
# """
# return [self, contact, notif]
#
def notification_is_blocked_by_contact(self, notifways, timeperiods, notif, contact):
"""Check if the notification is blocked by this contact.
Expand Down
54 changes: 27 additions & 27 deletions alignak/objects/schedulingitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -2942,33 +2942,33 @@ def raise_notification_log_entry(self, notif, contact, host_ref): # pragma: no
"""
pass

def get_data_for_checks(self): # pragma: no cover, base function
"""Get data for a check
:return: list containing the service and the linked host
:rtype: list
"""
pass

def get_data_for_event_handler(self): # pragma: no cover, base function
"""Get data for an event handler
:return: list containing a single item (this one)
:rtype: list
"""
pass

def get_data_for_notifications(self, contact, notif): # pragma: no cover, base function
"""Get data for a notification
:param contact: The contact to return
:type contact:
:param notif: the notification to return
:type notif:
:return: list
:rtype: list
"""
pass
# def get_data_for_checks(self): # pragma: no cover, base function
# """Get data for a check
#
# :return: list containing the service and the linked host
# :rtype: list
# """
# pass
#
# def get_data_for_event_handler(self): # pragma: no cover, base function
# """Get data for an event handler
#
# :return: list containing a single item (this one)
# :rtype: list
# """
# pass
#
# def get_data_for_notifications(self, contact, notif): # pragma: no cover, base function
# """Get data for a notification
#
# :param contact: The contact to return
# :type contact:
# :param notif: the notification to return
# :type notif:
# :return: list
# :rtype: list
# """
# pass

def set_impact_state(self):
"""We just go an impact, so we go unreachable
Expand Down
54 changes: 27 additions & 27 deletions alignak/objects/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -929,33 +929,33 @@ def manage_stalking(self, check):
if need_stalk:
logger.info("Stalking %s: %s", self.get_name(), check.output)

def get_data_for_checks(self):
"""Get data for a check
:return: list containing the service and the linked host
:rtype: list
"""
return [self.host, self]

def get_data_for_event_handler(self):
"""Get data for an event handler
:return: list containing the service and the linked host
:rtype: list
"""
return [self.host, self]

def get_data_for_notifications(self, contact, notif):
"""Get data for a notification
:param contact: The contact to return
:type contact:
:param notif: the notification to return
:type notif:
:return: list containing the service, the host and the given parameters
:rtype: list
"""
return [self.host, self, contact, notif]
# def get_data_for_checks(self):
# """Get data for a check
#
# :return: list containing the service and the linked host
# :rtype: list
# """
# return [self.host, self]
#
# def get_data_for_event_handler(self):
# """Get data for an event handler
#
# :return: list containing the service and the linked host
# :rtype: list
# """
# return [self.host, self]
#
# def get_data_for_notifications(self, contact, notif):
# """Get data for a notification
#
# :param contact: The contact to return
# :type contact:
# :param notif: the notification to return
# :type notif:
# :return: list containing the service, the host and the given parameters
# :rtype: list
# """
# return [self.host, self, contact, notif]

def notification_is_blocked_by_contact(self, notifways, timeperiods, notif, contact):
"""Check if the notification is blocked by this contact.
Expand Down
45 changes: 1 addition & 44 deletions alignak/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def split_semicolon(line, maxsplit=None):
return split_line


def jsonify_r(obj):
def jsonify_r(obj): # pragma: no cover, not for unit tests...
"""Convert an object into json (recursively on attribute)
:param obj: obj to jsonify
Expand Down Expand Up @@ -245,20 +245,6 @@ def get_end_of_day(year, month_id, day):
return end_time_epoch


def print_date(timestamp):
"""Get date (local) in asc format from timestamp
example : 'Thu Jan 1 01:00:00 1970' (for timestamp=0 in a EUW server)
:param timestamp: timestamp
:type timestamp; int
:return: formatted time
:rtype: int
TODO: Missing timezone
"""
return time.asctime(time.localtime(timestamp))


def get_day(timestamp):
"""Get timestamp of the beginning of the day (local) given by timestamp
Expand Down Expand Up @@ -669,21 +655,6 @@ def to_svc_hst_distinct_lists(ref, tab): # pragma: no cover, to be deprectaed?
return res


def get_obj_name(obj):
"""Get object name (call get_name) if not a string
:param obj: obj we want the name
:type obj: object
:return: object name
:rtype: str
"""
# Maybe we do not have a real object but already a string. If so
# return the string
if isinstance(obj, basestring):
return obj
return obj.get_name()


def get_obj_name_two_args_and_void(obj, value): # pylint: disable=W0613
"""Get value name (call get_name) if not a string
Expand All @@ -700,20 +671,6 @@ def get_obj_name_two_args_and_void(obj, value): # pylint: disable=W0613
return ''


def get_obj_full_name(obj):
"""Wrapper to call obj.get_full_name or obj.get_name
:param obj: object name
:type obj: object
:return: object name
:rtype: str
"""
try:
return obj.get_full_name()
except AttributeError:
return obj.get_name()


def get_customs_keys(dic): # pragma: no cover, to be deprectaed?
"""Get a list of keys of the custom dict
without the first char
Expand Down

0 comments on commit 07a8b1e

Please sign in to comment.