Format with black and remove unused imports

main
Eric Ihli 1 year ago
parent db49b62a46
commit 426906cadb

@ -2,7 +2,6 @@ import locale
import logging
import json
import operator
import requests
import html2text
from lottery_data_scraper.schemas import GameSchema
@ -12,7 +11,7 @@ from lottery_data_scraper.util import fetch_html
# because California only gives prize values and our schema
# expects a string representation of the prize.
# https://docs.python.org/3/library/locale.html
locale.setlocale(locale.LC_ALL, 'en_US.utf8')
locale.setlocale(locale.LC_ALL, "en_US.utf8")
logger = logging.getLogger(__name__)
h = html2text.HTML2Text()
@ -20,6 +19,7 @@ h = html2text.HTML2Text()
BASE_URL = "https://www.calottery.com"
SCRATCHER_URL = "https://www.calottery.com/api/games/scratchers"
def num_tx_initial(game):
grand_prize = game["topPrizeTier"]
return grand_prize["odds"] * grand_prize["totalNumberOfPrizes"]
@ -35,7 +35,9 @@ def fetch_games():
"available": prize_["numberOfPrizesPending"],
"claimed": prize_["numberOfPrizesCashed"],
"value": prize_["value"],
"prize": locale.currency(prize_["value"], grouping=True)[:-3] # -3 to drop the cents
"prize": locale.currency(prize_["value"], grouping=True)[
:-3
], # -3 to drop the cents
}
prizes.append(prize)
grand_prize = sorted(game_["prizeTiers"], key=operator.itemgetter("value"))[-1]

@ -2,11 +2,18 @@ import json
import subprocess
import unittest
from lottery_data_scraper.util import fetch_html
class TestCalifornia(unittest.TestCase):
def test_all(self):
result = subprocess.run(["python3", "-m", "lottery_data_scraper.california"], capture_output=True)
result = subprocess.run(
["python3", "-m", "lottery_data_scraper.california"], capture_output=True
)
data = json.loads(result.stdout)
self.assertEqual(data[0]["game_id"], "1405", "Expected the first game to be PAC-MAN, #1405.")
self.assertEqual(data[0]["num_tx_initial"], 37080000, "Expected 37,080,000 tickets for PAC-MAN #1405.")
self.assertEqual(
data[0]["game_id"], "1405", "Expected the first game to be PAC-MAN, #1405."
)
self.assertEqual(
data[0]["num_tx_initial"],
37080000,
"Expected 37,080,000 tickets for PAC-MAN #1405.",
)

Loading…
Cancel
Save