def setUp(self): with \ Autowired('DataTestData', self),\ Autowired('AiTestData', self),\ Autowired('UpdateTestData', self),\ MockedService('PrepareDataService', self),\ MockedService('NeuralNetBuilderService', self),\ MockedService('NeuralNetTrainerService', self),\ MockedService('AccuracyCheckService', self),\ MockedService('UpdateService', self): categorizerService.call()
def setUp(self): with \ Autowired('UpdateTestData', self),\ Autowired('DbTestData', self),\ MockedService('RowUpdateService', self),\ MockedService('ConnectionService', self),\ MockedService('CategoryService', self): updateService.call(self.UpdateTestData.data) self.handleOneRowArgs = self.RowUpdateService.call
def runTest(self, choice): with \ MockedService('UpdateDBService', self),\ MockedService('RowProviderService', self),\ MockedService('TransactionDisplayService', self),\ MockedService('OptionPreparatorService', self),\ MockedService('ChoiceObtainerService', self): self.ChoiceObtainerStubs.answerIs(choice) rowUpdateService.call(self.UpdateTestData.rowNumber, self.UpdateTestData.data, self.DbTestData.connection, self.UpdateTestData.categories)
def setUp(self): with\ Autowired('DataTestData',self),\ MockedService('NumericConverterService', self): self.result = prepareDataService.call( self.DataTestData.TRAIN_SET, self.DataTestData.PROBLEM_SET) self.callList = self.NumericConverterService.call.mock_calls
def testdisplayTransaction_prints_the_transaction(self): with\ Autowired('DbTestData', self),\ MockedService('sys.stdout') as mockedStdout: transactionDisplayService.call(self.DbTestData.fetched_row) TestHelper.assertPrintedOn(mockedStdout, self.DbTestData.fetched_row)
def test_MockedService_does_not_leave_foreign_service_in_registry(self): with MockedService('sys.stderr', self): sys.stderr.write("hello") self.assertFalse('sys.stderr' in providers)
def test_MockedService_unmocks_foreign_stuff_after_use(self): with MockedService('sys.stderr', self): sys.stderr.write("hello") sys.stderr.write("hello") self.sys_stderr.write.assert_called_once()
def test_MockedService_runs_the_behaviour_only_if_stubs_exist_for_the_service( self): with MockedService('ExampleNonstubbedService', self): pass
def setUp(self): with\ Autowired('DataTestData', self),\ MockedService('keras.Sequential') as self.model: self.result = neuralNetBuilderService().call(self.DataTestData.MAX_LENGTH, self.DataTestData.OUTPUT_NEURONS ) self.firstCallList = TestHelper.callArgument(self.model, 0)
def test_MockedService_changes_the_original_service(self): with MockedService('TheExampleService') as TheExampleService: TheExampleServiceCreatedBeforeMock().foo() TheExampleService.foo.assert_called_once()
def runTestWithAccuracy(self, accuracy): with\ MockedService('DisplayAccuracyService', self),\ MockedService('AccuracyErrorDisplayService', self),\ unittest.mock.patch('sys.exit') as self.sysExit: accuracyCheckService.call(accuracy)
def it_displays_the_transaction(self): with\ Autowired('UiTestData', self),\ MockedService('sys.stdout') as mockedStdout: accuracyErrorDisplayService.displayAccurracyError() TestHelper.assertPrintedOn(mockedStdout, self.UiTestData.ACCURACY_ERROR_MESSAGE)
def setUp(self): with MockedService('WinterBootTestData', self): self.serviceId = self.WinterBootTestData.undefinedConsumedServiceId self.testArtifact = Autowired(self.serviceId) self.TheExampleServiceClassName = 'TheExampleService'
def runTest(self, choice): with MockedService('ChoiceAskService', self): self.ChoiceAskStubs.answerIs(choice) choice = choiceObtainerService.call(self.options) return choice
def test_MockedService_can_patch_foreign_service(self): with MockedService('sys.stdin', self): self.assertEqual("foo", sys.stdin.readline())
def setUp(self): with\ Autowired('UpdateTestData', self, singleton=False),\ MockedService('OptionDisplayService', self): self.result = optionPreparatorService.call( self.UpdateTestData.rowNumber, self.UpdateTestData.data, self.UpdateTestData.categories)
def setUp(self): with\ Autowired('UiTestData', self),\ MockedService('categorizerai.ui.ChoiceAskService.input') as self.mockedInput: self.answer = choiceAskService.call()
def test_MockedService_adds_field_to_instance_if_asked(self): with MockedService('TheExampleService', self): TheExampleServiceCreatedBeforeMock().bar() self.TheExampleService.bar.assert_called_once()
def test_MockedService_can_mock_foreign_stuff(self): with MockedService('sys.stderr', self): sys.stderr.write("hello") self.sys_stderr.write.assert_called_once()
def test_MockedService_runs_the_behaviour_of_the_stub_of_the_related_service( self): with MockedService('TheExampleService', self): self.assertEqual('get:foo', self.TheExampleService.method('foo'))