Skip to content
This repository has been archived by the owner on May 16, 2022. It is now read-only.

Commit

Permalink
fix last two test failures
Browse files Browse the repository at this point in the history
the problem was that methods were not mocked and picked data from the
current working directory

Signed-off-by: Tomas Tomecek <[email protected]>
  • Loading branch information
TomasTomecek committed Apr 9, 2019
1 parent d24b60d commit 73f4529
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
6 changes: 5 additions & 1 deletion tests/test_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ def mock_upload(self):
"""Mocks upload to PyPi"""
flexmock(self.release_bot.pypi, upload=True)

@pytest.fixture()
def mock_get_latest_version(self):
flexmock(self.release_bot.pypi, latest_version=lambda: "0.0.0")

def test_load_release_conf(self):
"""Tests loading release configuration from repository"""
self.release_bot.load_release_conf()
Expand Down Expand Up @@ -151,7 +155,7 @@ def test_github_release(self, open_pr_fixture):
self.release_bot.make_new_github_release()
assert self.release_bot.github.latest_release() == "0.0.1"

def test_pypi_release(self, mock_upload, github_release):
def test_pypi_release(self, mock_upload, github_release, mock_get_latest_version):
"""Test PyPi release"""
self.release_bot.load_release_conf()
# Testing dry-run mode
Expand Down
14 changes: 8 additions & 6 deletions tests/test_load_local_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from pathlib import Path

import pytest
from flexmock import flexmock

from pathlib import Path
from release_bot.configuration import configuration
from release_bot.configuration import configuration, Configuration


class TestLoadLocalConf:
""" This class contains tests for loading the release-bot
configuration from conf.yaml"""


def setup_method(self):
""" Setup any state tied to the execution of the given method in a
class. setup_method is invoked for every test method of a class.
Expand Down Expand Up @@ -51,11 +52,12 @@ def non_existing_conf(self):
"""Return a non-existing configutation file"""
return ""

def test_non_existing_conf(self, non_existing_conf):
def test_non_existing_conf(self):
"""Test if missing conf.yaml generates an error"""
configuration.configuration = non_existing_conf
flexmock(Path, is_file=lambda: False)
c = Configuration()
with pytest.raises(SystemExit) as error:
configuration.load_configuration()
c.load_configuration()
assert error.type == SystemExit
assert error.value.code == 1

Expand Down
1 change: 1 addition & 0 deletions tests/test_load_release_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from pathlib import Path

import pytest

from release_bot.configuration import configuration, Configuration
Expand Down

0 comments on commit 73f4529

Please sign in to comment.