diff options
| author | John L. Villalovos <john@sodarock.com> | 2021-04-25 13:03:13 -0700 |
|---|---|---|
| committer | John L. Villalovos <john@sodarock.com> | 2021-04-25 13:03:13 -0700 |
| commit | 115938b3e5adf9a2fb5ecbfb34d9c92bf788035e (patch) | |
| tree | dabf574c82f459aefb142b46d111b92dd93b7637 | |
| parent | e37de189d5799e9bdbbd7556289d4b617aff9c4d (diff) | |
| download | gitlab-115938b3e5adf9a2fb5ecbfb34d9c92bf788035e.tar.gz | |
feat: add support for lists of integers to ListAttribute
Previously ListAttribute only support lists of integers. Now be more
flexible and support lists of items which can be coerced into strings,
for example integers.
This will help us fix issue #1407 by using ListAttribute for the
'iids' field.
| -rw-r--r-- | gitlab/tests/test_types.py | 5 | ||||
| -rw-r--r-- | gitlab/types.py | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/gitlab/tests/test_types.py b/gitlab/tests/test_types.py index f84eddb..a2e5ff5 100644 --- a/gitlab/tests/test_types.py +++ b/gitlab/tests/test_types.py @@ -59,6 +59,11 @@ def test_list_attribute_get_for_api_from_list(): assert o.get_for_api() == "foo,bar,baz" +def test_list_attribute_get_for_api_from_int_list(): + o = types.ListAttribute([1, 9, 7]) + assert o.get_for_api() == "1,9,7" + + def test_list_attribute_does_not_split_string(): o = types.ListAttribute("foo") assert o.get_for_api() == "foo" diff --git a/gitlab/types.py b/gitlab/types.py index e07d078..0495c97 100644 --- a/gitlab/types.py +++ b/gitlab/types.py @@ -42,7 +42,7 @@ class ListAttribute(GitlabAttribute): if isinstance(self._value, str): return self._value - return ",".join(self._value) + return ",".join([str(x) for x in self._value]) class LowercaseStringAttribute(GitlabAttribute): |
