def testGetCoordinates(self): # should not crash for any input print 'Testing getCoordinates:' print '-Testing nonnumerical inputs...', nonnumCoords = Location() (nonnumCoords.longitude,nonnumCoords.latitude) = ('ha','ha') self.assertEqual(nonnumCoords.getCoordinates(), None) print 'Passed!' print '-Testing expected inputs...', correctCoords = Location() (correctCoords.longitude,correctCoords.latitude) = (34.4566,-118.9653) self.assertEqual(correctCoords.getCoordinates(), "(34.4566, -118.9653)") print 'Passed!' print 'All tests passed!'
def testIsRecent(self): print 'Testing isRecent:' now = timezone.now() print "-Testing past date...", pastLocation = Location() pastLocation.saveDate = now - datetime.timedelta(days=1) self.assertEqual(pastLocation.isRecent(), False) print "Passed!" print "-Testing recent date...", recentLocation = Location() recentLocation.saveDate = now - datetime.timedelta(hours=5) self.assertEqual(recentLocation.isRecent(), True) print "Passed!" print "-Testing future date...", futureLocation = Location() futureLocation.saveDate = now + datetime.timedelta(days=1) self.assertEqual(futureLocation.isRecent(), False) print "Passed!" print "All tests passed!"