Skip to content

Commit

Permalink
Merge pull request #1 from Itxaka/testing_and_coverage
Browse files Browse the repository at this point in the history
add coverage
  • Loading branch information
Itxaka committed Feb 2, 2018
2 parents 596c93f + ef435d7 commit 7a8bdb5
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
10 changes: 4 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ python:
- "3.5"
- "3.6"
install:
- pip install -r requirements.txt
- pip install -r test-requirements.txt
script:
- python tests_main.py
matrix:
include:
- python: "2.7"
install: pip install -r test-requirements.txt
- coverage run tests.py
after_success:
- codecov
6 changes: 5 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ def __init__(self):
formatter = logging.Formatter('%(asctime)s - %(thread)d - %(levelname)s - %(funcName)s - %(message)s')
ch.setFormatter(formatter)
self.log.addHandler(ch)
levels = {"debug": logging.DEBUG, "info": logging.INFO}
levels = {
"debug": logging.DEBUG,
"info": logging.INFO,
"error": logging.ERROR
}

config = self.load_config()
username = config.get("default", "username")
Expand Down
3 changes: 2 additions & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
requests
mock
future
future
coverage
15 changes: 13 additions & 2 deletions tests_main.py → tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
from unittest.mock import Mock, patch, mock_open
from main import QueueBalancer
import io
from builtins import range
try:
from builtins import range
except ImportError:
from __builtin__ import range


class TestQueues(unittest.TestCase):
Expand Down Expand Up @@ -39,7 +42,15 @@ def setUpClass(cls):
]

def setUp(self):
config = u"[default]\nusername = username\npassword = password\nvhost = vhost\nhostname = hostname\nport = port"
config = u"""[default]
username = username
password = password
vhost = vhost
hostname = hostname
port = 1
log_level = error
threads = 1
wait_time = 1"""

with patch('main.open') as mo:
mo.__enter__ = Mock(return_value=(Mock(), None))
Expand Down

0 comments on commit 7a8bdb5

Please sign in to comment.