From 297d8f559ee069de34b70cfc67fd71784a9f2460 Mon Sep 17 00:00:00 2001 From: Bruce Schubert Date: Wed, 19 Aug 2020 10:40:01 -0700 Subject: [PATCH] Move nomorobo unit tests to test_nomorobo.py - Re: #67 --- src/screening/nomorobo.py | 11 ---------- tests/test_nomorobo.py | 44 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 11 deletions(-) create mode 100644 tests/test_nomorobo.py diff --git a/src/screening/nomorobo.py b/src/screening/nomorobo.py index fac7bfe..8d7c180 100644 --- a/src/screening/nomorobo.py +++ b/src/screening/nomorobo.py @@ -88,14 +88,3 @@ def __init__(self, spam_threshold=2): self.spam_threshold = spam_threshold -def test(args): - nomorobo = NomoroboService() - result = nomorobo.lookup_number("5622862616") - print(result) - return 0 - - -if __name__ == '__main__': - import sys - sys.exit(test(sys.argv)) - print("Done") diff --git a/tests/test_nomorobo.py b/tests/test_nomorobo.py new file mode 100644 index 0000000..4ff85fe --- /dev/null +++ b/tests/test_nomorobo.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# test_nomorobo.py +# +# Copyright 2020 Bruce Schubert +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +import os +import sys +import sqlite3 +from pprint import pprint + +import pytest + +from src.callattendant import make_config +from src.screening.nomorobo import NomoroboService + +def test_lookup(): + nomorobo = NomoroboService() + result = nomorobo.lookup_number("5622862616") + pprint(result) + assert result["spam"] + + result = nomorobo.lookup_number("1234567890") + pprint(result) + assert not result.get("spam")