Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
e122e1e
Add 500 lines full of mocks
ItsDrike Aug 6, 2021
9a14d42
Add async mock spec for webhook features
ItsDrike Aug 6, 2021
3f3bcfc
Define certain attributes of Bot in __init__
ItsDrike Aug 8, 2021
584b74c
Remove irrelevant context attribute
ItsDrike Aug 8, 2021
4fb1b65
Add README for unit testing
ItsDrike Aug 8, 2021
0309a08
Remove trailing whitespaces
ItsDrike Aug 8, 2021
c1ff2fe
Cleanup testing async functions section
ItsDrike Aug 8, 2021
0f05d0b
Support MockTextChannel.edit async function
ItsDrike Aug 8, 2021
acbe7ca
Use single-line docstrings
ItsDrike Aug 8, 2021
a1af47d
Add pytest and pytest-cov dev dependencies
ItsDrike Aug 8, 2021
9ee37a9
Add taskipy tasks for tests
ItsDrike Aug 8, 2021
318ae10
Document use of pytest
ItsDrike Aug 8, 2021
3ef8d9c
Improve taskipy test aliases
ItsDrike Aug 8, 2021
dcdff13
Document running coverage and viewing reports
ItsDrike Aug 8, 2021
78aec18
Add basic slowmode cog tests
ItsDrike Aug 8, 2021
cf45cf5
Rename lint workflow to validation and add tests
ItsDrike Aug 8, 2021
6358ca5
Don't track coverage in .cache
ItsDrike Aug 8, 2021
451953f
Only include bot as coverage pkg and tests source
ItsDrike Aug 8, 2021
2c64973
Add coveralls.io reporting
ItsDrike Aug 8, 2021
ddce1a0
Add coveralls dev dependency
ItsDrike Aug 8, 2021
06e5850
Rename validate job to validation
ItsDrike Aug 8, 2021
59adb04
Specify coveralls service as github
ItsDrike Aug 8, 2021
8af299a
Add coverage badge, reorder badges
ItsDrike Aug 8, 2021
4e7dcd2
Fix log message typo
ItsDrike Aug 8, 2021
c22d6ef
Move user mock above member
ItsDrike Aug 8, 2021
fe43b1d
Include guild attr for MockMember by default
ItsDrike Aug 8, 2021
6c3680a
Handle overwrites separately and include @everyone
ItsDrike Aug 8, 2021
4890737
Fix multiple mocks (missing class parents)
ItsDrike Aug 8, 2021
03b775f
Apply discord.mixins.Hashable to hashable mocks
ItsDrike Aug 8, 2021
39b27c8
Make overwrites optional for MockTextChannel
ItsDrike Aug 8, 2021
54a9dac
Include cog_check test
ItsDrike Aug 8, 2021
8471b0d
Update workflow name in comment
ItsDrike Aug 8, 2021
7604e84
Ignore bot.run line in coverage reports
ItsDrike Aug 8, 2021
fee36c9
Also test slowmode removed message
ItsDrike Aug 8, 2021
958e889
Add tests for FilePaste cog
ItsDrike Aug 8, 2021
7c91768
Fix import order
ItsDrike Aug 8, 2021
c4f1a1c
Add additional tests for FilePaste cog
ItsDrike Aug 8, 2021
b1345cd
Add sudo cog_check test
ItsDrike Aug 8, 2021
912d740
Add error handler tests
ItsDrike Aug 8, 2021
62aec8f
Add tests for error embed sending functions
ItsDrike Aug 8, 2021
90e8be5
Fix import order
ItsDrike Aug 8, 2021
641d1f1
Handle for unset JSONDecodeError.lines attribute
ItsDrike Aug 8, 2021
15059b6
Use x >= y instead of x > y - 1
ItsDrike Aug 8, 2021
8bdecac
Add tests for strikes cog
ItsDrike Aug 10, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/status_embed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Status Embed
on:
workflow_run:
workflows:
- Lint
- Validation
types:
- completed

Expand All @@ -15,7 +15,7 @@ jobs:
steps:
# A workflow_run event does not contain all the information
# we need for a PR embed. That's why we upload an artifact
# with that information in the Lint workflow.
# with that information in the Validation workflow.
- name: Get Pull Request Information
id: pr_info
if: github.event.workflow_run.event == 'pull_request'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Lint
name: Validation

on:
push:
Expand All @@ -20,8 +20,8 @@ env:
PRE_COMMIT_HOME: ${{ github.workspace }}/.cache/pre-commit-cache

jobs:
lint:
name: Lint
validation:
name: Validation
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -80,6 +80,17 @@ jobs:
[flake8] %(code)s: %(text)s' \
--extend-exclude '.cache'"

# Run all of the unit tests and generate coverage report with
# coverage.py
- name: Run tests and generate coverage report
run: pytest --cov --disable-warnings -q

# Publish test coverage report to coveralls.io, print a
# "job" link in the output of the GitHub Action
- name: Publish coverage report to coveralls.io
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: coveralls --service=github

# Prepare the Pull Request Payload artifact. If this fails, we
# we fail silently using the `continue-on-error` option. It's
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Neutron Bot

[![mit](https://img.shields.io/badge/Licensed%20under-GPL-red.svg?style=flat-square)](./LICENSE)
![Python package](https://github.com/Codin-Nerds/Neutron-Bot/workflows/Python%20package/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/Codin-Nerds/Neutron-Bot/badge.svg?branch=main)](https://coveralls.io/github/Codin-Nerds/Neutron-Bot?branch=main)
[![made-with-python](https://img.shields.io/badge/Made%20with-Python%203.9-ffe900.svg?longCache=true&style=flat-square&colorB=00a1ff&logo=python&logoColor=88889e)](https://www.python.org/)
[![license](https://img.shields.io/badge/Licensed%20under-GPL-red.svg?style=flat-square)](./LICENSE)
[![Discord](https://img.shields.io/static/v1?label=The%20Codin'%20Nerds&logo=discord&message=%3E600%20members&color=%237289DA&logoColor=white)](https://discord.gg/Dhz9pM7)

## About the bot
Expand Down
2 changes: 1 addition & 1 deletion bot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@


if __name__ == "__main__":
bot.run(config.TOKEN)
bot.run(config.TOKEN) # pragma: no cover
2 changes: 1 addition & 1 deletion bot/cogs/core/error_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ async def handle_json_decode_error(self, ctx: Context, exception: JSONDecodeErro
The error occurred on *`line {exception.lineno} column {exception.colno} (char {exception.pos})`*
"""
)
if exception.lines:
if hasattr(exception, "lines") and len(exception.lines) >= exception.lineno:
msg += textwrap.dedent(
f"""
```
Expand Down
2 changes: 1 addition & 1 deletion bot/cogs/moderation/slowmode.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async def slow_mode(self, ctx: Context, duration: Duration) -> None:
await ctx.channel.edit(slowmode_delay=duration)

if duration:
log_msg = f"ser {ctx.author} applied slowmode to #{ctx.channel} for {stringify_duration(duration)}"
log_msg = f"User {ctx.author} applied slowmode to #{ctx.channel} for {stringify_duration(duration)}"
msg = f"⏱️ Applied slowmode for this channel, time delay: {stringify_duration(duration)}."
else:
log_msg = f"User {ctx.author} removed slowmode from #{ctx.channel}"
Expand Down
6 changes: 6 additions & 0 deletions bot/core/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ def __init__(self, *args, **kwargs) -> None:
self.initial_call = True
self._ignored_logs = defaultdict(set)

# These attributes will be set later, once the bot starts up
# they can't be set here, because they need asyncio's event loop
# however we still want to define them here to provide type hints
self.http_session: t.Optional[aiohttp.ClientSession] = None
self.db_engine: t.Optional[AsyncEngine] = None

async def load_extensions(self) -> None:
"""Load all listed cogs."""
for extension in autoload.EXTENSIONS:
Expand Down
Loading