# Path: alignak_app/utils/config.py
# class Settings(object):
#     def __init__(self):
#     def init_config(self):
#     def get_config(self, section, option, boolean=False):
#     def set_config(self, section, option, new_value):
#     def get_image(self, name):
#     def init_css(self):
# def open_url(endpoint='login'):  # pragma: no cover
# def get_url_endpoint_from_icon_name(icon_name):
# 
# Path: alignak_app/qobjects/common/labels.py
# def get_icon_pixmap(value, icons):
#     """
#     Return corresponding icon name in icons
# 
#     :param value: value of attribute
#     :type value: bool
#     :param icons: pair of icons
#     :type icons: list
#     :return: pixmap icon corresponding to value
#     :rtype: QPixmap
#     """
# 
#     if not isinstance(value, bool) or not value:
#         value = False
# 
#     available_icons = {
#         True: icons[0],
#         False: icons[1]
#     }
# 
#     return QPixmap(settings.get_image(available_icons[value]))
# 
# def get_icon_item(item_type, problem_nb):
#     """
#     Return QPixmap with the corresponding image
# 
#     :param item_type: type of item: host, service or problem
#     :type item_type: str
#     :param problem_nb: problem number
#     :type problem_nb: int
#     :return: QPixmap with corresponding image
#     :rtype: QPixmap
#     """
# 
#     if problem_nb > 0:
#         if item_type == 'host':
#             icon_type = 'hosts_down'
#         elif item_type == 'service':
#             icon_type = 'services_critical'
#         else:
#             icon_type = 'problem'
#     else:
#         if item_type == 'host':
#             icon_type = 'hosts_up'
#         elif item_type == 'service':
#             icon_type = 'services_ok'
#         else:
#             icon_type = 'problem_ok'
# 
#     icon = QPixmap(settings.get_image(icon_type))
# 
#     return icon


import sys
import unittest2
from PyQt5.Qt import QApplication, QPixmap
from alignak_app.utils.config import settings
from alignak_app.qobjects.common.labels import get_icon_pixmap, get_icon_item
class TestCommonQPixmap(unittest2.TestCase):
    """
        This file test the Common QPixmap funtions
    """

    @classmethod
    def setUpClass(cls):
        """Create QApplication"""
        try:
            cls.app = QApplication(sys.argv)
        except:
            pass

    def test_get_icon_item(self):
        """Get Icon Item"""

        item_types = ['host', 'service', 'problem']
        under_test = None

        i = -3
        for item in item_types:
            under_test = get_icon_item(item, i)
            i += 1

        self.assertIsInstance(under_test, QPixmap)

    def test_get_icon_pixmap(self):
        """Get Icon Pixmap"""

        under_test_true = get_icon_pixmap(True, ['first', 'second'])

# Path: alignak_app/utils/config.py
# class Settings(object):
#     def __init__(self):
#     def init_config(self):
#     def get_config(self, section, option, boolean=False):
#     def set_config(self, section, option, new_value):
#     def get_image(self, name):
#     def init_css(self):
# def open_url(endpoint='login'):  # pragma: no cover
# def get_url_endpoint_from_icon_name(icon_name):
# 
# Path: alignak_app/qobjects/common/labels.py
# def get_icon_pixmap(value, icons):
#     """
#     Return corresponding icon name in icons
# 
#     :param value: value of attribute
#     :type value: bool
#     :param icons: pair of icons
#     :type icons: list
#     :return: pixmap icon corresponding to value
#     :rtype: QPixmap
#     """
# 
#     if not isinstance(value, bool) or not value:
#         value = False
# 
#     available_icons = {
#         True: icons[0],
#         False: icons[1]
#     }
# 
#     return QPixmap(settings.get_image(available_icons[value]))
# 
# def get_icon_item(item_type, problem_nb):
#     """
#     Return QPixmap with the corresponding image
# 
#     :param item_type: type of item: host, service or problem
#     :type item_type: str
#     :param problem_nb: problem number
#     :type problem_nb: int
#     :return: QPixmap with corresponding image
#     :rtype: QPixmap
#     """
# 
#     if problem_nb > 0:
#         if item_type == 'host':
#             icon_type = 'hosts_down'
#         elif item_type == 'service':
#             icon_type = 'services_critical'
#         else:
#             icon_type = 'problem'
#     else:
#         if item_type == 'host':
#             icon_type = 'hosts_up'
#         elif item_type == 'service':
#             icon_type = 'services_ok'
#         else:
#             icon_type = 'problem_ok'
# 
#     icon = QPixmap(settings.get_image(icon_type))
# 
#     return icon


# Path: test/test_common_pixmap.py
import sys
import unittest2
from PyQt5.Qt import QApplication, QPixmap
from alignak_app.utils.config import settings
from alignak_app.qobjects.common.labels import get_icon_pixmap, get_icon_item

class TestCommonQPixmap(unittest2.TestCase):
    """
        This file test the Common QPixmap funtions
    """

    @classmethod
    def setUpClass(cls):
        """Create QApplication"""
        try:
            cls.app = QApplication(sys.argv)
        except:
            pass

    def test_get_icon_item(self):
        """Get Icon Item"""

        item_types = ['host', 'service', 'problem']
        under_test = None

        i = -3
        for item in item_types:
            under_test = get_icon_item(item, i)
            i += 1

        self.assertIsInstance(under_test, QPixmap)

    def test_get_icon_pixmap(self):
        """Get Icon Pixmap"""

        under_test_true = get_icon_pixmap(True, ['first', 'second'])

        under_test_false = get_icon_pixmap(False, ['first', 'second'])