Skip to content

Commit

Permalink
misc: Add GHA CI, Fix source unit tests (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kissaki authored Mar 15, 2024
2 parents 6683a61 + 3c6a8ba commit 92aa673
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Python
on: [push]
jobs:
LintAndTest:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pylint pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Analysing the code with pylint
if: false
run: |
pylint $(git ls-files '*.py')
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
11 changes: 6 additions & 5 deletions modules/source/source_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

import config
from . import source
from .users import User


class InvalidChannelExceptionMock(Exception):
Expand Down Expand Up @@ -191,19 +192,19 @@ def setUp(self):
self.mm = ManagerMock();
self.mserv = self.mm.meta.getServer(1)

testconfig = config.Config(None, source.source.default_config)
testconfig = config.Config(None, source.default_config)
testconfig.source.database = ":memory:"

# As it is hard to create the read only config structure from
# hand use a spare one to steal from
spare = config.Config(None, source.source.default_config)
spare = config.Config(None, source.default_config)
testconfig.__dict__['game:tf'] = spare.generic
testconfig.__dict__['game:tf'].name = "Team Fortress 2"
testconfig.__dict__['game:tf'].teams = ["Lobby", "Spectator", "Blue", "Red"]
testconfig.__dict__['game:tf'].serverregex = re.compile("^\[A-1:123\]$")
testconfig.__dict__['game:tf'].servername = "Test %(game)s %(server)s"

self.s = source.source("source", self.mm, testconfig)
self.s = source("source", self.mm, testconfig)
self.mm.s = self.s

# Since we don't want to run threaded if we don't have to
Expand Down Expand Up @@ -232,7 +233,7 @@ def testDefaultConfig(self):

mm = ManagerMock()
INVALIDFORCEDEFAULT = ""
s = source.source("source", mm, INVALIDFORCEDEFAULT)
s = source("source", mm, INVALIDFORCEDEFAULT)
self.assertNotEqual(s.cfg(), None)

def testConfiguration(self):
Expand Down Expand Up @@ -412,7 +413,7 @@ def testMoveUser(self):
TEAM_RED_SID = prev + 3
TEAM_BLUE_SID = prev + 4

user = source.User(user_state, {'team': TEAM_BLUE}, "tf", "[A-1:123]")
user = User(user_state, {'team': TEAM_BLUE}, "tf", "[A-1:123]")
self.s.moveUser(self.mserv, user)
c = mumble_server.channels
self.assertEqual(c[prev + 1].parent, BASE_SID)
Expand Down

0 comments on commit 92aa673

Please sign in to comment.