things-py 0.0.7__tar.gz → 0.0.9.dev0__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.
- {things.py-0.0.7 → things.py-0.0.9.dev0}/PKG-INFO +1 -1
- things.py-0.0.9.dev0/setup.cfg +19 -0
- {things.py-0.0.7 → things.py-0.0.9.dev0}/setup.py +0 -2
- things.py-0.0.9.dev0/tests/test_things.py +183 -0
- {things.py-0.0.7 → things.py-0.0.9.dev0}/things/__init__.py +11 -0
- {things.py-0.0.7 → things.py-0.0.9.dev0}/things/api.py +153 -70
- {things.py-0.0.7 → things.py-0.0.9.dev0}/things/database.py +333 -181
- {things.py-0.0.7 → things.py-0.0.9.dev0}/things.py.egg-info/PKG-INFO +1 -1
- {things.py-0.0.7 → things.py-0.0.9.dev0}/things.py.egg-info/SOURCES.txt +1 -0
- things.py-0.0.7/setup.cfg +0 -4
- things.py-0.0.7/tests/test_things.py +0 -126
- {things.py-0.0.7 → things.py-0.0.9.dev0}/README.md +0 -0
- {things.py-0.0.7 → things.py-0.0.9.dev0}/tests/__init__.py +0 -0
- {things.py-0.0.7 → things.py-0.0.9.dev0}/things.py.egg-info/dependency_links.txt +0 -0
- {things.py-0.0.7 → things.py-0.0.9.dev0}/things.py.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
[metadata]
|
|
2
|
+
version = attr: things.__version__
|
|
3
|
+
|
|
4
|
+
[pycodestyle]
|
|
5
|
+
max_line_length = 88
|
|
6
|
+
ignore = E501,E203,W503
|
|
7
|
+
|
|
8
|
+
[flake8]
|
|
9
|
+
max-line-length = 88
|
|
10
|
+
max-complexity = 10
|
|
11
|
+
ignore = E501,E203,W503
|
|
12
|
+
|
|
13
|
+
[pylama]
|
|
14
|
+
ignore = E501,E203,W503
|
|
15
|
+
|
|
16
|
+
[egg_info]
|
|
17
|
+
tag_build =
|
|
18
|
+
tag_date = 0
|
|
19
|
+
|
|
@@ -20,7 +20,6 @@ AUTHOR = "Alexander Willner, Michael B."
|
|
|
20
20
|
AUTHOR_MAIL = "alex@willner.ws"
|
|
21
21
|
DESCRIPTON = "A simple Python 3 library to read your Things app data."
|
|
22
22
|
URL = "https://github.com/thingsapi/things.py"
|
|
23
|
-
VERSION = "0.0.7"
|
|
24
23
|
DATA_FILES = package_files("")
|
|
25
24
|
OPTIONS = {
|
|
26
25
|
"argv_emulation": False,
|
|
@@ -47,7 +46,6 @@ setup(
|
|
|
47
46
|
"Natural Language :: English",
|
|
48
47
|
],
|
|
49
48
|
python_requires=">=3.6",
|
|
50
|
-
version=VERSION,
|
|
51
49
|
data_files=DATA_FILES,
|
|
52
50
|
options={"py2app": OPTIONS},
|
|
53
51
|
setup_requires=["py2app"],
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
"""Module documentation goes here."""
|
|
5
|
+
|
|
6
|
+
import os
|
|
7
|
+
import unittest
|
|
8
|
+
|
|
9
|
+
import things
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
TEST_DATABASE_FILEPATH = "tests/main.sqlite"
|
|
13
|
+
|
|
14
|
+
THINGSDB = things.database.ENVIRONMENT_VARIABLE_WITH_FILEPATH
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class ThingsCase(unittest.TestCase):
|
|
18
|
+
"""Class documentation goes here."""
|
|
19
|
+
|
|
20
|
+
def setUp(self):
|
|
21
|
+
# set environment variable to test database
|
|
22
|
+
self.saved_filepath = os.getenv(THINGSDB)
|
|
23
|
+
os.environ[THINGSDB] = TEST_DATABASE_FILEPATH
|
|
24
|
+
|
|
25
|
+
def tearDown(self):
|
|
26
|
+
# restore environment variable to its previous value
|
|
27
|
+
# or delete it if it wasn't set before running the test.
|
|
28
|
+
if self.saved_filepath is None:
|
|
29
|
+
if THINGSDB in os.environ:
|
|
30
|
+
del os.environ[THINGSDB]
|
|
31
|
+
else:
|
|
32
|
+
os.environ[THINGSDB] = self.saved_filepath
|
|
33
|
+
|
|
34
|
+
def test_get_tag_by_database_filepath(self):
|
|
35
|
+
"""Test get tag by database filepath."""
|
|
36
|
+
del os.environ[THINGSDB]
|
|
37
|
+
tag_uuid = "Qt2AY87x2QDdowSn9HKTt1"
|
|
38
|
+
tag = things.get(tag_uuid, filepath=TEST_DATABASE_FILEPATH)
|
|
39
|
+
self.assertEqual(tag["uuid"], tag_uuid)
|
|
40
|
+
|
|
41
|
+
def test_get_url_scheme_auth_token(self):
|
|
42
|
+
"""Test get url scheme auth token."""
|
|
43
|
+
expected = "vKkylosuSuGwxrz7qcklOw"
|
|
44
|
+
token = things.token()
|
|
45
|
+
self.assertEqual(token, expected)
|
|
46
|
+
|
|
47
|
+
def test_search(self):
|
|
48
|
+
"""Test search."""
|
|
49
|
+
tasks = things.search("wrong_query")
|
|
50
|
+
self.assertEqual(0, len(tasks))
|
|
51
|
+
tasks = things.search("To-Do % Heading")
|
|
52
|
+
self.assertEqual(1, len(tasks))
|
|
53
|
+
|
|
54
|
+
def test_inbox(self):
|
|
55
|
+
"""Test inbox."""
|
|
56
|
+
tasks = things.inbox()
|
|
57
|
+
self.assertEqual(2, len(tasks))
|
|
58
|
+
|
|
59
|
+
def test_upcoming(self):
|
|
60
|
+
"""Test upcoming."""
|
|
61
|
+
tasks = things.upcoming()
|
|
62
|
+
self.assertEqual(1, len(tasks))
|
|
63
|
+
|
|
64
|
+
def test_deadlines(self):
|
|
65
|
+
"""Test deadlines."""
|
|
66
|
+
tasks = things.deadlines()
|
|
67
|
+
self.assertEqual(1, len(tasks))
|
|
68
|
+
|
|
69
|
+
def test_today(self):
|
|
70
|
+
"""Test today."""
|
|
71
|
+
tasks = things.today()
|
|
72
|
+
self.assertEqual(2, len(tasks))
|
|
73
|
+
|
|
74
|
+
def test_checklist(self):
|
|
75
|
+
"""Test checklist."""
|
|
76
|
+
checklist_items = things.checklist_items("3Eva4XFof6zWb9iSfYy4ej")
|
|
77
|
+
self.assertEqual(3, len(checklist_items))
|
|
78
|
+
checklist_items = things.checklist_items("K9bx7h1xCJdevvyWardZDq")
|
|
79
|
+
self.assertEqual(0, len(checklist_items))
|
|
80
|
+
|
|
81
|
+
def test_anytime(self):
|
|
82
|
+
"""Test anytime."""
|
|
83
|
+
tasks = things.anytime()
|
|
84
|
+
self.assertEqual(11, len(tasks))
|
|
85
|
+
self.assertTrue(any(task.get("area_title") == "Area 1" for task in tasks))
|
|
86
|
+
|
|
87
|
+
def test_logbook(self):
|
|
88
|
+
"""Test logbook."""
|
|
89
|
+
tasks = things.logbook()
|
|
90
|
+
self.assertEqual(21, len(tasks))
|
|
91
|
+
|
|
92
|
+
def test_canceled(self):
|
|
93
|
+
"""Test canceled."""
|
|
94
|
+
tasks = things.canceled()
|
|
95
|
+
self.assertEqual(11, len(tasks))
|
|
96
|
+
|
|
97
|
+
def test_completed(self):
|
|
98
|
+
"""Test completed."""
|
|
99
|
+
tasks = things.completed()
|
|
100
|
+
self.assertEqual(10, len(tasks))
|
|
101
|
+
|
|
102
|
+
def test_someday(self):
|
|
103
|
+
"""Test someday."""
|
|
104
|
+
tasks = things.someday()
|
|
105
|
+
self.assertEqual(1, len(tasks))
|
|
106
|
+
|
|
107
|
+
def test_get(self):
|
|
108
|
+
"""Test get."""
|
|
109
|
+
task = things.get("wrong_uuid")
|
|
110
|
+
self.assertEqual(None, task)
|
|
111
|
+
task = things.get("wrong_uuid", "NOT FOUND")
|
|
112
|
+
self.assertEqual("NOT FOUND", task)
|
|
113
|
+
task = things.get("Qt2AY87x2QDdowSn9HKTt1")
|
|
114
|
+
self.assertEqual(4, len(task.keys()))
|
|
115
|
+
|
|
116
|
+
def test_todos(self):
|
|
117
|
+
"""Test all to-dos."""
|
|
118
|
+
todos = things.todos(start="Anytime")
|
|
119
|
+
self.assertEqual(8, len(todos))
|
|
120
|
+
todos = things.todos(start="Anytime", status="completed")
|
|
121
|
+
self.assertEqual(6, len(todos))
|
|
122
|
+
todos = things.todos(status="completed")
|
|
123
|
+
self.assertEqual(10, len(todos))
|
|
124
|
+
todos = things.todos(include_items=True)
|
|
125
|
+
self.assertEqual(12, len(todos))
|
|
126
|
+
with self.assertRaises(ValueError):
|
|
127
|
+
things.todos(status="wrong_value")
|
|
128
|
+
todo = things.todos("A2oPvtt4dXoypeoLc8uYzY")
|
|
129
|
+
self.assertEqual(16, len(todo.keys()))
|
|
130
|
+
|
|
131
|
+
def test_tags(self):
|
|
132
|
+
"""Test all tags."""
|
|
133
|
+
tags = things.tags()
|
|
134
|
+
self.assertEqual(5, len(tags))
|
|
135
|
+
tasks = things.tasks(tag="Errand")
|
|
136
|
+
self.assertEqual(1, len(tasks))
|
|
137
|
+
|
|
138
|
+
def test_projects(self):
|
|
139
|
+
"""Test all projects."""
|
|
140
|
+
projects = things.projects()
|
|
141
|
+
self.assertEqual(2, len(projects))
|
|
142
|
+
|
|
143
|
+
def test_areas(self):
|
|
144
|
+
"""Test all test_areas."""
|
|
145
|
+
areas = things.areas()
|
|
146
|
+
self.assertEqual(3, len(areas))
|
|
147
|
+
|
|
148
|
+
def test_database_version(self):
|
|
149
|
+
"""Test database version."""
|
|
150
|
+
version = things.Database().get_version()
|
|
151
|
+
self.assertEqual(18, version)
|
|
152
|
+
|
|
153
|
+
def test_last(self):
|
|
154
|
+
"""Test last parameter"""
|
|
155
|
+
last_tasks = things.last("1d")
|
|
156
|
+
self.assertEqual(len(last_tasks), 0)
|
|
157
|
+
|
|
158
|
+
last_tasks = things.last("10000w")
|
|
159
|
+
self.assertEqual(len(last_tasks), 15)
|
|
160
|
+
|
|
161
|
+
last_tasks = things.last("100y", status="completed")
|
|
162
|
+
self.assertEqual(len(last_tasks), 10)
|
|
163
|
+
|
|
164
|
+
with self.assertRaises(ValueError):
|
|
165
|
+
things.last(None)
|
|
166
|
+
|
|
167
|
+
with self.assertRaises(ValueError):
|
|
168
|
+
things.last("XYZ")
|
|
169
|
+
|
|
170
|
+
with self.assertRaises(ValueError):
|
|
171
|
+
things.last("")
|
|
172
|
+
|
|
173
|
+
with self.assertRaises(ValueError):
|
|
174
|
+
things.last("3X")
|
|
175
|
+
|
|
176
|
+
def test_tasks(self):
|
|
177
|
+
"""Test tasks"""
|
|
178
|
+
count = things.tasks(status="completed", last="100y", count_only=True)
|
|
179
|
+
self.assertEqual(count, 10)
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
if __name__ == "__main__":
|
|
183
|
+
unittest.main()
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
"""A simple Python 3 library to read your Things app data."""
|
|
2
2
|
|
|
3
|
+
__author__ = ["Alexander Willner", "Michael Belfrage"]
|
|
4
|
+
__copyright__ = "2021 Alexander Willner & Michael Belfrage"
|
|
5
|
+
__credits__ = ["Alexander Willner", "Michael Belfrage"]
|
|
6
|
+
__license__ = "Apache License 2.0"
|
|
7
|
+
__version__ = "0.0.9.dev"
|
|
8
|
+
__maintainer__ = ["Alexander Willner", "Michael Belfrage"]
|
|
9
|
+
__email__ = "alex@willner.ws"
|
|
10
|
+
__status__ = "Development"
|
|
11
|
+
|
|
3
12
|
from things.api import ( # noqa
|
|
4
13
|
anytime,
|
|
5
14
|
areas,
|
|
@@ -9,6 +18,7 @@ from things.api import ( # noqa
|
|
|
9
18
|
deadlines,
|
|
10
19
|
get,
|
|
11
20
|
inbox,
|
|
21
|
+
last,
|
|
12
22
|
link,
|
|
13
23
|
logbook,
|
|
14
24
|
projects,
|
|
@@ -19,6 +29,7 @@ from things.api import ( # noqa
|
|
|
19
29
|
tasks,
|
|
20
30
|
today,
|
|
21
31
|
todos,
|
|
32
|
+
token,
|
|
22
33
|
upcoming,
|
|
23
34
|
)
|
|
24
35
|
from things.database import Database # noqa
|