def testExecuteHistoricalPriceNoYear(self): testDayStr = '1' testMonthStr = '1' testHourStr = '01' testMinuteStr = '15' testTimeZoneStr = 'Europe/Zurich' self.commandPrice.parsedParmData[self.commandPrice.CRYPTO] = 'btc' self.commandPrice.parsedParmData[self.commandPrice.FIAT] = 'usd' self.commandPrice.parsedParmData[ self.commandPrice.EXCHANGE] = 'bittrex' self.commandPrice.parsedParmData[self.commandPrice.DAY] = testDayStr self.commandPrice.parsedParmData[ self.commandPrice.MONTH] = testMonthStr #self.commandPrice.parsedParmData[self.commandPrice.YEAR] = '2017' self.commandPrice.parsedParmData[self.commandPrice.HOUR] = testHourStr self.commandPrice.parsedParmData[ self.commandPrice.MINUTE] = testMinuteStr resultData = self.commandPrice.execute() now = DateTimeUtil.localNow(testTimeZoneStr) fourDigitYear = now.year nowYear = fourDigitYear - 2000 nowYearStr = str(nowYear) testDateTime = DateTimeUtil.dateTimeComponentsToArrowLocalDate( int(testDayStr), int(testMonthStr), fourDigitYear, int(testHourStr), int(testMinuteStr), 0, testTimeZoneStr) self.assertEqual(resultData.getValue(resultData.RESULT_KEY_ERROR_MSG), None) self.assertEqual(resultData.getValue(resultData.RESULT_KEY_CRYPTO), 'BTC') self.assertEqual(resultData.getValue(resultData.RESULT_KEY_FIAT), 'USD') self.assertEqual(resultData.getValue(resultData.RESULT_KEY_EXCHANGE), 'BitTrex') if DateTimeUtil.isDateOlderThan(testDateTime, 7): self.assertEqual( resultData.getValue(resultData.RESULT_KEY_PRICE_TYPE), resultData.PRICE_TYPE_HISTO_DAY) self.assertEqual( resultData.getValue( resultData.RESULT_KEY_PRICE_DATE_TIME_STRING), '01/01/{} 00:00'.format(nowYearStr)) else: self.assertEqual( resultData.getValue(resultData.RESULT_KEY_PRICE_TYPE), resultData.PRICE_TYPE_HISTO_MINUTE) self.assertEqual( resultData.getValue( resultData.RESULT_KEY_PRICE_DATE_TIME_STRING), '01/01/{} {}:{}'.format(nowYearStr, testHourStr, testMinuteStr))
def testIsDateOlderThanSevenDaysMinusOneSecond(self): DAYS_BEFORE = 7 SECOND_BEFORE = 1 dateBefore = arrow.utcnow().shift(days = -DAYS_BEFORE, seconds = SECOND_BEFORE).to('Europe/Zurich') self.assertFalse(DateTimeUtil.isDateOlderThan(dateBefore, DAYS_BEFORE))
def testIsDateOlderThanSevenDays(self): DAYS_BEFORE = 7 dateBefore = arrow.utcnow().shift(days = -DAYS_BEFORE).to('Europe/Zurich') self.assertFalse(DateTimeUtil.isDateOlderThan(dateBefore, DAYS_BEFORE))