summaryrefslogtreecommitdiff
path: root/src/leap/gui/firstrun/wizard.py
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-12-05 23:50:08 +0900
committerkali <kali@leap.se>2012-12-12 04:27:50 +0900
commit490cde9c33039c2c5b16d929d6f8bb8e8f06f430 (patch)
tree2f03c228e674569e0bdb74e088b487c9b3aaa19b /src/leap/gui/firstrun/wizard.py
parent01116d8725eaa74f8f3581248198b5d0ec1577dd (diff)
tests for firstrun/wizard
Diffstat (limited to 'src/leap/gui/firstrun/wizard.py')
-rwxr-xr-xsrc/leap/gui/firstrun/wizard.py56
1 files changed, 37 insertions, 19 deletions
diff --git a/src/leap/gui/firstrun/wizard.py b/src/leap/gui/firstrun/wizard.py
index 9b77b877..bd3fe903 100755
--- a/src/leap/gui/firstrun/wizard.py
+++ b/src/leap/gui/firstrun/wizard.py
@@ -2,8 +2,11 @@
import logging
import sip
-sip.setapi('QString', 2)
-sip.setapi('QVariant', 2)
+try:
+ sip.setapi('QString', 2)
+ sip.setapi('QVariant', 2)
+except ValueError:
+ pass
from PyQt4 import QtCore
from PyQt4 import QtGui
@@ -146,6 +149,10 @@ class FirstRunWizard(QtGui.QWizard):
# TODO: set style for MAC / windows ...
#self.setWizardStyle()
+ #
+ # setup pages in wizard
+ #
+
def add_pages_from_dict(self, pages_dict):
"""
@param pages_dict: the dictionary with pages, where
@@ -168,6 +175,10 @@ class FirstRunWizard(QtGui.QWizard):
"""
return self.pages_dict.keys().index(page_name)
+ #
+ # validation errors
+ #
+
def set_validation_error(self, pagename, error):
self.validation_errors[pagename] = error
@@ -179,20 +190,6 @@ class FirstRunWizard(QtGui.QWizard):
def get_validation_error(self, pagename):
return self.validation_errors.get(pagename, None)
- def set_providerconfig(self, providerconfig):
- self.providerconfig = providerconfig
-
- def setWindowFlags(self, flags):
- logger.debug('setting window flags')
- QtGui.QWizard.setWindowFlags(self, flags)
-
- def focusOutEvent(self, event):
- # needed ?
- self.setFocus(True)
- self.activateWindow()
- self.raise_()
- self.show()
-
def accept(self):
"""
final step in the wizard.
@@ -246,11 +243,14 @@ class FirstRunWizard(QtGui.QWizard):
if cb and callable(cb):
self.success_cb()
- def get_provider_by_index(self):
- provider = self.field('provider_index')
- return self.providers[provider]
+ # misc helpers
def get_random_str(self, n):
+ """
+ returns a random string
+ :param n: the length of the desired string
+ :rvalue: str
+ """
from string import (ascii_uppercase, ascii_lowercase, digits)
from random import choice
return ''.join(choice(
@@ -258,6 +258,24 @@ class FirstRunWizard(QtGui.QWizard):
ascii_lowercase +
digits) for x in range(n))
+ def set_providerconfig(self, providerconfig):
+ """
+ sets a providerconfig attribute
+ used when we fetch and parse a json configuration
+ """
+ self.providerconfig = providerconfig
+
+ def get_provider_by_index(self): # pragma: no cover
+ """
+ returns the value of a provider given its index.
+ this was used in the select provider page,
+ in the case where we were preseeding providers in a combobox
+ """
+ # Leaving it here for the moment when we go back at the
+ # option of preseeding with known provider values.
+ provider = self.field('provider_index')
+ return self.providers[provider]
+
if __name__ == '__main__':
# standalone test