mirror of
https://github.com/craigerl/aprsd.git
synced 2024-12-18 07:36:34 -05:00
Added pre-commit hooks
This patch adds pre-commit hook support to ensure code passes basic checks prior to allowing a commit.
This commit is contained in:
parent
8bd8b95b35
commit
75f610d971
18
.pre-commit-config.yaml
Normal file
18
.pre-commit-config.yaml
Normal file
@ -0,0 +1,18 @@
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v3.2.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
- id: end-of-file-fixer
|
||||
- id: check-yaml
|
||||
- id: check-added-large-files
|
||||
- repo: https://github.com/psf/black
|
||||
rev: 19.3b0
|
||||
hooks:
|
||||
- id: black
|
||||
|
||||
- repo: https://gitlab.com/pycqa/flake8
|
||||
rev: 3.8.1
|
||||
hooks:
|
||||
- id: flake8
|
||||
additional_dependencies: [flake8-bugbear]
|
@ -4,6 +4,8 @@ CHANGES
|
||||
v1.5.0
|
||||
------
|
||||
|
||||
* Added pre-commit hooks
|
||||
* Update Changelog for v1.5.0
|
||||
* Added QueryPlugin resend all delayed msgs or Flush
|
||||
* Added QueryPlugin
|
||||
* Added support to save/load MsgTrack on exit/start
|
||||
|
@ -414,4 +414,3 @@ Provide a csv list of pypi installable plugins. Then make sure the plugin
|
||||
python file is in your /plugins volume and the plugin will be installed at
|
||||
container startup. The plugin may have dependencies that are required.
|
||||
The plugin file should be copied to /plugins for loading by aprsd
|
||||
|
||||
|
@ -383,10 +383,7 @@ def server(loglevel, quiet, disable_validation, config_file, flush):
|
||||
|
||||
rx_msg_queue = queue.Queue(maxsize=20)
|
||||
tx_msg_queue = queue.Queue(maxsize=20)
|
||||
msg_queues = {
|
||||
"rx": rx_msg_queue,
|
||||
"tx": tx_msg_queue,
|
||||
}
|
||||
msg_queues = {"rx": rx_msg_queue, "tx": tx_msg_queue}
|
||||
|
||||
rx_thread = threads.APRSDRXThread(msg_queues=msg_queues, config=config)
|
||||
tx_thread = threads.APRSDTXThread(msg_queues=msg_queues, config=config)
|
||||
|
@ -217,10 +217,7 @@ class TextMessage(Message):
|
||||
def __repr__(self):
|
||||
"""Build raw string to send over the air."""
|
||||
return "{}>APRS::{}:{}{{{}\n".format(
|
||||
self.fromcall,
|
||||
self.tocall.ljust(9),
|
||||
self._filter_for_send(),
|
||||
str(self.id),
|
||||
self.fromcall, self.tocall.ljust(9), self._filter_for_send(), str(self.id)
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
|
@ -70,7 +70,7 @@ class PluginManager(object):
|
||||
|
||||
self.obj_list = []
|
||||
|
||||
for path, subdirs, files in os.walk(dir_path):
|
||||
for path, _subdirs, files in os.walk(dir_path):
|
||||
for name in files:
|
||||
if fnmatch.fnmatch(name, pattern):
|
||||
LOG.debug("MODULE? '{}' '{}'".format(name, path))
|
||||
|
@ -2,8 +2,6 @@
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import pytest
|
||||
|
||||
from aprsd import email
|
||||
|
||||
if sys.version_info >= (3, 2):
|
||||
@ -12,7 +10,7 @@ else:
|
||||
import mock
|
||||
|
||||
|
||||
class testMain(unittest.TestCase):
|
||||
class TestMain(unittest.TestCase):
|
||||
@mock.patch("aprsd.email._imap_connect")
|
||||
@mock.patch("aprsd.email._smtp_connect")
|
||||
def test_validate_email(self, imap_mock, smtp_mock):
|
||||
|
@ -1,16 +1,13 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import sys
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
import aprsd
|
||||
from aprsd import plugin
|
||||
from aprsd.fuzzyclock import fuzzy
|
||||
|
||||
|
||||
class testPlugin(unittest.TestCase):
|
||||
class TestPlugin(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.fromcall = "KFART"
|
||||
self.ack = 1
|
||||
@ -41,11 +38,11 @@ class testPlugin(unittest.TestCase):
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
@mock.patch("time.localtime")
|
||||
def test_Time(self, mock_time):
|
||||
def test_time(self, mock_time):
|
||||
fake_time = mock.MagicMock()
|
||||
h = fake_time.tm_hour = 16
|
||||
m = fake_time.tm_min = 12
|
||||
s = fake_time.tm_sec = 55
|
||||
fake_time.tm_sec = 55
|
||||
mock_time.return_value = fake_time
|
||||
time_plugin = plugin.TimePlugin(self.config)
|
||||
|
||||
@ -66,7 +63,7 @@ class testPlugin(unittest.TestCase):
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
@mock.patch("time.localtime")
|
||||
def test_Ping(self, mock_time):
|
||||
def test_ping(self, mock_time):
|
||||
fake_time = mock.MagicMock()
|
||||
h = fake_time.tm_hour = 16
|
||||
m = fake_time.tm_min = 12
|
||||
|
4
tox.ini
4
tox.ini
@ -28,7 +28,7 @@ commands = sphinx-build -b html docs/source docs/html
|
||||
|
||||
[testenv:pep8]
|
||||
commands =
|
||||
flake8 {posargs} aprsd
|
||||
flake8 {posargs} aprsd tests
|
||||
|
||||
[testenv:fast8]
|
||||
basepython = python3
|
||||
@ -43,7 +43,7 @@ skip_install = true
|
||||
deps =
|
||||
-r{toxinidir}/dev-requirements.txt
|
||||
commands =
|
||||
flake8 aprsd
|
||||
flake8 aprsd tests
|
||||
|
||||
[flake8]
|
||||
max-line-length = 99
|
||||
|
Loading…
Reference in New Issue
Block a user