Skip to content

Commit 54aeb0a

Browse files
studiojNeefs, Jef
authored andcommitted
adding version to documentation to help out on pycontribs#1016 (pycontribs#1039)
* adding version to documentation to help out on pycontribs#1016 * updating param name from **args to **kwargs and adding some test coverage for it * adding an example in the method documentation Co-authored-by: Neefs, Jef <[email protected]>
1 parent 6092dcf commit 54aeb0a

File tree

3 files changed

+45
-7
lines changed

3 files changed

+45
-7
lines changed

docs/api.rst

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ Comment
2626

2727
.. autoclass:: Comment
2828

29+
Version
30+
=======
31+
32+
.. autoclass:: jira.resources.Version
33+
2934
Worklog
3035
=======
3136

jira/resources.py

+29-7
Original file line numberDiff line numberDiff line change
@@ -879,10 +879,11 @@ def __init__(self, options, session, raw=None):
879879
self._parse_raw(raw)
880880

881881
def delete(self, moveFixIssuesTo=None, moveAffectedIssuesTo=None):
882-
"""Delete this project version from the server.
882+
"""
883+
Delete this project version from the server.
883884
884-
If neither of the arguments are specified, the version is
885-
removed from all issues it is attached to.
885+
If neither of the arguments are specified, the version is removed from all
886+
issues it is attached to.
886887
887888
:param moveFixIssuesTo: in issues for which this version is a fix
888889
version, add this argument version to the fix version list
@@ -898,11 +899,32 @@ def delete(self, moveFixIssuesTo=None, moveAffectedIssuesTo=None):
898899

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

901-
def update(self, **args):
902-
"""Update this project version from the server. It is prior used to archive versions."""
902+
def update(self, **kwargs):
903+
"""
904+
Update this project version from the server. It is prior used to archive versions.
905+
906+
Refer to Atlassian REST API `documentation`_.
907+
908+
.. _documentation: https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-project-versions/#api-rest-api-2-version-id-put
909+
910+
:Example:
911+
912+
.. code-block:: python
913+
914+
>> version_id = "10543"
915+
>> version = JIRA("https://atlassian.org").version(version_id)
916+
>> print(version.name)
917+
"some_version_name"
918+
>> version.update(name="another_name")
919+
>> print(version.name)
920+
"another_name"
921+
>> version.update(archived=True)
922+
>> print(version.archived)
923+
True
924+
"""
903925
data = {}
904-
for field in args:
905-
data[field] = args[field]
926+
for field in kwargs:
927+
data[field] = kwargs[field]
906928

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

tests/tests.py

+11
Original file line numberDiff line numberDiff line change
@@ -1570,6 +1570,17 @@ def test_project_versions(self):
15701570
i.update(fields={"fixVersions": [{"id": version.id}]})
15711571
version.delete()
15721572

1573+
def test_update_project_version(self):
1574+
# given
1575+
name = "version-%s" % rndstr()
1576+
version = self.jira.create_version(name, self.project_b, "will be deleted soon")
1577+
updated_name = "version-%s" % rndstr()
1578+
# when
1579+
version.update(name=updated_name)
1580+
# then
1581+
self.assertEqual(updated_name, version.name)
1582+
version.delete()
1583+
15731584
def test_get_project_version_by_name(self):
15741585
name = "version-%s" % rndstr()
15751586
version = self.jira.create_version(name, self.project_b, "will be deleted soon")

0 commit comments

Comments
 (0)