Skip to content

Commit

Permalink
Improve contactgroup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mohierf committed Sep 12, 2016
1 parent 251fe69 commit 03be436
Show file tree
Hide file tree
Showing 11 changed files with 393 additions and 210 deletions.
16 changes: 6 additions & 10 deletions alignak/objects/contactgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"""
from alignak.objects.itemgroup import Itemgroup, Itemgroups

from alignak.property import StringProp
from alignak.property import StringProp, ListProp
from alignak.log import logger


Expand All @@ -71,7 +71,8 @@ class Contactgroup(Itemgroup):
'uuid': StringProp(default='', fill_brok=['full_status']),
'contactgroup_name': StringProp(fill_brok=['full_status']),
'alias': StringProp(fill_brok=['full_status']),
'contactgroup_members': StringProp(fill_brok=['full_status']),
'contactgroup_members': ListProp(default=[], fill_brok=['full_status'],
merging='join', split_on_coma=True)
})

macros = {
Expand Down Expand Up @@ -102,18 +103,13 @@ def get_name(self):

def get_contactgroup_members(self):
"""
Get contactgroup members
Get list of groups members of this contactgroup
:return: list of hosts
:return: list of contacts
:rtype: list
"""
# TODO: imho a Contactgroup instance should always have defined
# its contactgroup_members attribute, even if it's empty / the empty list.
if hasattr(self, 'contactgroup_members'):
# more over: it should already be in the list form,
# not anymore in the "bare" string from as read
# from configuration (files or db or whatever)
return [m.strip() for m in self.contactgroup_members.split(',')]
return self.contactgroup_members
else:
return []

Expand Down
11 changes: 0 additions & 11 deletions test/_old/etc/alignak_contactgroup_nomembers.cfg

This file was deleted.

69 changes: 0 additions & 69 deletions test/_old/test_contactgroup_nomembers.py

This file was deleted.

120 changes: 0 additions & 120 deletions test/_old/test_contactgroups_plus_inheritance.py

This file was deleted.

22 changes: 22 additions & 0 deletions test/cfg/contactgroup/alignak_contactgroup_members.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
cfg_dir=../default

define contact{
contact_name test_contact_2
alias Second contact alias
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r,f
host_notification_options d,u,r,f,s
service_notification_commands notify-service
host_notification_commands notify-host
email nobody@localhost
can_submit_commands 0
; contactgroups another_contact_test
}

define contactgroup {
contactgroup_name allcontacts_and_groups
alias All: Contacts and groups
members test_contact, test_contact_2
contactgroup_members test_contact
}
6 changes: 6 additions & 0 deletions test/cfg/contactgroup/alignak_contactgroup_no_contact.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cfg_dir=../default

define contactgroup {
contactgroup_name void
alias Void group
}
6 changes: 6 additions & 0 deletions test/cfg/contactgroup/alignak_contactgroup_with_space.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cfg_dir=../default

define contactgroup {
contactgroup_name test_With Spaces
members test_contact
}
35 changes: 35 additions & 0 deletions test/cfg/contactgroup/alignak_contactgroup_with_void_member.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
cfg_dir=../default

define hostgroup{
hostgroup_name MYGROUP
members h1,h2,
}


define host{
host_name h1
use generic-host
}

define host{
host_name h2
use generic-host
}



define contactgroup{
contactgroup_name SPACEMARINES
members m1 , m2 ,
}


define contact{
contact_name m1
use generic-contact
}

define contact{
contact_name m2
use generic-contact
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
cfg_dir=../default

define contactgroup{
contactgroup_name test_contact_1
alias test_contacts_alias_1
Expand Down
4 changes: 4 additions & 0 deletions test/cfg/contactgroup/alignak_groups_with_no_alias.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

define contactgroup {
contactgroup_name NOALIAS
}
Loading

0 comments on commit 03be436

Please sign in to comment.