# 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/locales/locales.py
# def init_localization():  # pragma: no cover
#     """
#     Application localization
# 
#     :return: gettext translator method
#     :rtype: method
#     """
#     try:
#         # Language message file
#         lang_filename = os.path.join(
#             os.path.abspath(os.path.dirname(__file__)),
#             "LC_MESSAGES/%s.mo" % settings.get_config('Alignak-app', 'locale')
#         )
#         logger.info(
#             "Opening message file %s for locale %s",
#             lang_filename, settings.get_config('Alignak-app', 'locale')
#         )
#         translation = GNUTranslations(open(lang_filename, "rb"))
#         translation.install()
#         _ = translation.gettext
#     except IOError:
#         logger.warning("Locale not found. Using default language messages (English)")
#         null_translation = NullTranslations()
#         null_translation.install()
#         _ = null_translation.gettext
#     except Exception as e:  # pragma: no cover - should not happen
#         logger.error("Locale not found. Exception: %s", str(e))
#         null_translation = NullTranslations()
#         null_translation.install()
#         _ = null_translation.gettext
# 
#     return _
# 
# Path: alignak_app/qobjects/user/password.py
# class PasswordQDialog(QDialog):
#     """
#         Class who create PasswordDialog QDialog
#     """
# 
#     def __init__(self, parent=None):
#         super(PasswordQDialog, self).__init__(parent)
#         self.setWindowTitle('User Password')
#         self.setWindowFlags(Qt.FramelessWindowHint)
#         self.setStyleSheet(settings.css_style)
#         self.setWindowIcon(QIcon(settings.get_image('icon')))
#         self.setObjectName('dialog')
#         self.setFixedSize(300, 300)
#         # Fields
#         self.pass_edit = QLineEdit()
#         self.confirm_edit = QLineEdit()
#         self.help_label = QLabel()
# 
#     def initialize(self):
#         """
#         Initialize QDialog for PasswordDialog
# 
#         """
# 
#         center_widget(self)
# 
#         # Main status_layout
#         main_layout = QVBoxLayout(self)
#         main_layout.setContentsMargins(0, 0, 0, 0)
#         self.setLayout(main_layout)
# 
#         main_layout.addWidget(get_logo_widget(self, _('Edit Password')))
# 
#         pass_title = QLabel(_("Please type a new PASSWORD:"))
#         pass_title.setObjectName('itemtitle')
#         main_layout.addWidget(pass_title)
#         main_layout.setAlignment(pass_title, Qt.AlignCenter)
# 
#         pass_widget = QWidget()
#         pass_widget.setObjectName('dialog')
#         pass_layout = QVBoxLayout()
#         pass_widget.setLayout(pass_layout)
# 
#         self.pass_edit.setPlaceholderText(_('type password...'))
#         self.pass_edit.setEchoMode(QLineEdit.Password)
#         self.pass_edit.setFixedHeight(25)
#         pass_layout.addWidget(self.pass_edit)
# 
#         self.confirm_edit.setPlaceholderText(_('confirm password...'))
#         self.confirm_edit.setEchoMode(QLineEdit.Password)
#         self.confirm_edit.setFixedHeight(25)
#         pass_layout.addWidget(self.confirm_edit)
# 
#         self.help_label.setText(_("Your password must contain at least 5 characters."))
#         self.help_label.setWordWrap(True)
#         pass_layout.addWidget(self.help_label)
# 
#         # Accept button
#         accept_btn = QPushButton('Confirm', self)
#         accept_btn.clicked.connect(self.handle_confirm)
#         accept_btn.setObjectName('valid')
#         accept_btn.setMinimumHeight(30)
#         pass_layout.addWidget(accept_btn)
# 
#         main_layout.addWidget(pass_widget)
# 
#     def handle_confirm(self):
#         """
#         Handle accept_btn for password
# 
#         """
# 
#         if bool(self.pass_edit.text() == self.confirm_edit.text()) and \
#                 len(self.pass_edit.text()) > 4 and len(self.confirm_edit.text()) > 4:
#             self.accept()
#         else:
#             if bool(self.pass_edit.text() != self.confirm_edit.text()):
#                 self.help_label.setText(_("Passwords do not match !"))
#                 self.help_label.setStyleSheet("color: red;")
#             if len(self.pass_edit.text()) < 5 or len(self.confirm_edit.text()) < 5:
#                 self.help_label.setText(_("Your password must contain at least 5 characters."))
#                 self.help_label.setStyleSheet("color: orange;")


import sys
import unittest2
from PyQt5.QtWidgets import QApplication
from alignak_app.utils.config import settings
from alignak_app.locales.locales import init_localization
from alignak_app.qobjects.user.password import PasswordQDialog
    @classmethod
    def setUpClass(cls):
        """Create QApplication"""
        try:
            cls.app = QApplication(sys.argv)
        except:
            pass

    def test_about_dialog(self):
        """Initialize Password QDialog"""

        under_test = PasswordQDialog()

        self.assertIsNotNone(under_test.pass_edit)
        self.assertIsNotNone(under_test.confirm_edit)
        self.assertIsNotNone(under_test.help_label)

        under_test.initialize()

        self.assertIsNotNone(under_test.pass_edit)
        self.assertIsNotNone(under_test.confirm_edit)
        self.assertIsNotNone(under_test.help_label)
        self.assertEqual(
            'Your password must contain at least 5 characters.',
            under_test.help_label.text()
        )

    def test_handle_confirm(self):
        """Confirm Password"""


# 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/locales/locales.py
# def init_localization():  # pragma: no cover
#     """
#     Application localization
# 
#     :return: gettext translator method
#     :rtype: method
#     """
#     try:
#         # Language message file
#         lang_filename = os.path.join(
#             os.path.abspath(os.path.dirname(__file__)),
#             "LC_MESSAGES/%s.mo" % settings.get_config('Alignak-app', 'locale')
#         )
#         logger.info(
#             "Opening message file %s for locale %s",
#             lang_filename, settings.get_config('Alignak-app', 'locale')
#         )
#         translation = GNUTranslations(open(lang_filename, "rb"))
#         translation.install()
#         _ = translation.gettext
#     except IOError:
#         logger.warning("Locale not found. Using default language messages (English)")
#         null_translation = NullTranslations()
#         null_translation.install()
#         _ = null_translation.gettext
#     except Exception as e:  # pragma: no cover - should not happen
#         logger.error("Locale not found. Exception: %s", str(e))
#         null_translation = NullTranslations()
#         null_translation.install()
#         _ = null_translation.gettext
# 
#     return _
# 
# Path: alignak_app/qobjects/user/password.py
# class PasswordQDialog(QDialog):
#     """
#         Class who create PasswordDialog QDialog
#     """
# 
#     def __init__(self, parent=None):
#         super(PasswordQDialog, self).__init__(parent)
#         self.setWindowTitle('User Password')
#         self.setWindowFlags(Qt.FramelessWindowHint)
#         self.setStyleSheet(settings.css_style)
#         self.setWindowIcon(QIcon(settings.get_image('icon')))
#         self.setObjectName('dialog')
#         self.setFixedSize(300, 300)
#         # Fields
#         self.pass_edit = QLineEdit()
#         self.confirm_edit = QLineEdit()
#         self.help_label = QLabel()
# 
#     def initialize(self):
#         """
#         Initialize QDialog for PasswordDialog
# 
#         """
# 
#         center_widget(self)
# 
#         # Main status_layout
#         main_layout = QVBoxLayout(self)
#         main_layout.setContentsMargins(0, 0, 0, 0)
#         self.setLayout(main_layout)
# 
#         main_layout.addWidget(get_logo_widget(self, _('Edit Password')))
# 
#         pass_title = QLabel(_("Please type a new PASSWORD:"))
#         pass_title.setObjectName('itemtitle')
#         main_layout.addWidget(pass_title)
#         main_layout.setAlignment(pass_title, Qt.AlignCenter)
# 
#         pass_widget = QWidget()
#         pass_widget.setObjectName('dialog')
#         pass_layout = QVBoxLayout()
#         pass_widget.setLayout(pass_layout)
# 
#         self.pass_edit.setPlaceholderText(_('type password...'))
#         self.pass_edit.setEchoMode(QLineEdit.Password)
#         self.pass_edit.setFixedHeight(25)
#         pass_layout.addWidget(self.pass_edit)
# 
#         self.confirm_edit.setPlaceholderText(_('confirm password...'))
#         self.confirm_edit.setEchoMode(QLineEdit.Password)
#         self.confirm_edit.setFixedHeight(25)
#         pass_layout.addWidget(self.confirm_edit)
# 
#         self.help_label.setText(_("Your password must contain at least 5 characters."))
#         self.help_label.setWordWrap(True)
#         pass_layout.addWidget(self.help_label)
# 
#         # Accept button
#         accept_btn = QPushButton('Confirm', self)
#         accept_btn.clicked.connect(self.handle_confirm)
#         accept_btn.setObjectName('valid')
#         accept_btn.setMinimumHeight(30)
#         pass_layout.addWidget(accept_btn)
# 
#         main_layout.addWidget(pass_widget)
# 
#     def handle_confirm(self):
#         """
#         Handle accept_btn for password
# 
#         """
# 
#         if bool(self.pass_edit.text() == self.confirm_edit.text()) and \
#                 len(self.pass_edit.text()) > 4 and len(self.confirm_edit.text()) > 4:
#             self.accept()
#         else:
#             if bool(self.pass_edit.text() != self.confirm_edit.text()):
#                 self.help_label.setText(_("Passwords do not match !"))
#                 self.help_label.setStyleSheet("color: red;")
#             if len(self.pass_edit.text()) < 5 or len(self.confirm_edit.text()) < 5:
#                 self.help_label.setText(_("Your password must contain at least 5 characters."))
#                 self.help_label.setStyleSheet("color: orange;")


# Path: test/test_password_dialog.py
import sys
import unittest2
from PyQt5.QtWidgets import QApplication
from alignak_app.utils.config import settings
from alignak_app.locales.locales import init_localization
from alignak_app.qobjects.user.password import PasswordQDialog

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

    def test_about_dialog(self):
        """Initialize Password QDialog"""

        under_test = PasswordQDialog()

        self.assertIsNotNone(under_test.pass_edit)
        self.assertIsNotNone(under_test.confirm_edit)
        self.assertIsNotNone(under_test.help_label)

        under_test.initialize()

        self.assertIsNotNone(under_test.pass_edit)
        self.assertIsNotNone(under_test.confirm_edit)
        self.assertIsNotNone(under_test.help_label)
        self.assertEqual(
            'Your password must contain at least 5 characters.',
            under_test.help_label.text()
        )

    def test_handle_confirm(self):
        """Confirm Password"""


        under_test = PasswordQDialog()