本文整理汇总了Python中Controller.Controller.do_select_rec方法的典型用法代码示例。如果您正苦于以下问题:Python Controller.do_select_rec方法的具体用法?Python Controller.do_select_rec怎么用?Python Controller.do_select_rec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Controller.Controller
的用法示例。
在下文中一共展示了Controller.do_select_rec方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_SelectedRecord_EditIncome
# 需要导入模块: from Controller import Controller [as 别名]
# 或者: from Controller.Controller import do_select_rec [as 别名]
def test_SelectedRecord_EditIncome(self):
"""
A RecordCollection with one Record will be provided to Controller
- Random ID, male, default attributes
- Randomise an income
- Methodology for picking a new income will be
(original sales + 1) % 1000
"""
theRC = self._getRecordColl_OneMaleRecord_RandomID()
theRecord = theRC.getAllRecords()[0]
theID = theRecord.getID()
theRecord.setIncome(random.randrange(1000))
originalIncome = theRecord.getIncome()
newIncome = (originalIncome + 1) % 1000 # 1000 is income limit
theController = Controller(TestView.TestView(), theRC)
# From here the record will be manipulated via theController
# Successful calls will represent the record via show message
expected_1 = self._getRecordStateMessage(theID, income=originalIncome)
expected_2 = self._getRecordStateMessage(theID, income=newIncome)
# Call 1, selecting the record. 3 show messages
expectedList = [TestObjectSelectionClass._expRecordHeader, expected_1,
TestObjectSelectionClass._expRecordFunctions]
TestView.clearLog()
theController.do_select_rec(theID)
self.assertEqual(expectedList, TestView.theLog)
# Call 2, editing the income. 3 show messages
expectedList[1] = expected_2
TestView.clearLog()
theController.do_edit_income(newIncome)
self.assertEqual(expectedList, TestView.theLog)
示例2: test_SelectedRecord_EditBMI
# 需要导入模块: from Controller import Controller [as 别名]
# 或者: from Controller.Controller import do_select_rec [as 别名]
def test_SelectedRecord_EditBMI(self):
"""
A RecordCollection with one Record will be provided to Controller
- Random ID, male, default attributes
- New BMI will be Overweight
"""
theRC = self._getRecordColl_OneMaleRecord_RandomID()
theRecord = theRC.getAllRecords()[0]
theID = theRecord.getID()
newBMI = "Overweight"
theController = Controller(TestView.TestView(), theRC)
# From here the record will be manipulated via theController
# Successful calls will represent the record via show message
expected_1 = self._getRecordStateMessage(theID)
expected_2 = self._getRecordStateMessage(theID, bmi=newBMI)
# Call 1, selecting the record. 3 show messages
expectedList = [TestObjectSelectionClass._expRecordHeader, expected_1,
TestObjectSelectionClass._expRecordFunctions]
TestView.clearLog()
theController.do_select_rec(theID)
self.assertEqual(expectedList, TestView.theLog)
# Call 2, editing the BMI. 3 show messages
expectedList[1] = expected_2
TestView.clearLog()
theController.do_edit_bmi(newBMI)
self.assertEqual(expectedList, TestView.theLog)
示例3: test_DoesNotSelectRecord
# 需要导入模块: from Controller import Controller [as 别名]
# 或者: from Controller.Controller import do_select_rec [as 别名]
def test_DoesNotSelectRecord(self):
"""
To successfully select a record, the correct ID must be provided
- No correct ID provided would expect an alternative show message
"""
expected = "There is no record with that ID\n"
incorrectID = ""
theController = Controller(TestView.TestView(), None)
TestView.clearLog()
# Call
theController.do_select_rec(incorrectID)
self.assertEqual(expected, TestView.theLog[0])
示例4: test_ControllerNeutralState
# 需要导入模块: from Controller import Controller [as 别名]
# 或者: from Controller.Controller import do_select_rec [as 别名]
def test_ControllerNeutralState(self):
"""
Concerned with the show output on command
> neutral
Concerned with no record/option selected
"""
# Start Controller with RecordCollection, with 1 record
theRC, testID = self._getRecordColl_OneMaleRecord_RandomID()
theController = Controller(TestView.TestView(), theRC)
# Call 1, do neutral. Expect number of records to be 1
expected_1 = "Records in ERP: 1"
TestView.clearLog()
theController.do_neutral("")
actual_1 = TestView.theLog[0]
self.assertEqual(expected_1, actual_1)
# Call 2, 3. Select the record.
# Then go neutral and no record is selected
expected_2 = "Selected Record"
TestView.clearLog()
theController.do_select_rec(testID)
actual_2 = TestView.theLog[0]
self.assertEqual(expected_2, actual_2)
theController.do_neutral("")
expected_3 = "No record selected"
TestView.clearLog()
theController.do_edit_age("")
actual_3 = TestView.theLog[0]
self.assertEqual(expected_3, actual_3)
# Call 4, 5. Select the option.
# Then go neutral and no option is selected
expected_4 = "Selected Option"
TestView.clearLog()
theController.do_select_option("autoid")
actual_4 = TestView.theLog[0]
self.assertEqual(expected_4, actual_4)
theController.do_neutral("")
expected_5 = "No option selected"
TestView.clearLog()
theController.do_on("")
actual_5 = TestView.theLog[0]
self.assertEqual(expected_5, actual_5)
示例5: test_ControllerExit_ReturnTrue_Condition
# 需要导入模块: from Controller import Controller [as 别名]
# 或者: from Controller.Controller import do_select_rec [as 别名]
def test_ControllerExit_ReturnTrue_Condition(self):
"""
Concerned with the show ouput on command
> exit
if a record/option is selected
Otherwise that method returns True
"""
neutralStr = "Records in ERP: 1"
# Start Controller with RecordCollection, with 1 record
theRC, testID = self._getRecordColl_OneMaleRecord_RandomID()
theController = Controller(TestView.TestView(), theRC)
TestView.clearLog()
expected_1 = "Selected Record"
expected_2 = neutralStr
# Call 1. Select record, then exit
theController.do_select_rec(testID)
actual_1 = TestView.theLog[0]
TestView.clearLog()
theReturn = theController.do_exit("")
actual_2 = TestView.theLog[0]
self.assertEqual(expected_1, actual_1)
self.assertEqual(expected_2, actual_2)
self.assertNotEqual(True, theReturn)
TestView.clearLog()
expected_3 = "Selected Option"
expected_4 = neutralStr
# Call 2. Select option, then exit
theController.do_select_option("autoid")
actual_3 = TestView.theLog[0]
TestView.clearLog()
theReturn = theController.do_exit("")
actual_4 = TestView.theLog[0]
self.assertEqual(expected_3, actual_3)
self.assertEqual(expected_4, actual_4)
self.assertNotEqual(True, theReturn)
# Different outcome when Controller in neutral state
TestView.clearLog()
expected_5 = "END"
theReturn = theController.do_exit("")
actual_5 = TestView.theLog[0]
self.assertEqual(expected_5, actual_5)
self.assertTrue(theReturn)
示例6: test_NoOptionSelected
# 需要导入模块: from Controller import Controller [as 别名]
# 或者: from Controller.Controller import do_select_rec [as 别名]
def test_NoOptionSelected(self):
"""
This can be asserted by attempting to select a record
- Regardless if the attempt works or not, one expected outcome is that
no option will be selected
"""
theController = Controller(TestView.TestView(), None)
theController.do_select_rec("")
# For the method calls below, the main flow requires an option to be
# selected, therefore the alternative show message is expected
expectedMessage = "No option selected"
TestView.clearLog()
theController.do_on("")
theController.do_off("")
# 2 calls
self.assertEqual(2, len(TestView.theLog))
for actualMessage in TestView.theLog:
self.assertEqual(expectedMessage, actualMessage)