def setUpClass(self): Logger.pushLogData("unitTesting", __name__) forceWorkingDirectory() pyswing.globals.potentialRuleMatches = None pyswing.globals.equityCount = None pyswing.database.overrideDatabase("output/TestDatabase.db") pyswing.constants.pySwingStartDate = datetime.datetime(2015, 1, 1) deleteFile(pyswing.database.pySwingDatabase) deleteFile(pyswing.database.pySwingTestDatabase) args = "-n %s" % ("unitTesting") createDatabase(args.split()) pretendDate = datetime.datetime(2015, 7, 1) with patch.object(Equity, '_getTodaysDate', return_value=pretendDate) as mock_method: args = "-n unitTest".split() importData(args) args = "-n unitTest".split() updateIndicators(args) args = "-n unitTest".split() evaluateRules(args) args = "-n unitTest".split() analyseRules(args) args = "-n unitTest".split() calculateExitValues(args)
def test_CalculateExitValues(self): pretendDate = datetime.datetime(2015, 6, 1) with patch.object(Equity, '_getTodaysDate', return_value=pretendDate) as mock_method: args = "-n unitTest".split() importData(args) args = "-n unitTest".split() calculateExitValues(args) rowCount = self._countRows("Exit TrailingStop3.0 RiskRatio2") self.assertEqual(rowCount, 606)