Add tests
All checks were successful
Run Limnoria Plugin Tests / test (push) Successful in 32s

This commit is contained in:
Stanislas Daniel Claude Dolcini 2024-09-08 17:27:11 +03:00
parent f5722a96b4
commit 651940372e
Signed by: Stan
GPG Key ID: 244943DFF8370D60
2 changed files with 95 additions and 0 deletions

33
.gitea/workflows/test.yml Normal file
View File

@ -0,0 +1,33 @@
name: Run Limnoria Plugin Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the code from the repository
- name: Checkout code
run: |
mkdir -p plugins
git clone https://gitea.wildfiregames.com/${{ github.repository }} plugins/wfg --depth 1
# Step 2: Set up Python environment
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9' # Use the Python version you need
# Step 3: Install dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
cd plugins/wfg
pip install -r requirements.txt
cd ../../
# Step 4: Run tests
- name: Run Limnoria Plugin Tests
run: |
supybot-test -v --plugins-dir=plugins --no-network

62
test.py
View File

@ -29,9 +29,71 @@
###
from supybot.test import *
import supybot.ircmsgs as ircmsgs
class WFGTestCase(PluginTestCase):
plugins = ('wfg',)
config: dict[str, any] = {
'supybot.plugins.wfg': True,
'supybot.plugins.wfg.ticketUrl': "https://gitea.wildfiregames.com/0ad/0ad/issues/",
'supybot.plugins.wfg.channels': ["#test"],
}
def testTicketUrl(self):
obj = self.irc.getCallback('wfg')
obj.doPrivmsg(
self.irc,
ircmsgs.privmsg(self.config["supybot.plugins.wfg.channels"][0], "test")
)
count = 0
msg = self.irc.takeMsg()
while msg is not None:
msg = self.irc.takeMsg()
count += 1
self.assertEquals(count, 0)
obj.doPrivmsg(
self.irc,
ircmsgs.privmsg(self.config["supybot.plugins.wfg.channels"][0], "Sounds like #666")
)
count = 0
msg = self.irc.takeMsg()
while msg is not None:
self.assertEquals(msg.nick, "")
self.assertEquals(msg.args[0], self.config["supybot.plugins.wfg.channels"][0])
self.assertEquals(msg.args[1], "#666 - Remove Devil – https://gitea.wildfiregames.com/0ad/0ad/issues/666")
msg = self.irc.takeMsg()
count += 1
self.assertEquals(count, 1)
def testPullRequestUrl(self):
obj = self.irc.getCallback('wfg')
obj.doPrivmsg(
self.irc,
ircmsgs.privmsg(self.config["supybot.plugins.wfg.channels"][0], "test")
)
count = 0
msg = self.irc.takeMsg()
while msg is not None:
msg = self.irc.takeMsg()
count += 1
self.assertEquals(count, 0)
obj.doPrivmsg(
self.irc,
ircmsgs.privmsg(self.config["supybot.plugins.wfg.channels"][0], "Sounds like it's fixed by #7028")
)
count = 0
msg = self.irc.takeMsg()
while msg is not None:
self.assertEquals(msg.nick, "")
self.assertEquals(msg.args[0], self.config["supybot.plugins.wfg.channels"][0])
self.assertEquals(msg.args[1], "#7028 - Add yamllint to pre-commit – https://gitea.wildfiregames.com/0ad/0ad/pulls/7028")
msg = self.irc.takeMsg()
count += 1
self.assertEquals(count, 1)
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: