Skip to content

Commit

Permalink
Testing to 100%
Browse files Browse the repository at this point in the history
 - Update tox.ini and circle.yml
  • Loading branch information
levi-rs committed Dec 4, 2016
1 parent 253bcc2 commit 2988915
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
10 changes: 5 additions & 5 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ machine:

general:
artifacts:
- .tox/tox/junit.xml
- .tox/tox/flake8.txt
- .tox/coverage.xml
- .tox/py3/junit.xml
- .tox/lint/flake8.txt
- coverage.xml

dependencies:
override:
Expand All @@ -20,8 +20,8 @@ test:
post:
- coveralls
- mkdir -p $CIRCLE_TEST_REPORTS/dankbot
- cp .tox/tox/junit.xml $CIRCLE_TEST_REPORTS/dankbot
- cp .tox/tox/flake8.txt $CIRCLE_TEST_REPORTS/dankbot
- cp .tox/py3/junit.xml $CIRCLE_TEST_REPORTS/dankbot
- cp .tox/lint/flake8.txt $CIRCLE_TEST_REPORTS/dankbot
- cp -R htmlcov $CIRCLE_TEST_REPORTS/dankbot
- cp coverage.xml $CIRCLE_TEST_REPORTS/dankbot

Expand Down
2 changes: 1 addition & 1 deletion dankbot/dankbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def get_memes(self):
self.logger.debug("Collecting memes from subreddit: {0}".format(sub))
try:
subreddit_memes = self._get_memes_from_subreddit(r_client, sub)
except HTTPException:
except HTTPException: # pragma: no cover
log = "API failed to get memes for subreddit: {0}"
self.logger.exception(log.format(sub))
continue
Expand Down
14 changes: 9 additions & 5 deletions tests/test_dankbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def dank_meme():

@pytest.fixture(scope="function")
def imgur_meme():
return MockMeme(False, DANK_MEME_URL)
return MockMeme(False, IMGUR_MEME_URL)


@pytest.fixture(scope="function")
Expand Down Expand Up @@ -189,14 +189,18 @@ def test_yes_nsfw_and_18plus(ic, atc, slack, praw, config, logger):
assert slack.post_message.call_args == call(MOCK_CHANNEL, message, as_user=True)


@patch('dankbot.dankbot.praw')
@patch('dankbot.memes.ImgurClient')
@patch.object(DankBot, 'add_to_collection')
@patch.object(DankBot, 'in_collection')
def test_post_imgur_meme(ic, atc, slack, praw, config, logger, imgur_meme):
def test_post_imgur_meme(ic, atc, imgur, praw, slack, config, logger, imgur_meme):
ic.return_value = False
praw.get_hot.return_value[0].over_18 = True
imgur.return_value = Exception("Preventing connection")
praw.Reddit.return_value = praw
praw.get_subreddit.return_value = praw
praw.get_hot.return_value = [imgur_meme, ]

dankbot = DankBot(config, logger)
dankbot.include_nsfw = True
dankbot.subreddits = dankbot.subreddits[:1]

resp = dankbot.find_and_post_memes()
Expand All @@ -205,5 +209,5 @@ def test_post_imgur_meme(ic, atc, slack, praw, config, logger, imgur_meme):
assert resp is True
assert atc.called

message = "from {0}: {1}".format(SUB_1, DANK_MEME_URL)
message = "from {0}: {1}".format(SUB_1, IMGUR_MEME_URL)
assert slack.post_message.call_args == call(MOCK_CHANNEL, message, as_user=True)
5 changes: 4 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ envlist = py3,lint

[testenv]
commands =
py.test -sx --cov dankbot --cov-report term-missing --cov-report html --cov-report xml --junitxml={envdir}/junit.xml tests []
py.test -s --cov dankbot --cov-report term-missing --cov-report html --cov-report xml --junitxml={envdir}/junit.xml tests []
deps =
pytest>=2.6.4
pytest-cov>=1.8.1
Expand All @@ -14,3 +14,6 @@ deps =
flake8==2.4.0
commands =
flake8 --output-file={envdir}/flake8.txt setup.py dankbot tests

[testenv:env]
envdir = {toxinidir}/env

0 comments on commit 2988915

Please sign in to comment.