From 426906cadbf50f8d969804589797b013e0f84850 Mon Sep 17 00:00:00 2001 From: Eric Ihli Date: Sun, 23 Apr 2023 15:56:47 -0700 Subject: [PATCH] Format with black and remove unused imports --- lottery_data_scraper/california.py | 8 +++++--- tests/test_california.py | 15 +++++++++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lottery_data_scraper/california.py b/lottery_data_scraper/california.py index aeb7027..468308f 100644 --- a/lottery_data_scraper/california.py +++ b/lottery_data_scraper/california.py @@ -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] diff --git a/tests/test_california.py b/tests/test_california.py index d757fd0..b4ec1e9 100644 --- a/tests/test_california.py +++ b/tests/test_california.py @@ -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.", + )