def test_humanize_sort(): collection.remove( {} ) memo1 = "This is memo1" date1 = arrow.utcnow().to('local') isoDate1 = date1.isoformat() record = { "type": "dated_memo", "date": isoDate1, "text": memo1 } collection.insert(record) memo2 = "This is memo2" date2 = date1.replace(days=-1).isoformat() record = { "type": "dated_memo", "date": date2, "text": memo2 } collection.insert(record) memo3 = "This is memo2" date3 = date1.replace(days=1).isoformat() record = { "type": "dated_memo", "date": date3, "text": memo3 } collection.insert(record) memos = get_memos() assert humanize_arrow_date(memos[0]['date']) == "Yesterday" assert humanize_arrow_date(memos[0]['text']) == "This is memo2" #just to show sorting assert humanize_arrow_date(memos[1]['date']) == "Today" assert humanize_arrow_date(memos[2]['date']) == "Tomorrow"
def test_humanize_sort(): collection.remove({}) memo1 = "This is memo1" date1 = arrow.utcnow().to('local') isoDate1 = date1.isoformat() record = {"type": "dated_memo", "date": isoDate1, "text": memo1} collection.insert(record) memo2 = "This is memo2" date2 = date1.replace(days=-1).isoformat() record = {"type": "dated_memo", "date": date2, "text": memo2} collection.insert(record) memo3 = "This is memo2" date3 = date1.replace(days=1).isoformat() record = {"type": "dated_memo", "date": date3, "text": memo3} collection.insert(record) memos = get_memos() assert humanize_arrow_date(memos[0]['date']) == "Yesterday" assert humanize_arrow_date( memos[0]['text']) == "This is memo2" #just to show sorting assert humanize_arrow_date(memos[1]['date']) == "Today" assert humanize_arrow_date(memos[2]['date']) == "Tomorrow"
def test_humanize_arrow_date(): """ Testing Humanize """ curDateTime = arrow.utcnow().to('local') assert humanize_arrow_date(curDateTime) == "Today" assert humanize_arrow_date(curDateTime.replace(days=+1)) == "Tomorrow" assert humanize_arrow_date(curDateTime.replace(days=-1)) == "Yesterday"
def test_auto(): """ tests if a bunch of dates are humanized """ assert humanize_arrow_date(tomm.replace(hours=+24)) == "Day after tomorrow" assert humanize_arrow_date(tomm.replace(hours=+48)) == "in {} days".format(3) for i in range(0,month,day): assert humanize_arrow_date(tomm.replace(hours=+(48+i))) == "in {} days".format((int(i/day)+3))
def test_dates(): """ Tests if the datetimes are humanized correctly """ assert (flask_main.humanize_arrow_date( arrow.utcnow().to('local').naive) == "Today") assert (flask_main.humanize_arrow_date( arrow.utcnow().to('local').replace(days=+7).naive) == "in 7 days") assert (flask_main.humanize_arrow_date( arrow.utcnow().to('local').replace(years=+1).naive) == "in a year") assert (flask_main.humanize_arrow_date( arrow.utcnow().to('local').replace(days=-1).naive) == 'Yesterday')
def test_warped(): """ This tests a warped version of humanize_arrow_date used to get correct output in the webpage Today should be seen as tomorrow Yesterday should be seen as today The day before Yesterday should be seen as yesterday """ today = arrow.utcnow().to('local') assert (humanize_arrow_date(today.isoformat()) == 'Tomorrow') yesterday = today.replace(days=-1) assert (humanize_arrow_date(yesterday.isoformat()) == 'Today') before_yesterday = yesterday.replace(days=-1) assert (humanize_arrow_date(before_yesterday.isoformat()) == 'Yesterday')
def test_warped(): """ This tests a warped version of humanize_arrow_date used to get correct output in the webpage Today should be seen as tomorrow Yesterday should be seen as today The day before Yesterday should be seen as yesterday """ today = arrow.utcnow().to('local') assert (humanize_arrow_date(today.isoformat())=='Tomorrow') yesterday = today.replace(days =-1) assert (humanize_arrow_date(yesterday.isoformat())=='Today') before_yesterday = yesterday.replace(days=-1) assert(humanize_arrow_date(before_yesterday.isoformat())=='Yesterday')
def testHumanizingDate(self): #Testing today case test_date = arrow.utcnow().replace(hour=0, minute=0, second=0, microsecond=0) self.assertEqual(flask_main.humanize_arrow_date(test_date), "Today") #Testing yesterday case self.assertEqual(flask_main.humanize_arrow_date(test_date.replace(days=-1)), "Yesterday") #Testing 2 days ago case self.assertEqual(flask_main.humanize_arrow_date(test_date.replace(days=-2)), "2 days ago") #Testing tomorrow case test_date = test_date.replace(days=+1) self.assertEqual(flask_main.humanize_arrow_date(test_date), "Tomorrow") #Testing other day cases up to where arrow defines it as a month for h in range(2, 24): test_date = test_date.replace(days=+1) self.assertEqual(flask_main.humanize_arrow_date(test_date), "in {} days".format(h))
def test_humanize_arrow_date(): """ Confirm that humanization won't be wonky (as long as the user is in the Pacific time zone) """ today = arrow.now('US/Pacific').replace(hour=0, minute=0, second=0) days = {-1: "Yesterday", 0: "Today", 1: "Tomorrow"} for day in range(-1, 2): for hour in range(0, 24): test_date = today.replace(days=+day).replace(hours=+hour) print("Days: {} Hours: {}".format(day, hour)) result = flask_main.humanize_arrow_date(test_date.isoformat()) print(result) assert result == days[day]
def test_humanize(): """ Make sure times are humanized correctly """ today = arrow.now() assert flask_main.humanize_arrow_date( today.replace(years=-1).date()) == 'a year ago' assert flask_main.humanize_arrow_date( today.replace(months=-1).date()) == 'a month ago' assert flask_main.humanize_arrow_date( today.replace(days=-2).date()) == '2 days ago' assert flask_main.humanize_arrow_date( today.replace(days=-1).date()) == 'yesterday' assert flask_main.humanize_arrow_date(today.date()) == 'today' assert flask_main.humanize_arrow_date( today.replace(days=+1).date()) == 'tomorrow' assert flask_main.humanize_arrow_date( today.replace(days=+2).date()) == 'in 2 days' assert flask_main.humanize_arrow_date( today.replace(months=+1).date()) == 'in a month' assert flask_main.humanize_arrow_date( today.replace(years=+1).date()) == 'in a year'
def test_yesterday(): today = arrow.utcnow().to('local') assert (humanize_arrow_date(today.isoformat()) != 'Yesterday') yesterday = today.replace(days=-1)
def test_yesterday(): today = arrow.utcnow().to('local') assert (humanize_arrow_date(today.isoformat())!='Yesterday') yesterday = today.replace(days =-1)
def test_human(): """ tests if dates are humanized """ assert humanize_arrow_date(tomm) == "Tomorrow" assert humanize_arrow_date(yest) == "Yesterday"