Skip to content

Commit

Permalink
Fixed testsgit status!
Browse files Browse the repository at this point in the history
  • Loading branch information
jwgerlach00 committed Nov 28, 2023
1 parent ceb48dd commit 499bb41
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 44 deletions.
17 changes: 8 additions & 9 deletions cogs/grades.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,18 +776,17 @@ async def add_grade_category(self, ctx, categoryname: str, weight: str):
if existing:
await ctx.author.send("This category has already been added..!!")
return

current_weight_sum = float(
db.query(
"""SELECT SUM(category_weight)

current_weight_sum = db.query(
"""SELECT SUM(category_weight)
FROM grade_categories
WHERE guild_id = %s""",
(ctx.guild.id,),
)[0][0]
)
if current_weight_sum + categoryweight > 1:
(ctx.guild.id,),
)[0][0]

if current_weight_sum is not None and float(current_weight_sum) + categoryweight > 1 :
await ctx.author.send(
"This category weight would make the total weight less than 1..!!"
"This category weight would make the total weight more than 1..!!"
)
return

Expand Down
2 changes: 1 addition & 1 deletion cogs/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ async def join(self, ctx, group_num: int):
await member.add_roles(role)

await ctx.send(
f"You are now in Group {group_num}! There are now {group_count[0][0] + 1}/ {max_members} members."
f"You are now in Group {group_num}! There are now {group_count[0][0] + 1}/{max_members} members."
)

# -------------------------------------------------------------------------------------------------------
Expand Down
57 changes: 23 additions & 34 deletions test/test_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,14 @@ async def test_ping(bot):
# Tests cogs/groups.py
# ---------------------
@pytest.mark.asyncio
async def test_groupJoin(bot):
async def test_groupJoin(bot):
# first leave all groups just in case in any
await dpytest.message("$leave")
dpytest.get_message()

# Try to join a group
await dpytest.message("$join 99")
assert (
dpytest.verify()
.message()
.content("You are now in Group 99! There are now 1/6 members.")
)
assert dpytest.verify().message().content("You are now in Group 99! There are now 1/6 members.")

# try to join a different group
await dpytest.message("$join 1")
Expand All @@ -71,9 +67,9 @@ async def test_groupJoin(bot):
await dpytest.message("$connect")


# ------------------------------------
# Tests cogs/groups.py error handling
# ------------------------------------
# # ------------------------------------
# # Tests cogs/groups.py error handling
# # ------------------------------------
@pytest.mark.asyncio
async def test_groupError(bot):
# Try to join a group that doesn't exist
Expand All @@ -83,7 +79,8 @@ async def test_groupError(bot):
dpytest.verify()
.message()
.content(
"To use the join command, do: $join <Num> where 0 <= <Num> <= 99 \n ( For example: $join 0 )"
"To use the join command, do: $join <Num> "
"where 0 <= <Num> <= total groups$ \n ( For example: $join 0 )"
)
)

Expand Down Expand Up @@ -121,6 +118,12 @@ async def test_assignments(bot):
.message()
.content("A grading category has been added for: Project with weight: 0.7 ")
)
await dpytest.message("$addgradecategory Test 0.1")
assert (
dpytest.verify()
.message()
.content("This category weight would make the total weight more than 1..!!")
)
##Adding Assignments
# Test adding a valid assignment with new category
await dpytest.message("$addassignment HW1 Homework 30")
Expand Down Expand Up @@ -302,13 +305,9 @@ async def test_gradesStudent(bot):
await dpytest.message("$gradebycategory Homework")
assert dpytest.verify().message().content("Grade for Homework: 25.00%")
await dpytest.message("$gradeforclass")
assert dpytest.verify().message().content("Grade for class: 7.50%")
assert dpytest.verify().message().content("Grade for class: 25.00%")
await dpytest.message("$graderequired Homework 50 30")
assert (
dpytest.verify()
.message()
.content("Grade on next assignment needed to keep 30% in Homework: 33.00%")
)
assert dpytest.verify().message().content('Grade on next assignment needed to keep 30% in Homework: 33.00%')
await dpytest.message("$graderequiredforclass Homework 50 60")
assert (
dpytest.verify()
Expand Down Expand Up @@ -375,7 +374,8 @@ async def test_gradesStudentError(bot):
dpytest.verify()
.message()
.content(
"To use the gradebycategory command, do: $gradebycategory <categoryname>\n ( For example: $gradebycategory tests )"
"To use the gradebycategory command, do: $gradebycategory <categoryname>\n" +
"( For example: $gradebycategory tests )"
)
)
await dpytest.message("$gradebycategory FakeCat")
Expand Down Expand Up @@ -432,22 +432,13 @@ async def test_gradesInstructor(bot):
.message()
.content("A grading category has been added for: Exams with weight: 0.7 ")
)
await dpytest.message("$addgradecategory Projects 0.5")
assert (
dpytest.verify()
.message()
.content("A grading category has been added for: Projects with weight: 0.5 ")
)
await dpytest.message("$deletegradecategory Projects")
assert dpytest.verify().message().content("Projects category has been deleted ")
await dpytest.message("$deletegradecategory Exams")
assert dpytest.verify().message().content("Exams category has been deleted ")
await dpytest.message("$addgradecategory Exams 0.7") # add back
dpytest.get_message()
await dpytest.message("$addassignment Midterm1 Exams 100")
assert (
dpytest.verify()
.message()
.content(
"A grading assignment has been added for: Midterm1 with points: 100 and category: Exams"
)
)
assert dpytest.verify().message().contains().content("A grading assignment has been added for: Midterm1 with points: 100 and category: Exams")

await dpytest.message("$addassignment HW1 Homework 10")
assert (
dpytest.verify()
Expand Down Expand Up @@ -718,8 +709,6 @@ async def test_listreminders(bot):
.content("All reminders have been cleared..!!")
)

# Tests cogs/deadline.py


# ------------------------------
# Tests reminders due this week
Expand Down

0 comments on commit 499bb41

Please sign in to comment.