예제 #1
0
    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])
예제 #2
0
    def testLoadCardList(self):
        """test that loading a test list of cards to an empty database works"""
        # cards_file has 5 cards (6 lines and a duplicate swamp)
        setup.update(cards_file)

        cards = setup.db(setup.db.Cards.id > 0).select()
        self.assertEqual(len(cards), 5)

        swamp = setup.db(setup.db.Cards.Name == "Swamp").select().first()
        self.assertEqual(swamp.Quantity, 2)

        # Ensure the rest are active w/ quantity 1
        for card in cards:
            if card.Name != "Swamp":
                self.assertEqual(card.Quantity, 1)
예제 #3
0
    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)
예제 #4
0
    def testUpdateCardList(self):
        """test that database is updated properly"""
        setup.update(cards_file)  # Tested via testLoadCardList
        setup.update(cards_file2)

        # cards_list2 should make the following changes against card_list:
        # - 1x Swamp
        # - 1x Faith's Fetters
        # + 1x Island
        cards = setup.db(setup.db.Cards.id > 0).select()

        ff = setup.db(setup.db.Cards.Name == "Faith's Fetters")
        self.assertEqual(ff.count(), 1)

        self.assertEqual(1, setup.db(setup.db.Cards.Name == "Swamp").select().first().Quantity)
        self.assertEqual(0, setup.db(setup.db.Cards.Name == "Faith's Fetters").select().first().Quantity)
        self.assertEqual(1, setup.db(setup.db.Cards.Name == "Island").select().first().Quantity)
예제 #5
0
    print(
        "An error ocurred while trying to get version locally and/or remotely")
    print("Wait...")
    time.sleep(2)
elif update["UPDATE_CODE"] != setup.UPDATE_NONE:
    # Update available
    if update['UPDATE_CODE'] == setup.UPDATE_MAJOR:
        print("There is a MAJOR update available")
    elif update['UPDATE_CODE'] == setup.UPDATE_MINOR:
        print("There is a MINOR update available")
    elif update['UPDATE_CODE'] == setup.UPDATE_PATCH_OR_BUG_FIX:
        print("There is a bug fix or patch update available")
    if input(
            f"""Would you like to update{f" from {update['LOCAL_VERSION']}" if update['LOCAL_VERSION'] else ""}{f" to {update['REMOTE_VERSION']}" if update['REMOTE_VERSION'] else ""}? [y/n]"""
    ).lower() == "y":
        setup.update()
        sys.exit(0)

# INIT
logger.debug("Init")

if __name__ == '__main__':
    try:
        from scripts import download, addEpisodes, updateLinks, settings, database, user

        logger.debug("Starting threads")
        threading.Thread(target=addEpisodes.run).start()
        threading.Thread(target=download.run).start()
        threading.Thread(target=updateLinks.run).start()
        user = threading.Thread(target=user.run)