def test_update_version_missing(test_repo):
    """If there is no version we should return None"""
    os.unlink("ccxcon/settings.py")
    contents = """
setup(
    name='pylmod',
)        """
    with open("setup.py", "w") as f:
        f.write(contents)
    with pytest.raises(UpdateVersionException) as ex:
        update_version("4.5.6")
    assert ex.value.args[0] == "Unable to find previous version number"
def test_update_version_duplicate(test_repo):
    """If there are two detected versions in different files we should raise an exception"""
    contents = """
setup(
    name='pylmod',
    version='1.2.3',
)        """
    with open("setup.py", "w") as f:
        f.write(contents)
    with pytest.raises(UpdateVersionException) as ex:
        update_version("4.5.6")
    assert ex.value.args[
        0] == "Found at least two files with updatable versions: settings.py and setup.py"
def test_update_version_duplicate_same_file(test_repo):
    """If there are two detected versions in the same file we should raise an exception"""
    contents = """
setup(
    name='pylmod',
    version='1.2.3',
    version='4.5.6',
)        """
    with open("setup.py", "w") as f:
        f.write(contents)
    with pytest.raises(UpdateVersionException) as ex:
        update_version("4.5.6")
    assert ex.value.args[
        0] == "Expected only one version for setup.py but found 2"
def test_update_version_settings(test_repo):
    """update_version should return the old version and replace the appropriate file's text with the new version"""
    new_version = "9.9.99"
    path = "ccxcon/settings.py"

    old_lines = open(path).readlines()

    old_version = update_version(new_version)
    assert old_version == "0.2.0"
    new_lines = open(path).readlines()

    assert len(old_lines) == len(new_lines)

    diff_count = 0
    for old_line, new_line in zip(old_lines, new_lines):
        if old_line != new_line:
            diff_count += 1

    assert diff_count == 1

    found_new_version = False
    with open(path) as f:
        for line in f.readlines():
            if line == "VERSION = \"{}\"\n".format(new_version):
                found_new_version = True
                break
    assert found_new_version, "Unable to find updated version"
Example #5
0
def test_update_version(test_repo):
    """update_version should return the old version and replace the appropriate file's text with the new version"""
    new_version = "9.9.99"
    old_version = update_version(new_version)
    assert old_version == "0.2.0"

    found_new_version = False
    with open("ccxcon/settings.py") as f:
        for line in f.readlines():
            if line.startswith("VERSION = \"{}\"".format(new_version)):
                found_new_version = True
                break
    assert found_new_version, "Unable to find updated version"
def test_update_version_init(test_repo):
    """If we detect a version in a __init__.py file we should update it properly"""
    old_version = '1.2.3'
    os.unlink("ccxcon/settings.py")
    with open("ccxcon/__init__.py", "w") as f:
        f.write("__version__ = '{}'".format(old_version))
    new_version = "4.5.6"
    assert update_version(new_version) == old_version

    found_new_version = False
    with open("ccxcon/__init__.py") as f:
        for line in f.readlines():
            if line.strip() == "__version__ = '{}'".format(new_version):
                found_new_version = True
                break
    assert found_new_version, "Unable to find updated version"
Example #7
0
    async def commits_since_last_release(self, command_args):
        """
        Have doof show the release notes since the last release

        Args:
            command_args (CommandArgs): The arguments for this command
        """
        repo_info = command_args.repo_info
        with init_working_dir(self.github_access_token, repo_info.repo_url):
            last_version = update_version("9.9.9")

            release_notes = create_release_notes(last_version, with_checkboxes=False)

        await self.say_with_attachment(
            channel_id=repo_info.channel_id,
            title="Release notes since {}".format(last_version),
            text=release_notes,
        )
Example #8
0
    async def commits_since_last_release(self, repo_info):
        """
        Have doof show the release notes since the last release

        Args:
            repo_info (RepoInfo): The info for a repo
        """
        with init_working_dir(repo_info.repo_url):
            last_version = update_version("9.9.9")

            release_notes = create_release_notes(last_version,
                                                 with_checkboxes=False)
        await self.say(
            repo_info.channel_id,
            "Release notes since {version}...\n\n{notes}".format(
                version=last_version,
                notes=release_notes,
            ),
        )
def test_update_version_setup(test_repo):
    """If we detect a version in setup.py we should update it properly"""
    old_version = '0.2.0'
    os.unlink("ccxcon/settings.py")
    with open("setup.py", "w") as f:
        f.write("""
setup(
    name='pylmod',
    version='0.2.0',
    license='BSD',
    author='MIT ODL Engineering',
    zip_safe=True,
)        """)
    new_version = '4.5.6'
    assert update_version(new_version) == old_version

    found_new_version = False
    with open("setup.py") as f:
        for line in f.readlines():
            if line.strip() == "version='{}',".format(new_version):
                found_new_version = True
                break
    assert found_new_version, "Unable to find updated version"