Skip to content

Commit

Permalink
Fixed lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
emxsys committed Nov 20, 2020
1 parent c5770a3 commit a8b075b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions callattendant/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ def wait_for_rings(self, rings_before_answer):
break
return ok_to_answer


def make_config(filename=None, datapath=None, create_folder=False):
"""
Creates the config dictionary for this application/module.
Expand Down
2 changes: 1 addition & 1 deletion callattendant/hardware/modem.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ def ring(self):
"""
Activate the ring indicator
"""
# Notify other threads that a ring occurred
# Notify other threads that a ring occurred
self.ring_event.set()
self.ring_event.clear()
# Visual notification (LED)
Expand Down
10 changes: 7 additions & 3 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import pytest
import threading
import time
from datetime import datetime

from callattendant.app import CallAttendant
from callattendant.config import Config
Expand All @@ -46,16 +45,17 @@
caller3 = {"NAME": "CALLER3", "NMBR": "3333333333", "DATE": "0303", "TIME": "0303"}
caller4 = {"NAME": "CALLER4", "NMBR": "4444444444", "DATE": "0404", "TIME": "0404"}


@pytest.fixture()
def app(mocker):

# Create a config object with default settings
config = Config()
config['DEBUG'] = False
config['TESTING'] = True
config["BLOCKED_ACTIONS"] = ("answer","greeting","voice_mail")
config["BLOCKED_ACTIONS"] = ("answer", "greeting", "voice_mail")
config["BLOCKED_RINGS_BEFORE_ANSWER"] = 0
config["SCREENED_ACTIONS"] = ("answer","greeting","record_message")
config["SCREENED_ACTIONS"] = ("answer", "greeting", "record_message")
config["SCREENED_RINGS_BEFORE_ANSWER"] = 0
config["PERMITTED_ACTIONS"] = ("ignore",)
config["PERMITTED_RINGS_BEFORE_ANSWER"] = 4
Expand Down Expand Up @@ -163,6 +163,7 @@ def mock_voice_messaging_menu(call_no, caller):

app.shutdown()


def test_ignore_permitted(app):
"""
Tests that permitted calls are ignored (per config)
Expand Down Expand Up @@ -265,6 +266,7 @@ def test_answer_call_no_actions(app, mocker):
assert not record_message_called
assert not voice_messaging_menu_called


def test_answer_call_greeting(app):

global play_audio_called
Expand All @@ -281,6 +283,7 @@ def test_answer_call_greeting(app):
assert not record_message_called
assert not voice_messaging_menu_called


def test_answer_call_record_message(app):

global play_audio_called
Expand All @@ -297,6 +300,7 @@ def test_answer_call_record_message(app):
assert record_message_called
assert not voice_messaging_menu_called


def test_answer_call_voice_mail(app):

global play_audio_called
Expand Down
10 changes: 7 additions & 3 deletions tests/test_modem.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ def modem():

modem.stop()


def test_modem_online(modem):
assert modem.is_open


def test_profile_reset(modem):
assert modem._send(RESET)

Expand Down Expand Up @@ -126,10 +128,12 @@ def test_recording_audio(modem):
filename = os.path.join(modem.config["DATA_PATH"], "message.wav")
assert modem.record_audio(filename, detect_silence=False)


def test_recording_audio_detect_silence(modem):
filename = os.path.join(modem.config["DATA_PATH"], "message.wav")
assert not modem.record_audio(filename)


def test_call_handler(modem, mocker):
# Incoming caller id test data: valid numbers are sequential 10 digit repeating nums,
# plus some spurious call data intermixed between caller ids
Expand All @@ -138,7 +142,7 @@ def test_call_handler(modem, mocker):
b"RING", b"DATE=0202", b"TIME=0202", b"NMBR=2222222222", # Test2 - no name
b"RING", b"NMBR=3333333333", # Test3 - number only
b"RING", b"DATE=0404", b"TIME=0404", b"NMBR=4444444444", b"NAME=Test4",
b"RING", b"RING",b"NAME=TestNoNumber", b"RING", b"RING", # Partial data w/o number
b"RING", b"RING", b"NAME=TestNoNumber", b"RING", b"RING", # Partial data w/o number
b"RING", b"DATE=0505", b"TIME=0505", b"NMBR=5555555555", b"NAME=Test5",
]
data_queue = queue.Queue()
Expand Down Expand Up @@ -182,8 +186,8 @@ def handle_call(call_record):
assert all(k in call for k in ("DATE", "TIME", "NAME", "NMBR"))

# Assert the number and name matches the inputs or defaults
assert call["NMBR"] == str(n)*10
if n in [1,4,5]:
assert call["NMBR"] == str(n) * 10
if n in [1, 4, 5]:
assert call["NAME"] == "Test{}".format(n)
else:
assert call["NAME"] == "Unknown"
Expand Down

0 comments on commit a8b075b

Please sign in to comment.