From b07cf35e70e9204b4a630b5294151057585d1576 Mon Sep 17 00:00:00 2001 From: Lev Bernstein Date: Sun, 14 Jul 2024 12:36:37 -0400 Subject: [PATCH] 2.2.0: upgrade dependencies, fix tests --- Bot.py | 2 +- README.MD | 10 +++++++++- bb_test.py | 5 ++--- bucks.py | 10 ++++++++-- misc.py | 2 +- resources/requirements.txt | 16 ++++++++-------- 6 files changed, 29 insertions(+), 16 deletions(-) diff --git a/Bot.py b/Bot.py index cf471e3..81ebdfd 100644 --- a/Bot.py +++ b/Bot.py @@ -1,5 +1,5 @@ """ Beardless Bot """ -__version__ = "Full Release 2.1.8" +__version__ = "Full Release 2.2.0" import asyncio import logging diff --git a/README.MD b/README.MD index 8573573..c69fc2d 100644 --- a/README.MD +++ b/README.MD @@ -1,6 +1,6 @@ # Beardless Bot -### Full Release 2.1.8 ![Coverage badge](./resources/images/coverage.svg) +### Full Release 2.2.0 ![Coverage badge](./resources/images/coverage.svg) A Discord bot supporting gambling (coin flips and blackjack), a currency system, fun facts, and more. @@ -58,6 +58,14 @@ could use someone tackling them. Please make sure your code is PEP8 compliant (except for tabs), with a column limit of 80. +## Testing + +To run Beardless Bot's suite of unit tests, do `bash unitTests.sh`. This will +also generate a coverage badge.To run an individual test--for instance, the +PEP8 compliance test--use the pytest command, like so: +`pytest -v bb_test.py::test_pep8Compliance`. + + ## License This program is free software: you can redistribute it and/or modify diff --git a/bb_test.py b/bb_test.py index 3b66164..0507935 100644 --- a/bb_test.py +++ b/bb_test.py @@ -814,7 +814,6 @@ async def test_on_message_edit() -> None: assert emb.fields[1].value == ( f"{after.content}\n[Jump to Message]({after.jump_url})" ) - # testing for scamCheck == True after.content = "http://dizcort.com free nitro!" emb = await Bot.on_message_edit(before, after) assert any( @@ -1239,7 +1238,7 @@ def test_animal_with_goodUrl(animalName: str) -> None: def test_animal_dog_breed() -> None: breeds = misc.animal("dog", "breeds")[12:-1].split(", ") - assert len(breeds) == 98 + assert len(breeds) == 107 assert goodURL(requests.get(misc.animal("dog", choice(breeds)))) assert misc.animal("dog", "invalidbreed").startswith("Breed not") assert misc.animal("dog", "invalidbreed1234").startswith("Breed not") @@ -1341,7 +1340,7 @@ def test_getRank() -> None: "You haven't played ranked yet this season." ) brawl.claimProfile(196354892208537600, 12502880) - assert brawl.getRank(user, brawlKey).color.value == 0x3D2399 + assert brawl.getRank(user, brawlKey).color.value == 20916 brawl.claimProfile(196354892208537600, 7032472) diff --git a/bucks.py b/bucks.py index 8ca659c..da34d63 100644 --- a/bucks.py +++ b/bucks.py @@ -340,7 +340,10 @@ def balance( " (or enter their username), or do !balance without a" f" target to see your own balance, {msg.author.mention}." ) - if not isinstance(target, nextcord.User): + if not ( + isinstance(target, nextcord.User) + or isinstance(target, nextcord.Member) + ): target = memSearch(msg, target) if target: result, bonus = writeMoney(target, 300, False, False) @@ -393,7 +396,10 @@ def leaderboard( """ lbDict: Dict[str, int] = {} emb = bbEmbed("BeardlessBucks Leaderboard") - if target and msg and not isinstance(target, nextcord.User): + if (target and msg and not ( + isinstance(target, nextcord.User) + or isinstance(target, nextcord.Member) + )): target = memSearch(msg, target) if target: writeMoney(target, 300, False, False) diff --git a/misc.py b/misc.py index 90f9d5b..5cbef6f 100644 --- a/misc.py +++ b/misc.py @@ -206,7 +206,7 @@ def animal(animalType: str, breed: Optional[str] = None) -> str: return r.json()["url"] elif animalType == "bear": - return f"https://placebear.com/{randint(200, 400)}/{randint(200,400)}" + return f"https://placebear.com/{randint(200, 400)}/{randint(200, 400)}" elif animalType == "frog": frog = choice(frogList)["name"] diff --git a/resources/requirements.txt b/resources/requirements.txt index 66460ee..491a8e4 100644 --- a/resources/requirements.txt +++ b/resources/requirements.txt @@ -1,10 +1,10 @@ -bs4==0.0.1 -coverage==6.4.3 -flake8==4.0.1 +beautifulsoup4==4.12.3 +coverage==7.6.0 +flake8==7.1.0 genbadge[all]==1.1.1 nextcord==2.6.0 -pytest==8.2.0 -pytest-asyncio==0.23.6 -python-dotenv==0.19.2 -requests==2.28.1 -steam==1.2.0 +pytest==8.2.2 +pytest-asyncio==0.23.7 +python-dotenv==1.0.1 +requests==2.32.3 +steam==1.4.4