# Path: alignak_app/backend/datamanager.py
# class DataManager(object):
#     def __init__(self):
#     def is_ready(self):
#     def update_database(self, item_type, items_list):
#     def get_item(self, item_type, key, value=None):
#     def remove_item(self, item_type, key, value=None):
#     def update_item_data(self, item_type, item_id, data):
#     def get_realm_name(self, realm):
#     def get_period_name(self, period):
#     def get_synthesis_count(self):
#     def get_all_hostnames(self):
#     def get_host_services(self, host_id):
#     def get_host_with_services(self, host_field):
#     def get_events(self):
#     def get_items_and_problems(self):
#     def update_problems(self):
#     def get_problems(self):
#     def is_problem(item_type, item_data):
# 
# 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/events/events.py
# def init_event_widget():  # pragma: no cover
#     """
#     Initialize the global EventsQWidget. Used for drag & drop and send events
# 
#     """
# 
#     global events_widget  # pylint: disable=global-statement
# 
#     events_widget = EventsQWidget()
#     events_widget.initialize()
# 
# Path: alignak_app/qobjects/app_main.py
# class AppQMainWindow(QMainWindow):
#     """
#         Class who create QMainWindow of Alignak-app
#     """
# 
#     def __init__(self, parent=None):
#         super(AppQMainWindow, self).__init__(parent)
#         self.setWindowFlags(Qt.FramelessWindowHint)
#         self.setStyleSheet(settings.css_style)
#         self.setWindowIcon(QIcon(settings.get_image('icon')))
#         # Fields
#         self.dock = DockQWidget()
#         self.panel_widget = PanelQWidget()
#         self.offset = None
# 
#     def initialize(self):
#         """
#         Initialize QMainWindow for App
# 
#         """
# 
#         logger.info('Display Alignak-App...')
# 
#         app_widget = QWidget()
#         app_widget.setObjectName('dialog')
#         app_layout = QGridLayout()
#         app_layout.setContentsMargins(0, 0, 0, 0)
#         app_widget.setLayout(app_layout)
# 
#         # Logo widget
#         app_layout.addWidget(get_logo_widget(self, 'Alignak-App'), 0, 0, 1, 3)
# 
#         # Panel
#         self.panel_widget.initialize()
#         app_layout.addWidget(self.panel_widget, 1, 0, 1, 1)
#         app_layout.addWidget(get_frame_separator(True), 1, 1, 1, 1)
# 
#         # Dock
#         self.dock.initialize()
#         app_layout.addWidget(self.dock, 1, 2, 1, 1)
# 
#         self.setCentralWidget(app_widget)
#         self.setMinimumSize(1440, 900)
#         center_widget(self)
# 
#         display = settings.get_config('Alignak-app', 'display')
#         if "min" in display:
#             self.show()
#         elif "max" in display:
#             self.showMaximized()
#         else:
#             pass
# 
#         if settings.get_config('Alignak-app', 'problems', boolean=True):
#             self.panel_widget.tab_widget.setCurrentIndex(
#                 self.panel_widget.tab_widget.indexOf(self.panel_widget.problems_widget)
#             )
#             self.panel_widget.problems_widget.line_search.setFocus()
#         else:
#             self.panel_widget.synthesis_widget.line_search.setFocus()
# 
#     def showEvent(self, _):
#         """ showEvent(self, QShowEvent) """
# 
#         if isinstance(
#                 self.panel_widget.tab_widget.currentWidget(),
#                 type(self.panel_widget.problems_widget)):
#             self.panel_widget.problems_widget.line_search.setFocus()
#         else:
#             self.panel_widget.synthesis_widget.line_search.setFocus()
# 
#         self.activateWindow()
# 
#     def mousePressEvent(self, event):  # pragma: no cover - not testable
#         """ QWidget.mousePressEvent(QMouseEvent) """
# 
#         self.offset = event.pos()
# 
#     def mouseMoveEvent(self, event):  # pragma: no cover - not testable
#         """ QWidget.mousePressEvent(QMouseEvent) """
# 
#         try:
#             x = event.globalX()
#             y = event.globalY()
#             x_w = self.offset.x()
#             y_w = self.offset.y()
#             self.move(x - x_w, y - y_w)
#         except AttributeError as e:
#             logger.warning('Move Event %s: %s', self.objectName(), str(e))


import sys
import unittest2
from PyQt5.QtWidgets import QApplication
from alignak_app.backend.datamanager import data_manager
from alignak_app.utils.config import settings
from alignak_app.qobjects.events.events import init_event_widget
from alignak_app.qobjects.app_main import AppQMainWindow






class TestAppQMainWindow(unittest2.TestCase):
    """
        This file test methods of AppQMainWindow class.
    """

    @classmethod
    def setUpClass(cls):
        """Create QApplication"""

        try:
            cls.app = QApplication(sys.argv)
        except:
            pass

    def test_initialize_app_main_window(self):
        """Initialize AppQMainWindow"""

        under_test = AppQMainWindow()

        self.assertTrue(under_test.panel_widget)
        self.assertTrue(under_test.dock)
        self.assertIsNone(under_test.offset)

        data_manager.update_database('host', [])

# Path: alignak_app/backend/datamanager.py
# class DataManager(object):
#     def __init__(self):
#     def is_ready(self):
#     def update_database(self, item_type, items_list):
#     def get_item(self, item_type, key, value=None):
#     def remove_item(self, item_type, key, value=None):
#     def update_item_data(self, item_type, item_id, data):
#     def get_realm_name(self, realm):
#     def get_period_name(self, period):
#     def get_synthesis_count(self):
#     def get_all_hostnames(self):
#     def get_host_services(self, host_id):
#     def get_host_with_services(self, host_field):
#     def get_events(self):
#     def get_items_and_problems(self):
#     def update_problems(self):
#     def get_problems(self):
#     def is_problem(item_type, item_data):
# 
# 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/events/events.py
# def init_event_widget():  # pragma: no cover
#     """
#     Initialize the global EventsQWidget. Used for drag & drop and send events
# 
#     """
# 
#     global events_widget  # pylint: disable=global-statement
# 
#     events_widget = EventsQWidget()
#     events_widget.initialize()
# 
# Path: alignak_app/qobjects/app_main.py
# class AppQMainWindow(QMainWindow):
#     """
#         Class who create QMainWindow of Alignak-app
#     """
# 
#     def __init__(self, parent=None):
#         super(AppQMainWindow, self).__init__(parent)
#         self.setWindowFlags(Qt.FramelessWindowHint)
#         self.setStyleSheet(settings.css_style)
#         self.setWindowIcon(QIcon(settings.get_image('icon')))
#         # Fields
#         self.dock = DockQWidget()
#         self.panel_widget = PanelQWidget()
#         self.offset = None
# 
#     def initialize(self):
#         """
#         Initialize QMainWindow for App
# 
#         """
# 
#         logger.info('Display Alignak-App...')
# 
#         app_widget = QWidget()
#         app_widget.setObjectName('dialog')
#         app_layout = QGridLayout()
#         app_layout.setContentsMargins(0, 0, 0, 0)
#         app_widget.setLayout(app_layout)
# 
#         # Logo widget
#         app_layout.addWidget(get_logo_widget(self, 'Alignak-App'), 0, 0, 1, 3)
# 
#         # Panel
#         self.panel_widget.initialize()
#         app_layout.addWidget(self.panel_widget, 1, 0, 1, 1)
#         app_layout.addWidget(get_frame_separator(True), 1, 1, 1, 1)
# 
#         # Dock
#         self.dock.initialize()
#         app_layout.addWidget(self.dock, 1, 2, 1, 1)
# 
#         self.setCentralWidget(app_widget)
#         self.setMinimumSize(1440, 900)
#         center_widget(self)
# 
#         display = settings.get_config('Alignak-app', 'display')
#         if "min" in display:
#             self.show()
#         elif "max" in display:
#             self.showMaximized()
#         else:
#             pass
# 
#         if settings.get_config('Alignak-app', 'problems', boolean=True):
#             self.panel_widget.tab_widget.setCurrentIndex(
#                 self.panel_widget.tab_widget.indexOf(self.panel_widget.problems_widget)
#             )
#             self.panel_widget.problems_widget.line_search.setFocus()
#         else:
#             self.panel_widget.synthesis_widget.line_search.setFocus()
# 
#     def showEvent(self, _):
#         """ showEvent(self, QShowEvent) """
# 
#         if isinstance(
#                 self.panel_widget.tab_widget.currentWidget(),
#                 type(self.panel_widget.problems_widget)):
#             self.panel_widget.problems_widget.line_search.setFocus()
#         else:
#             self.panel_widget.synthesis_widget.line_search.setFocus()
# 
#         self.activateWindow()
# 
#     def mousePressEvent(self, event):  # pragma: no cover - not testable
#         """ QWidget.mousePressEvent(QMouseEvent) """
# 
#         self.offset = event.pos()
# 
#     def mouseMoveEvent(self, event):  # pragma: no cover - not testable
#         """ QWidget.mousePressEvent(QMouseEvent) """
# 
#         try:
#             x = event.globalX()
#             y = event.globalY()
#             x_w = self.offset.x()
#             y_w = self.offset.y()
#             self.move(x - x_w, y - y_w)
#         except AttributeError as e:
#             logger.warning('Move Event %s: %s', self.objectName(), str(e))


# Path: test/test_app_main.py
import sys
import unittest2
from PyQt5.QtWidgets import QApplication
from alignak_app.backend.datamanager import data_manager
from alignak_app.utils.config import settings
from alignak_app.qobjects.events.events import init_event_widget
from alignak_app.qobjects.app_main import AppQMainWindow







class TestAppQMainWindow(unittest2.TestCase):
    """
        This file test methods of AppQMainWindow class.
    """

    @classmethod
    def setUpClass(cls):
        """Create QApplication"""

        try:
            cls.app = QApplication(sys.argv)
        except:
            pass

    def test_initialize_app_main_window(self):
        """Initialize AppQMainWindow"""

        under_test = AppQMainWindow()

        self.assertTrue(under_test.panel_widget)
        self.assertTrue(under_test.dock)
        self.assertIsNone(under_test.offset)

        data_manager.update_database('host', [])

        data_manager.update_database('service', [])