Exemple #1
0
    def testMicroRelease(self, write_version, read_version):
        scm = self.createSCM()

        release = self.release(scm, "micro")

        self._verify_command_invocations(release)

        scm.tag.assert_called_once_with(Version(1, 3, 3))
        read_version.assert_called_once_with()
        write_version.assert_called_once_with(Version(1, 3, 4))
        scm.commit.assert_called_once_with("Preparing version 1.3.4")
Exemple #2
0
    def testMajorRelease(self, write_version, read_version):
        scm = self.createSCM()

        release = self.release(scm, "major")

        self._verify_command_invocations(release)

        read_version.assert_called_once_with()
        scm.tag.assert_called_once_with(Version(2, 0, 0))
        write_version.assert_has_calls(
            [call(Version(2, 0, 0)),
             call(Version(2, 0, 1))])
        scm.commit.assert_has_calls(
            [call("Releasing version 2.0.0"),
             call("Preparing version 2.0.1")])
Exemple #3
0
 def test_tag():
     mock = MagicMock()
     with patch("subprocess.call", mock):
         scm = SourceControl()
         scm.tag(Version(2, 0, 1))
     mock.assert_has_calls([
         call(["git.exe", "tag", "-a", "v2.0.1", "-m", "\"Version 2.0.1\""],
              env=ANY,
              shell=True)
     ])
Exemple #4
0
class ReleaseTest(TestCase):
    @staticmethod
    def createSourceWithVersion(text):
        return None

    @staticmethod
    def release(scm, kind):
        release = Release(Distribution(), scm)
        release.run_command = MagicMock()
        release.type = kind
        release.run()
        return release

    @staticmethod
    def createSCM():
        scm = SourceControl()
        scm.tag = MagicMock()
        scm.commit = MagicMock()
        return scm

    @staticmethod
    def _verify_command_invocations(release):
        release.run_command.assert_has_calls([
            call("bdist_egg"),
            call("sdist"),
            call("register"),
            call("upload"),
        ])

    @patch("flap.util.releasing.Version.from_source_code",
           return_value=Version(1, 3, 3))
    @patch("flap.util.releasing.Version.update_source_code")
    def testMicroRelease(self, write_version, read_version):
        scm = self.createSCM()

        release = self.release(scm, "micro")

        self._verify_command_invocations(release)

        scm.tag.assert_called_once_with(Version(1, 3, 3))
        read_version.assert_called_once_with()
        write_version.assert_called_once_with(Version(1, 3, 4))
        scm.commit.assert_called_once_with("Preparing version 1.3.4")

    @patch("flap.util.releasing.Version.from_source_code",
           return_value=Version(1, 3, 3))
    @patch("flap.util.releasing.Version.update_source_code")
    def testMinorRelease(self, write_version, read_version):
        scm = self.createSCM()

        release = self.release(scm, "minor")

        self._verify_command_invocations(release)

        read_version.assert_called_once_with()
        scm.tag.assert_called_once_with(Version(1, 4, 0))
        write_version.assert_has_calls(
            [call(Version(1, 4, 0)),
             call(Version(1, 4, 1))])
        scm.commit.assert_has_calls(
            [call("Releasing version 1.4.0"),
             call("Preparing version 1.4.1")])

    @patch("flap.util.releasing.Version.from_source_code",
           return_value=Version(1, 3, 3))
    @patch("flap.util.releasing.Version.update_source_code")
    def testMajorRelease(self, write_version, read_version):
        scm = self.createSCM()

        release = self.release(scm, "major")

        self._verify_command_invocations(release)

        read_version.assert_called_once_with()
        scm.tag.assert_called_once_with(Version(2, 0, 0))
        write_version.assert_has_calls(
            [call(Version(2, 0, 0)),
             call(Version(2, 0, 1))])
        scm.commit.assert_has_calls(
            [call("Releasing version 2.0.0"),
             call("Preparing version 2.0.1")])
Exemple #5
0
 def test_update_source_code(self):
     mock = mock_open(read_data="__version__ = \"1.2.3\"")
     with patch('flap.util.releasing.open', mock, create=True):
         Version.update_source_code(Version(1, 3, 0))
     mock().write.assert_called_once_with("__version__ = \"1.3.0\"")
Exemple #6
0
 def test_read_from_source_code(self):
     with patch("flap.__version__", "1.3.4"):
         version = Version.from_source_code()
         self.assertEqual(version, Version(1, 3, 4))
Exemple #7
0
 def makeVersion(text):
     return Version.from_text(text)
Exemple #8
0
 def test_update_source_code(self):
     mock = mock_open(read_data='__version__ = "1.2.3"')
     with patch("flap.util.releasing.open", mock, create=True):
         Version.update_source_code(Version(1, 3, 0))
     mock().write.assert_called_once_with('__version__ = "1.3.0"')
Exemple #9
0
 def test_read_from_source_code(self):
     with patch("flap.__version__", "1.3.4"):
         version = Version.from_source_code()
         self.assertEqual(version, Version(1, 3, 4))
Exemple #10
0
 def makeVersion(text):
     return Version.from_text(text)