def testUsefulnessNoHitsAttribute(self): 'Test that accessing usefulness gives correct result when hits is missing.' slfile = ScanLogFile(self.owner, url=self.url, location=self.location) slfile.date = datetime.utcnow() # .now() is used in property. expected = 0.0 actual = slfile.usefulness self.assertEqual(expected, actual)
def testUsefulness(self): 'Test that accessing usefulness gives correct result. Fails every DST change.' slfile = ScanLogFile(self.owner, url=self.url, location=self.location, siginfo=self.siginfo) now = datetime.now() utcnow = datetime.utcnow() seconds_diff = utcnow - now slfile.hits = abs(seconds_diff.total_seconds() * 10) slfile.date = utcnow actual = slfile.usefulness expected = 10.0 self.assertAlmostEqual(expected, actual, places=5)