python-backlog 0.7.0__tar.gz → 0.7.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. python_backlog-0.7.4/MANIFEST.in +3 -0
  2. python_backlog-0.7.4/PKG-INFO +89 -0
  3. python_backlog-0.7.4/VERSION +1 -0
  4. python_backlog-0.7.4/python_backlog.egg-info/PKG-INFO +89 -0
  5. {python-backlog-0.7.0 → python_backlog-0.7.4}/python_backlog.egg-info/SOURCES.txt +14 -1
  6. python_backlog-0.7.4/python_backlog.egg-info/requires.txt +1 -0
  7. python_backlog-0.7.4/requirements-dev.txt +4 -0
  8. python_backlog-0.7.4/requirements.txt +1 -0
  9. {python-backlog-0.7.0 → python_backlog-0.7.4}/setup.py +9 -10
  10. python_backlog-0.7.4/tests/test_api.py +120 -0
  11. python_backlog-0.7.4/tests/test_attachment.py +55 -0
  12. python_backlog-0.7.4/tests/test_category.py +97 -0
  13. python_backlog-0.7.4/tests/test_custom_filed.py +328 -0
  14. python_backlog-0.7.4/tests/test_git.py +426 -0
  15. python_backlog-0.7.4/tests/test_issue.py +685 -0
  16. python_backlog-0.7.4/tests/test_project.py +438 -0
  17. python_backlog-0.7.4/tests/test_user.py +169 -0
  18. python_backlog-0.7.4/tests/test_wiki.py +520 -0
  19. python-backlog-0.7.0/PKG-INFO +0 -88
  20. python-backlog-0.7.0/python_backlog.egg-info/PKG-INFO +0 -88
  21. python-backlog-0.7.0/python_backlog.egg-info/requires.txt +0 -1
  22. {python-backlog-0.7.0 → python_backlog-0.7.4}/LICENSE +0 -0
  23. {python-backlog-0.7.0 → python_backlog-0.7.4}/README.md +0 -0
  24. {python-backlog-0.7.0 → python_backlog-0.7.4}/backlog/__init__.py +0 -0
  25. {python-backlog-0.7.0 → python_backlog-0.7.4}/backlog/attachment.py +0 -0
  26. {python-backlog-0.7.0 → python_backlog-0.7.4}/backlog/base.py +0 -0
  27. {python-backlog-0.7.0 → python_backlog-0.7.4}/backlog/category.py +0 -0
  28. {python-backlog-0.7.0 → python_backlog-0.7.4}/backlog/custom_field.py +0 -0
  29. {python-backlog-0.7.0 → python_backlog-0.7.4}/backlog/git.py +0 -0
  30. {python-backlog-0.7.0 → python_backlog-0.7.4}/backlog/issue.py +0 -0
  31. {python-backlog-0.7.0 → python_backlog-0.7.4}/backlog/project.py +0 -0
  32. {python-backlog-0.7.0 → python_backlog-0.7.4}/backlog/user.py +0 -0
  33. {python-backlog-0.7.0 → python_backlog-0.7.4}/backlog/wiki.py +0 -0
  34. {python-backlog-0.7.0 → python_backlog-0.7.4}/python_backlog.egg-info/dependency_links.txt +0 -0
  35. {python-backlog-0.7.0 → python_backlog-0.7.4}/python_backlog.egg-info/top_level.txt +0 -0
  36. {python-backlog-0.7.0 → python_backlog-0.7.4}/setup.cfg +0 -0
@@ -0,0 +1,3 @@
1
+ include VERSION
2
+ include requirements.txt
3
+ include requirements-dev.txt
@@ -0,0 +1,89 @@
1
+ Metadata-Version: 2.1
2
+ Name: python-backlog
3
+ Version: 0.7.4
4
+ Summary: Backlog API v2 wrapper
5
+ Home-page: https://github.com/hassaku63/pbl
6
+ Author: hassaku63
7
+ Author-email: hassaku63@gmail.com
8
+ License: MIT
9
+ Project-URL: Source, https://github.com/hassaku63/pbl
10
+ Keywords: nulab backlog
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Programming Language :: Python
13
+ Classifier: Programming Language :: Python :: 3.8
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Natural Language :: Japanese
18
+ Requires-Python: >=3.8
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: requests~=2.32.2
22
+
23
+ # pbl
24
+
25
+ A Python package wraps Backlog API V2
26
+
27
+ ## Usage
28
+
29
+ Install
30
+
31
+ ```bash
32
+ pip install python-backlog
33
+ ```
34
+
35
+ Code snippet
36
+
37
+ ```python
38
+ import base64
39
+ import json
40
+ from backlog.base import BacklogAPI
41
+
42
+
43
+ def main():
44
+ """
45
+ Initialize API Object
46
+ """
47
+ api = BacklogAPI("your-space", "your-api-key")
48
+
49
+ """
50
+ Project API
51
+ """
52
+ # list project users
53
+ # https://developer.nulab-inc.com/ja/docs/backlog/api/2/get-project-list/
54
+ print("# list project users")
55
+ users = api.project.list_users("SampleProject")
56
+ print(json.dumps(users, indent=2))
57
+
58
+
59
+ """
60
+ Wiki API
61
+ """
62
+ # list wikis
63
+ # https://developer.nulab-inc.com/ja/docs/backlog/api/2/get-wiki-page-list/
64
+ print("# list wikis")
65
+ wikis = api.wiki.list("SampleProject")
66
+ print(json.dumps(wikis[0], indent=2))
67
+
68
+ # get attachment
69
+ # https://developer.nulab-inc.com/ja/docs/backlog/api/2/get-issue-attachment/
70
+ print("# get attachment")
71
+ wiki = [w for w in api.wiki.list("SampleProject") if len(w["attachments"]) > 0][0]
72
+ attachment = api.wiki.get_attachment(
73
+ wikiId=wiki["id"],
74
+ attachmentId=wiki["attachments"][0]["id"])
75
+ attachment["data"] = base64.b64encode(attachment["data"]).decode()
76
+ print(json.dumps(attachment, indent=2))
77
+
78
+
79
+ if __name__ == "__main__":
80
+ main()
81
+ ```
82
+
83
+ ## See also
84
+
85
+ Qiita https://qiita.com/hassaku_63/items/b9eb2a1c7ecd3c19507d
86
+
87
+ ## Contact
88
+
89
+ Twitter: [hassaku_63](https://twitter.com/hassaku_63)
@@ -0,0 +1 @@
1
+ 0.7.4
@@ -0,0 +1,89 @@
1
+ Metadata-Version: 2.1
2
+ Name: python-backlog
3
+ Version: 0.7.4
4
+ Summary: Backlog API v2 wrapper
5
+ Home-page: https://github.com/hassaku63/pbl
6
+ Author: hassaku63
7
+ Author-email: hassaku63@gmail.com
8
+ License: MIT
9
+ Project-URL: Source, https://github.com/hassaku63/pbl
10
+ Keywords: nulab backlog
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Programming Language :: Python
13
+ Classifier: Programming Language :: Python :: 3.8
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Natural Language :: Japanese
18
+ Requires-Python: >=3.8
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: requests~=2.32.2
22
+
23
+ # pbl
24
+
25
+ A Python package wraps Backlog API V2
26
+
27
+ ## Usage
28
+
29
+ Install
30
+
31
+ ```bash
32
+ pip install python-backlog
33
+ ```
34
+
35
+ Code snippet
36
+
37
+ ```python
38
+ import base64
39
+ import json
40
+ from backlog.base import BacklogAPI
41
+
42
+
43
+ def main():
44
+ """
45
+ Initialize API Object
46
+ """
47
+ api = BacklogAPI("your-space", "your-api-key")
48
+
49
+ """
50
+ Project API
51
+ """
52
+ # list project users
53
+ # https://developer.nulab-inc.com/ja/docs/backlog/api/2/get-project-list/
54
+ print("# list project users")
55
+ users = api.project.list_users("SampleProject")
56
+ print(json.dumps(users, indent=2))
57
+
58
+
59
+ """
60
+ Wiki API
61
+ """
62
+ # list wikis
63
+ # https://developer.nulab-inc.com/ja/docs/backlog/api/2/get-wiki-page-list/
64
+ print("# list wikis")
65
+ wikis = api.wiki.list("SampleProject")
66
+ print(json.dumps(wikis[0], indent=2))
67
+
68
+ # get attachment
69
+ # https://developer.nulab-inc.com/ja/docs/backlog/api/2/get-issue-attachment/
70
+ print("# get attachment")
71
+ wiki = [w for w in api.wiki.list("SampleProject") if len(w["attachments"]) > 0][0]
72
+ attachment = api.wiki.get_attachment(
73
+ wikiId=wiki["id"],
74
+ attachmentId=wiki["attachments"][0]["id"])
75
+ attachment["data"] = base64.b64encode(attachment["data"]).decode()
76
+ print(json.dumps(attachment, indent=2))
77
+
78
+
79
+ if __name__ == "__main__":
80
+ main()
81
+ ```
82
+
83
+ ## See also
84
+
85
+ Qiita https://qiita.com/hassaku_63/items/b9eb2a1c7ecd3c19507d
86
+
87
+ ## Contact
88
+
89
+ Twitter: [hassaku_63](https://twitter.com/hassaku_63)
@@ -1,5 +1,9 @@
1
1
  LICENSE
2
+ MANIFEST.in
2
3
  README.md
4
+ VERSION
5
+ requirements-dev.txt
6
+ requirements.txt
3
7
  setup.py
4
8
  backlog/__init__.py
5
9
  backlog/attachment.py
@@ -15,4 +19,13 @@ python_backlog.egg-info/PKG-INFO
15
19
  python_backlog.egg-info/SOURCES.txt
16
20
  python_backlog.egg-info/dependency_links.txt
17
21
  python_backlog.egg-info/requires.txt
18
- python_backlog.egg-info/top_level.txt
22
+ python_backlog.egg-info/top_level.txt
23
+ tests/test_api.py
24
+ tests/test_attachment.py
25
+ tests/test_category.py
26
+ tests/test_custom_filed.py
27
+ tests/test_git.py
28
+ tests/test_issue.py
29
+ tests/test_project.py
30
+ tests/test_user.py
31
+ tests/test_wiki.py
@@ -0,0 +1 @@
1
+ requests~=2.32.2
@@ -0,0 +1,4 @@
1
+ flake8~=6.1.0
2
+ tox~=4.11.0
3
+ httpretty~=1.1.0
4
+ coverage~=7.3.0
@@ -0,0 +1 @@
1
+ requests~=2.32.2
@@ -10,14 +10,18 @@ with open(path.join(here, 'README.md'), encoding='utf-8') as f:
10
10
  long_description = f.read()
11
11
 
12
12
  with open(path.join(here, 'VERSION'), encoding='utf-8') as f:
13
- version = f.read()
13
+ version = f.read().strip()
14
+
15
+ with open(path.join(here, 'requirements.txt'), encoding='utf-8') as f:
16
+ install_requires = f.read().splitlines()
17
+
18
+ with open(path.join(here, 'requirements-dev.txt'), encoding='utf-8') as f:
19
+ tests_require = f.read().splitlines()
14
20
 
15
21
  setup(
16
22
  name='python-backlog',
17
23
  version=version,
18
- install_requires=[
19
- 'requests~=2.31.0',
20
- ],
24
+ install_requires=install_requires,
21
25
  description='Backlog API v2 wrapper',
22
26
  long_description=long_description,
23
27
  long_description_content_type='text/markdown',
@@ -38,12 +42,7 @@ setup(
38
42
  scripts=[],
39
43
  packages=find_packages(exclude=['tests*']),
40
44
  python_requires=">=3.8",
41
- tests_require=[
42
- "flake8~=6.1.0",
43
- "tox~=4.11.0",
44
- "httpretty~=1.1.0",
45
- "coverage~=7.3.0",
46
- ],
45
+ tests_require=install_requires + tests_require,
47
46
  project_urls={
48
47
  'Source': 'https://github.com/hassaku63/pbl',
49
48
  }
@@ -0,0 +1,120 @@
1
+ # coding: utf-8
2
+
3
+ import unittest
4
+ import httpretty
5
+ import json
6
+ from backlog.base import BacklogAPI
7
+
8
+ API_ENDPOINT = "https://{space}.backlog.jp/api/v2/{uri}"
9
+
10
+
11
+ class TestApi(unittest.TestCase):
12
+ def setUp(self):
13
+ self.api = BacklogAPI("space", "api_key")
14
+ self.space = "space"
15
+ self.api_key = "api_key"
16
+
17
+ @httpretty.activate
18
+ def test_invoke_get(self):
19
+ expects = {
20
+ "ok": True
21
+ }
22
+ _uri = "test"
23
+
24
+ # Status Pattern
25
+ _http_statuses = [200, 201]
26
+
27
+ for _status_code in _http_statuses:
28
+ with self.subTest(status_code=_status_code):
29
+ httpretty.register_uri(
30
+ httpretty.GET,
31
+ API_ENDPOINT.format(space=self.space, uri=_uri),
32
+ body=json.dumps(expects),
33
+ content_type="application/json",
34
+ status=_status_code
35
+ )
36
+
37
+ resp = self.api.invoke_method("GET", _uri)
38
+ self.assertEqual(_status_code, resp.status_code)
39
+ self.assertEqual(expects, resp.json())
40
+
41
+ # Test 204(NO_CONTENT) Response
42
+ # NOTE: 204 response MUST NOT include a message-body.
43
+ # http://tools.ietf.org/search/rfc2616#section-10.2.5
44
+ httpretty.register_uri(
45
+ httpretty.GET,
46
+ API_ENDPOINT.format(space=self.space, uri=_uri),
47
+ content_type="application/json",
48
+ status=204
49
+ )
50
+
51
+ resp = self.api.invoke_method("GET", _uri)
52
+ self.assertEqual(204, resp.status_code)
53
+
54
+ @httpretty.activate
55
+ def test_invoke_post(self):
56
+ expects = {
57
+ "ok": True
58
+ }
59
+ _uri = "test"
60
+
61
+ # Status Pattern
62
+ _http_statuses = [200, 201]
63
+
64
+ for _status_code in _http_statuses:
65
+ with self.subTest(status_code=_status_code):
66
+ httpretty.register_uri(
67
+ httpretty.POST,
68
+ API_ENDPOINT.format(space=self.space, uri=_uri),
69
+ body=json.dumps(expects),
70
+ content_type="application/json",
71
+ status=_status_code
72
+ )
73
+
74
+ resp = self.api.invoke_method("POST", _uri)
75
+ self.assertEqual(_status_code, resp.status_code)
76
+ self.assertEqual(expects, resp.json())
77
+
78
+ @httpretty.activate
79
+ def test_invoke_delete(self):
80
+ expects = {
81
+ "ok": True
82
+ }
83
+ _uri = "test"
84
+
85
+ # Status 200
86
+ httpretty.register_uri(
87
+ httpretty.DELETE,
88
+ API_ENDPOINT.format(space=self.space, uri=_uri),
89
+ body=json.dumps(expects),
90
+ content_type="application/json",
91
+ status=200
92
+ )
93
+
94
+ resp = self.api.invoke_method("DELETE", _uri)
95
+ self.assertEqual(200, resp.status_code)
96
+ self.assertEqual(expects, resp.json())
97
+
98
+ @httpretty.activate
99
+ def test_invoke_patch(self):
100
+ expects = {
101
+ "ok": True
102
+ }
103
+ _uri = "test"
104
+
105
+ # Status 200
106
+ httpretty.register_uri(
107
+ httpretty.PATCH,
108
+ API_ENDPOINT.format(space=self.space, uri=_uri),
109
+ body=json.dumps(expects),
110
+ content_type="application/json",
111
+ status=200
112
+ )
113
+
114
+ resp = self.api.invoke_method("PATCH", _uri)
115
+ self.assertEqual(200, resp.status_code)
116
+ self.assertEqual(expects, resp.json())
117
+
118
+
119
+ if __name__ == "__main__":
120
+ unittest.main(warnings='ignore')
@@ -0,0 +1,55 @@
1
+ # coding: utf-8
2
+
3
+ import unittest
4
+ import httpretty
5
+ import json
6
+ import os
7
+ import tempfile
8
+ from backlog.base import BacklogAPI
9
+
10
+ API_ENDPOINT = "https://{space}.backlog.jp/api/v2/{uri}"
11
+
12
+
13
+ class TestAttachment(unittest.TestCase):
14
+ def setUp(self):
15
+ self.api = BacklogAPI("space", "api_key")
16
+ self.space = "space"
17
+ self.api_key = "api_key"
18
+
19
+ # tempfile
20
+ self.test_dir = tempfile.mkdtemp()
21
+ self.test_fd, self.test_file = tempfile.mkstemp(dir=self.test_dir)
22
+ self.test_data = b"1234567890"
23
+
24
+ with open(self.test_fd, "wb") as fp:
25
+ fp.write(self.test_data)
26
+
27
+ @httpretty.activate
28
+ def test_upload_attachment(self):
29
+ _uri = "space/attachment"
30
+ _filename = os.path.basename(self.test_file)
31
+ expects = {
32
+ "id": 1,
33
+ "name": _filename,
34
+ "size": 8857
35
+ }
36
+ httpretty.register_uri(
37
+ httpretty.POST,
38
+ API_ENDPOINT.format(space=self.space, uri=_uri),
39
+ body=json.dumps(expects)
40
+ )
41
+
42
+ # test
43
+ resp = self.api.attachment.upload(filename=self.test_file)
44
+ self.assertTrue(expects, resp)
45
+
46
+ @httpretty.activate
47
+ def test_upload_attachment_file_not_found(self):
48
+ _filename = "not_exist_file.txt"
49
+
50
+ with self.assertRaises(FileNotFoundError):
51
+ self.api.attachment.upload(filename=_filename)
52
+
53
+
54
+ if __name__ == "__main__":
55
+ unittest.main(warnings='ignore')
@@ -0,0 +1,97 @@
1
+ import unittest
2
+ import json
3
+ import httpretty
4
+ from backlog.base import BacklogAPI
5
+
6
+ API_ENDPOINT = "https://{space}.backlog.jp/api/v2/{path}"
7
+
8
+
9
+ class TestCategory(unittest.TestCase):
10
+ def setUp(self) -> None:
11
+ self.api = BacklogAPI("space", "api_key")
12
+ self.space = "space"
13
+ self.api_key = "api_key"
14
+ self.project = "test-project"
15
+
16
+ @httpretty.activate
17
+ def test_list(self):
18
+ expects = [
19
+ {
20
+ "id": 100,
21
+ "projectId": 1,
22
+ "name": "test-category",
23
+ "displayOrder": 1
24
+ },
25
+ ]
26
+ path = f"projects/{self.project}/categories"
27
+ httpretty.register_uri(
28
+ httpretty.GET,
29
+ API_ENDPOINT.format(space=self.space, path=path),
30
+ body=json.dumps(expects),
31
+ content_type="application/json"
32
+ )
33
+
34
+ resp = self.api.category.list(self.project)
35
+ self.assertEqual(expects, resp)
36
+
37
+ @httpretty.activate
38
+ def test_add(self):
39
+ category = "test-category"
40
+ expects = {
41
+ "id": 100,
42
+ "projectId": 1,
43
+ "name": category,
44
+ "displayOrder": 1
45
+ }
46
+ path = f"projects/{self.project}/categories"
47
+ httpretty.register_uri(
48
+ httpretty.POST,
49
+ API_ENDPOINT.format(space=self.space, path=path),
50
+ body=json.dumps(expects),
51
+ content_type="application/json"
52
+ )
53
+
54
+ resp = self.api.category.add(self.project, category)
55
+ self.assertEqual(expects, resp)
56
+
57
+ @httpretty.activate
58
+ def test_update(self):
59
+ category_id = 100
60
+ category = "updated-category"
61
+ expects = {
62
+ "id": category_id,
63
+ "projectId": 1,
64
+ "name": category,
65
+ "displayOrder": 1
66
+ }
67
+ path = f"projects/{self.project}/categories/{category_id}"
68
+ httpretty.register_uri(
69
+ httpretty.PATCH,
70
+ API_ENDPOINT.format(space=self.space, path=path),
71
+ body=json.dumps(expects),
72
+ content_type="application/json"
73
+ )
74
+
75
+ resp = self.api.category.update(self.project, category_id, category)
76
+ self.assertEqual(expects, resp)
77
+
78
+ @httpretty.activate
79
+ def test_delete(self):
80
+ category_id = 100
81
+ category = "deleted-category"
82
+ expects = {
83
+ "id": category_id,
84
+ "projectId": 1,
85
+ "name": category,
86
+ "displayOrder": 1
87
+ }
88
+ path = f"projects/{self.project}/categories/{category_id}"
89
+ httpretty.register_uri(
90
+ httpretty.DELETE,
91
+ API_ENDPOINT.format(space=self.space, path=path),
92
+ body=json.dumps(expects),
93
+ content_type="application/json"
94
+ )
95
+
96
+ resp = self.api.category.delete(self.project, category_id)
97
+ self.assertEqual(expects, resp)