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

Commit

Permalink
Merge pull request #207 from TomasTomecek/woooooooooooooooh
Browse files Browse the repository at this point in the history
All tests now pass locally
  • Loading branch information
jpopelka authored Apr 9, 2019
2 parents 5157870 + 73f4529 commit 6e1bb9a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion release_bot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def get_pypi_project_from_setup_cfg(path=None):
pypi_config = configparser.ConfigParser()
pypi_config.read(path)

if len(pypi_config) > 0:
if pypi_config:
try:
metadata = pypi_config["metadata"]
return metadata.get("name", None)
Expand Down
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 6e1bb9a

Please sign in to comment.