コード例 #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)