-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* pass flake8 * add linting * pass foxylint
- Loading branch information
Showing
127 changed files
with
890 additions
and
605 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Enforce Conventions | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
linters-and-formatters: | ||
runs-on: ubuntu-latest | ||
environment: prod | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python 3.12 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.12' | ||
|
||
- name: Enforce Conventions | ||
uses: pre-commit/action@v3.0.1 | ||
with: | ||
extra_args: | ||
--all-files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name: Publish | ||
on: | ||
workflow_dispatch: | ||
jobs: | ||
jobs: | ||
publish: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# See https://pre-commit.com for more information | ||
# See https://pre-commit.com/hooks.html for more hooks | ||
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 | ||
exclude: template.yml | ||
- repo: https://github.com/psf/black | ||
rev: 23.12.1 | ||
hooks: | ||
- id: black | ||
args: | ||
- --line-length=150 | ||
- --target-version=py311 | ||
- --skip-string-normalization | ||
- repo: https://github.com/PyCQA/flake8 | ||
rev: 7.0.0 | ||
hooks: | ||
- id: flake8 | ||
args: | ||
- --ignore=E203,E501,E266,F541,W503,F405 | ||
- "--exclude=docs/*" | ||
- repo: https://github.com/python-jsonschema/check-jsonschema | ||
rev: 0.28.3 | ||
hooks: | ||
- id: check-github-workflows | ||
args: [ "--verbose" ] | ||
- repo: https://github.com/PracticeFoxyCode/practice | ||
rev: releases/1.0.0 | ||
hooks: | ||
- id: foxylint-imports | ||
args: | ||
- "--accept=/from testix.*import/" | ||
- "--accept=/from examples import/" | ||
- "--accept=/from unittest.*import/" | ||
- "--exclude=./testix/__init__.py" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,38 @@ | ||
import pytest | ||
from unittest.mock import patch | ||
import unittest.mock | ||
from unittest.mock import Mock, call | ||
import socket | ||
import chatbot.chatbot | ||
import chatbot.responder | ||
|
||
|
||
class TestChatbot: | ||
def construct(self, sock, Responder): | ||
self.tested = chatbot.chatbot.Chatbot( sock ) | ||
self.tested = chatbot.chatbot.Chatbot(sock) | ||
Responder.assert_called_once_with() | ||
|
||
@patch('chatbot.responder.Responder') | ||
@unittest.mock.patch('chatbot.responder.Responder') | ||
def test_construction(self, Responder): | ||
sock = Mock() | ||
self.construct(sock, Responder) | ||
|
||
@patch('chatbot.responder.Responder') | ||
@unittest.mock.patch('chatbot.responder.Responder') | ||
def test_request_response_loop(self, Responder): | ||
sock = Mock() | ||
responder = Mock() | ||
Responder.side_effect = [ responder ] | ||
Responder.side_effect = [responder] | ||
self.construct(sock, Responder) | ||
class EndTestException(Exception): pass | ||
|
||
class EndTestException(Exception): | ||
pass | ||
|
||
REQUESTS = [f'request {i}' for i in range(10)] | ||
RESPONSES = [f'response {i}' for i in range(10)] | ||
responder.process.side_effect = RESPONSES | ||
sock.recv.side_effect = REQUESTS + [EndTestException] | ||
|
||
with pytest.raises(EndTestException): | ||
self.tested.go() | ||
|
||
sock.recv.assert_has_calls( [ call(4096) ] * 10 ) | ||
responder.process.assert_has_calls( [ call(request) for request in REQUESTS ] ) | ||
sock.send.assert_has_calls( [ call( response ) for response in RESPONSES ] ) | ||
sock.recv.assert_has_calls([call(4096)] * 10) | ||
responder.process.assert_has_calls([call(request) for request in REQUESTS]) | ||
sock.send.assert_has_calls([call(response) for response in RESPONSES]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,3 @@ def test_send_and_receive_messages(): | |
|
||
assert alice_messages == ['hi Alice'] | ||
assert bob_messages == ['hi Bob'] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
import pty | ||
import select | ||
|
||
|
||
class LineMonitor: | ||
def __init__(self): | ||
self._callback = None | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
import pty | ||
import select | ||
|
||
|
||
class LineMonitor: | ||
def __init__(self): | ||
self._callback = None | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
import pty | ||
import select | ||
|
||
|
||
class LineMonitor: | ||
def __init__(self): | ||
self._callback = None | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
import pty | ||
import select | ||
|
||
|
||
class LineMonitor: | ||
def __init__(self): | ||
self._callback = None | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
import pty | ||
import select | ||
|
||
|
||
class LineMonitor: | ||
def __init__(self): | ||
self._callback = None | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import subprocess | ||
import pty | ||
|
||
|
||
class LineMonitor: | ||
def register_callback(self, callback): | ||
pass | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
import pty | ||
import select | ||
|
||
|
||
class LineMonitor: | ||
def __init__(self): | ||
self._callback = None | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
import pty | ||
import select | ||
|
||
|
||
class LineMonitor: | ||
def __init__(self): | ||
self._callback = None | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
import pty | ||
import select | ||
|
||
|
||
class LineMonitor: | ||
def __init__(self): | ||
self._callback = None | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
import pty | ||
import select | ||
|
||
|
||
class LineMonitor: | ||
def __init__(self): | ||
self._callback = None | ||
|
Oops, something went wrong.