Exemple #1
0
    def test_add_points(self):
        twitchusername = "******"
        points = 1000
        channel = "TestChannel"
        dbconn = Db()
        dbconn.create_viewer(twitchusername, channel, -1)

        current_points = dbconn.get_points(twitchusername, channel)
        expected_points = current_points + points
        dbconn.add_points(twitchusername, channel, points)
        new_points_total = dbconn.get_points(twitchusername, channel)
        self.cleanup()

        self.assertEqual(expected_points, new_points_total)
Exemple #2
0
    def __init__(self, twitchusername, bet):

        # Create the connection the database and retrieve viewers current points
        con = Db()
        points = con.get_points(twitchusername)
        if points < bet:
            # This will be a twitch message when using an API
            logging.error("You do not have enough points to make this bet")
        else:
            logging.info("Running bet")
            number_rolled = random.randint(1, 100)
            if number_rolled <= 50:
                con.remove_points(twitchusername, bet)
                logging.info(twitchusername + " lost.")
            elif 51 <= number_rolled <= 95:
                con.add_points(twitchusername, bet)
                logging.info(twitchusername + " won.")
            else:
                big_win = bet * 1.5
                con.add_points(twitchusername, big_win)
                logging.info(twitchusername + " won the big one.")