mirror of
https://github.com/rpm-software-management/tito.git
synced 2025-02-24 04:32:46 +00:00

Fix #364 Previously all non-yes input was considered to be "no". Which is not what we typically want. There should be expected "yes" inputs, expected "no" inputs and everything else should be considered to be an uknown input and should be treated this way. I think that printing an error for unknown input is too verbose and have no added value. Simply repeating the question is the way to go here: ##### Please review the above diff ##### Do you wish to proceed with commit? [y/n] foo Do you wish to proceed with commit? [y/n] y Proceeding with commit.
36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
import unittest
|
|
import mock
|
|
from tito.compat import PY2, RawConfigParser
|
|
from tito.release import Releaser
|
|
from unit import builtins_input
|
|
|
|
|
|
class ReleaserTests(unittest.TestCase):
|
|
|
|
@mock.patch("tito.release.main.create_builder")
|
|
@mock.patch("tito.release.main.mkdtemp")
|
|
def setUp(self, mkdtemp, create_builder):
|
|
self.config = RawConfigParser()
|
|
|
|
self.releaser_config = RawConfigParser()
|
|
self.releaser_config.add_section("test")
|
|
self.releaser_config.set('test', "releaser",
|
|
"tito.release.Releaser")
|
|
|
|
self.releaser = Releaser("titotestpkg", None, "/tmp/tito/",
|
|
self.config, {}, "test", self.releaser_config, False,
|
|
False, False, **{"offline": True})
|
|
|
|
@mock.patch(builtins_input)
|
|
def test_ask_yes_or_no(self, input_mock):
|
|
input_mock.side_effect = "y"
|
|
assert self.releaser._ask_yes_no()
|
|
|
|
input_mock.side_effect = "n"
|
|
assert not self.releaser._ask_yes_no()
|
|
|
|
input_mock.side_effect = ["yy", "y"]
|
|
assert self.releaser._ask_yes_no()
|
|
|
|
input_mock.side_effect = ["yy", "no"]
|
|
assert not self.releaser._ask_yes_no()
|