def testParsing(self):
     users = UsersList(self._file.path())
     staand = users.get("staand")
     stamax = users.get("stamax")
     chess_master = users.get("chess_master")
     dsz = users.get("dsz")
     none = users.get("any_other")
     self.assertNotEqual(staand, None, "'staand' user is 'None'")
     self.assertNotEqual(stamax, None, "'stamax' user is 'None'")
     self.assertNotEqual(chess_master, None, "'chess_master' user is 'None'")
     self.assertNotEqual(dsz, None, "'dsz' user is 'None'")
     self.assertEqual(none, None, "'none' user is NOT 'None'")
     self.assertTrue(staand.login() == "staand" and staand.password() == "081194", "'staand' attributes error")
     self.assertTrue(chess_master.login() == "chess_master" and chess_master.password() == "chess", "'chess_master' attributes error")
     self.assertTrue(stamax.login() == "stamax" and stamax.password() == "314159", "'stamax' attributes error")
     self.assertTrue(dsz.login() == "dsz" and dsz.password() == "dsz", "'dsz' attributes error")
     rights = staand.rights()
     self.assertTrue(rights.fieldsModifyingPermited() and rights.rowsAddingPermited() and rights.rowsRemovingPermited(), 
                     "'staand' rights error")
     rights = stamax.rights()
     self.assertFalse(rights.fieldsModifyingPermited() or rights.rowsAddingPermited() or rights.rowsRemovingPermited(), 
                     "'stamax' rights error")
     rights = chess_master.rights()
     self.assertTrue(rights.fieldsModifyingPermited() and rights.rowsAddingPermited() and not rights.rowsRemovingPermited(), 
                     "'chess_master' rights error")
     rights = dsz.rights()
     self.assertTrue(not rights.fieldsModifyingPermited() and not rights.rowsAddingPermited() and rights.rowsRemovingPermited(), 
                     "'dsz' rights error")
class LoginDialog(QtGui.QDialog):
    """
        Log-in dialog class
    """
    def __init__(self, loginsFilePath):
        """
            Default constructor.
            'loginsFilePath' - path to the file with users data
        """
        QtGui.QDialog.__init__(self)
        self._ui = Ui_loginDialog()
        self._ui.setupUi(self)
        self._usersList = UsersList(loginsFilePath)
        QtCore.QObject.connect(self._ui.okButton, QtCore.SIGNAL("clicked()"), self.okButtonClicked)
        QtCore.QObject.connect(self._ui.cancelButton, QtCore.SIGNAL("clicked()"), self.cancelButtonClicked)
        QtCore.QObject.connect(self, QtCore.SIGNAL("rejected()"), self.cancelButtonClicked)
        
    
    def okButtonClicked(self):
        """
            A slot for OK button "clicked()" signal
        """
        login = self._ui.loginEdit.text()
        password = self._ui.passwordEdit.text()
        user = self._usersList.get(login)
        if user == None or password != user.password():
            QtGui.QMessageBox.about(self, "Error...", "No such login-password pair was found!")
        else:
            self.hide()
            self.emit(QtCore.SIGNAL("userLoggedIn(QObject)"), user)
       
    
    def cancelButtonClicked(self):
        """
            A slot for CANCEL button "clicked()" signal
        """
        self.hide()
        self.emit(QtCore.SIGNAL("userLoggedIn(QObject)"), User("", ""))