def testTransactionWrite(self): """Test that transactions can be written to the db correctly.""" setup.update(cards_file) draft.db = setup.db trans = {"Swamp": (23.2, 6.55), "Faith's Fetters": (11.9, 4.33)} draft.write_updated_ratings(trans) ratings = draft.get_current_ratings() for card in trans: self.assertEqual(trans[card], ratings[card])
def testNewCardRatings(self): """test that cards with no transactions can be loaded from the db""" setup.update(cards_file) # Tested via testLoadCardList setup.update(cards_file2) # Tested via testUpdateCardList ratings = draft.get_current_ratings() # Do get all active cards (Qty != 0) self.assertEqual(len(ratings), 5) # Do not get any inactive cards (Qty == 0) self.assertTrue("Faith's Fetters" not in ratings) # No transactions yet; check that all mu,sigma are (25.0,25.0/3) for entry in ratings.values(): self.assertAlmostEqual(entry[0], 25.0) self.assertAlmostEqual(entry[1], 25.0 / 3)