def test_getListOfTopCrashersBySignature(self): lastweek = self.now.date() - datetime.timedelta(days=7) params = self.params params.startDate = self.now.date() - datetime.timedelta(days=8) res = tcbs.getListOfTopCrashersBySignature( self.connection, self.params ) sig_1 = res.next() sig_2 = res.next() eq_(sig_1[0], "Fake Signature #1") eq_(sig_2[0], "Fake Signature #2") eq_(sig_1[8].date(), lastweek) eq_(sig_2[8].date(), lastweek) eq_(sig_1[10], 0.58333333333333304) eq_(sig_2[10], 0.41666666666666702) assert_raises(StopIteration, res.next) # Test if raises ValueError when are passed wrong parameters params.product = None assert_raises( BadArgumentError, tcbs.getListOfTopCrashersBySignature, self.connection, params )
def test_getListOfTopCrashersBySignature(self): cursor = self.connection.cursor() lastweek = self.now.date() - datetime.timedelta(days=7) params = self.params params.startDate = self.now.date() - datetime.timedelta(days=8) res = tcbs.getListOfTopCrashersBySignature(cursor, self.params) sig_1 = res.next() sig_2 = res.next() self.assertEqual(sig_1[0], "Fake Signature #1") self.assertEqual(sig_2[0], "Fake Signature #2") self.assertEqual(sig_1[8].date(), lastweek) self.assertEqual(sig_2[8].date(), lastweek) self.assertEqual(sig_1[10], 0.58333333333333304) self.assertEqual(sig_2[10], 0.41666666666666702) self.assertRaises(StopIteration, res.next) # Test if raises ValueError when are passed wrong parameters params.product = None self.assertRaises(ValueError, tcbs.getListOfTopCrashersBySignature, cursor, params)