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