示例#1
0
文件: test_model.py 项目: F3DS/f3ds
 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)
示例#2
0
文件: test_model.py 项目: F3DS/f3ds
 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)