Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding version to documentation to help out on #1016 #1039

Merged
merged 3 commits into from
May 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ Comment

.. autoclass:: Comment

Version
=======

.. autoclass:: jira.resources.Version

Worklog
=======

Expand Down
36 changes: 29 additions & 7 deletions jira/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -879,10 +879,11 @@ def __init__(self, options, session, raw=None):
self._parse_raw(raw)

def delete(self, moveFixIssuesTo=None, moveAffectedIssuesTo=None):
"""Delete this project version from the server.
"""
Delete this project version from the server.

If neither of the arguments are specified, the version is
removed from all issues it is attached to.
If neither of the arguments are specified, the version is removed from all
issues it is attached to.

:param moveFixIssuesTo: in issues for which this version is a fix
version, add this argument version to the fix version list
Expand All @@ -898,11 +899,32 @@ def delete(self, moveFixIssuesTo=None, moveAffectedIssuesTo=None):

return super(Version, self).delete(params)

def update(self, **args):
"""Update this project version from the server. It is prior used to archive versions."""
def update(self, **kwargs):
"""
Update this project version from the server. It is prior used to archive versions.

Refer to Atlassian REST API `documentation`_.

.. _documentation: https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-project-versions/#api-rest-api-2-version-id-put

:Example:

.. code-block:: python

>> version_id = "10543"
>> version = JIRA("https://atlassian.org").version(version_id)
>> print(version.name)
"some_version_name"
>> version.update(name="another_name")
>> print(version.name)
"another_name"
>> version.update(archived=True)
>> print(version.archived)
True
"""
data = {}
for field in args:
data[field] = args[field]
for field in kwargs:
data[field] = kwargs[field]

super(Version, self).update(**data)

Expand Down
11 changes: 11 additions & 0 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1596,6 +1596,17 @@ def test_project_versions(self):
i.update(fields={"fixVersions": [{"id": version.id}]})
version.delete()

def test_update_project_version(self):
# given
name = "version-%s" % rndstr()
version = self.jira.create_version(name, self.project_b, "will be deleted soon")
updated_name = "version-%s" % rndstr()
# when
version.update(name=updated_name)
# then
self.assertEqual(updated_name, version.name)
version.delete()

def test_get_project_version_by_name(self):
name = "version-%s" % rndstr()
version = self.jira.create_version(name, self.project_b, "will be deleted soon")
Expand Down