def test_buildForm(self): """Test that we can build a form by passing it a function and params. """ myFunctionId = 'I T B Fatality Function Configurable' myFunctionList = get_plugins(myFunctionId) assert len(myFunctionList) == 1 assert myFunctionList[0].keys()[0] == myFunctionId myDialog = FunctionOptionsDialog(None) myParameters = { 'thresholds': [1.0], 'postprocessors': { 'Gender': { 'on': True }, 'Age': { 'on': True, 'params': { 'youth_ratio': 0.263, 'elder_ratio': 0.078, 'adult_ratio': 0.659 } } } } myDialog.buildForm(myParameters) assert myDialog.tabWidget.count() == 2 myChildren = myDialog.tabWidget.findChildren(QLineEdit) assert len(myChildren) == 4
def test_buildForm(self): """Test that we can build a form by passing it a function and params. """ myFunctionId = 'I T B Fatality Function Configurable' myFunctionList = get_plugins(myFunctionId) assert len(myFunctionList) == 1 assert myFunctionList[0].keys()[0] == myFunctionId myDialog = FunctionOptionsDialog(None) myParameters = { 'thresholds': [1.0], 'postprocessors': { 'Gender': {'on': True}, 'Age': { 'on': True, 'params': { 'youth_ratio': 0.263, 'elder_ratio': 0.078, 'adult_ratio': 0.659}}}} myDialog.buildForm(myParameters) assert myDialog.tabWidget.count() == 2 myChildren = myDialog.tabWidget.findChildren(QLineEdit) assert len(myChildren) == 4
def test_parseInput(self): myInput = { 'thresholds': lambda: [1.0], 'postprocessors': { 'Gender': {'on': lambda: True}, 'Age': { 'on': lambda: True, 'params': { 'youth_ratio': lambda: 0.263, 'elder_ratio': lambda: 0.078, 'adult_ratio': lambda: 0.659}}}} myDialog = FunctionOptionsDialog(None) myResult = myDialog.parseInput(myInput) print myResult assert myResult == OrderedDict([ ('thresholds', [1.0]), ('postprocessors', OrderedDict([ ('Gender', OrderedDict([('on', True)])), ('Age', OrderedDict([ ('on', True), ('params', OrderedDict([ ('youth_ratio', 0.263), ('elder_ratio', 0.078), ('adult_ratio', 0.659)]))]))]))])
def test_parseInput(self): myInput = { "thresholds": lambda: [1.0], "postprocessors": { "Gender": {"on": lambda: True}, "Age": { "on": lambda: True, "params": { "youth_ratio": lambda: 0.263, "elder_ratio": lambda: 0.078, "adult_ratio": lambda: 0.659, }, }, }, } myDialog = FunctionOptionsDialog(None) myResult = myDialog.parseInput(myInput) assert myResult == { "thresholds": [1.0], "postprocessors": { "Gender": {"on": True}, "Age": {"on": True, "params": {"youth_ratio": 0.263, "elder_ratio": 0.078, "adult_ratio": 0.659}}, }, }
def test_buildForm(self): """Test that we can build a form by passing it a function and params. """ myFunctionId = "I T B Fatality Function Configurable" myFunctionList = get_plugins(myFunctionId) assert len(myFunctionList) == 1 assert myFunctionList[0].keys()[0] == myFunctionId myFunction = myFunctionList[0] myDialog = FunctionOptionsDialog(None) myParameters = {"foo": "bar"} myDialog.buildForm(myFunction, myParameters) # myKids = myDialog.findChildren(QLineEdit) # for myKid in myKids: # print myKid.objectName() myWidget = myDialog.findChild(QLineEdit, "fooLineEdit") assert myWidget is not None assert myWidget.text() == "bar"
def test_buildWidget(self): myDialog = FunctionOptionsDialog(None) myValue = myDialog.buildWidget(myDialog.configLayout, 'foo', [2.3]) myWidget = myDialog.findChild(QLineEdit) # initial value must be same with default assert myValue() == [2.3] # change to 5.9 myWidget.setText('5.9') assert myValue() == [5.9] myWidget.setText('5.9, 70') assert myValue() == [5.9, 70] myWidget.setText('bar') try: myValue() except ValueError: ## expected to raises this exception pass else: raise Exception("Fail: must be raise an exception")
def test_buildForm(self): """Test that we can build a form by passing it a function and params. """ myFunctionId = "I T B Fatality Function Configurable" myFunctionList = get_plugins(myFunctionId) assert len(myFunctionList) == 1 assert myFunctionList[0].keys()[0] == myFunctionId myDialog = FunctionOptionsDialog(None) myParameters = { "thresholds": [1.0], "postprocessors": { "Gender": {"on": True}, "Age": {"on": True, "params": {"youth_ratio": 0.263, "elder_ratio": 0.078, "adult_ratio": 0.659}}, }, } myDialog.buildForm(myParameters) assert myDialog.tabWidget.count() == 2 myChildren = myDialog.tabWidget.findChildren(QLineEdit) assert len(myChildren) == 4
def test_parseInput(self): myInput = { 'thresholds': lambda: [1.0], 'postprocessors': { 'Gender': { 'on': lambda: True }, 'Age': { 'on': lambda: True, 'params': { 'youth_ratio': lambda: 0.263, 'elder_ratio': lambda: 0.078, 'adult_ratio': lambda: 0.659 } } } } myDialog = FunctionOptionsDialog(None) myResult = myDialog.parseInput(myInput) assert myResult == { 'thresholds': [1.0], 'postprocessors': { 'Gender': { 'on': True }, 'Age': { 'on': True, 'params': { 'youth_ratio': 0.263, 'elder_ratio': 0.078, 'adult_ratio': 0.659 } } } }