Skip to content

Commit 5bb68fa

Browse files
committed
split up tests
1 parent 9effcaa commit 5bb68fa

File tree

2 files changed

+2
-65
lines changed

2 files changed

+2
-65
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,4 @@ dmypy.json
133133
auth.json
134134
.coveragerc
135135
*.db
136+
tests/test_hidden.py

tests/test_toggl_to_sqlite.py

Lines changed: 1 addition & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,6 @@
99
import random
1010

1111

12-
def load_auth():
13-
try:
14-
json_path = pathlib.Path(__file__).parents[1] / "auth.json"
15-
return json.load(open(json_path, "r"))
16-
except FileNotFoundError:
17-
return {"api_token": "api_token"}
18-
19-
API_TOKEN = load_auth()['api_token']
20-
2112
def load():
2213
json_path = pathlib.Path(__file__).parent / "toggl.json"
2314
return json.load(open(json_path, "r"))
@@ -56,57 +47,19 @@ def test_get_start_datetime_bad_api_token():
5647
start_date = utils.get_start_datetime(api_token=api_token)
5748
assert start_date == datetime.date.today()
5849

59-
def test_get_start_datetime_good_api_token_blank_since():
60-
"""
61-
Need to figure out how to mock this
62-
"""
63-
api_token = API_TOKEN
64-
start_date = utils.get_start_datetime(api_token=api_token)
65-
assert start_date == datetime.date(2019, 12, 4)
66-
67-
68-
def test_get_start_datetime_good_api_token_non_blank_since():
69-
"""
70-
Need to figure out how to mock this
71-
"""
72-
api_token = API_TOKEN
73-
since = datetime.datetime(2020,12,4)
74-
start_date = utils.get_start_datetime(api_token=api_token, since=since)
75-
assert start_date == since.date()
76-
7750

7851
def test_get_workspaces_bad_api_token():
7952
api_token = "api_token"
8053
workspaces = utils.get_workspaces(api_token=api_token)
8154
assert workspaces == []
8255

83-
def test_get_workspaces_good_api_token():
84-
"""
85-
Need to figure out how to mock this
86-
"""
87-
api_token = API_TOKEN
88-
actual = utils.get_workspaces(api_token=api_token)
89-
expected = [[{'id': 1806100, 'name': "Rcheley's workspace", 'profile': 0, 'premium': False, 'admin': True, 'default_hourly_rate': 0, 'default_currency': 'USD', 'only_admins_may_create_projects': False, 'only_admins_see_billable_rates': False, 'only_admins_see_team_dashboard': False, 'projects_billable_by_default': True, 'rounding': 1, 'rounding_minutes': 0, 'api_token': '775c077edcdd0935c38cbfff99bbca96', 'at': '2016-12-15T06:53:39+00:00', 'ical_enabled': True}, {'id': 3829545, 'name': 'DOHC Business Informatics', 'profile': 101, 'premium': True, 'admin': True, 'default_hourly_rate': 0, 'default_currency': 'USD', 'only_admins_may_create_projects': False, 'only_admins_see_billable_rates': False, 'only_admins_see_team_dashboard': False, 'projects_billable_by_default': True, 'rounding': 1, 'rounding_minutes': 0, 'api_token': 'efb896083b906202d81d1fb78b69c313', 'at': '2019-12-04T05:14:38+00:00', 'logo_url': 'https://assets.toggl.com/images/workspace.jpg', 'ical_url': '/ical/workspace_user/df8d9fa987994f84f4f770d799c72e01', 'ical_enabled': True}]]
90-
assert expected == actual
91-
92-
9356
def test_get_projects_bad_api():
9457
api_token = "api_token"
9558
actual = utils.get_projects(api_token=api_token)
9659
expected = []
9760
assert actual == expected
9861

9962

100-
def test_get_projects_good_api():
101-
"""
102-
Need to figure out how to mock this
103-
"""
104-
api_token = API_TOKEN
105-
actual = utils.get_projects(api_token=api_token)
106-
expected = [[{'id': 155736600, 'wid': 3829545, 'name': 'Administration', 'billable': False, 'is_private': True, 'active': True, 'template': False, 'at': '2020-06-09T04:02:21+00:00', 'created_at': '2019-12-04T05:02:20+00:00', 'color': '0', 'auto_estimates': False, 'actual_hours': 1113, 'hex_color': '#0b83d9'}, {'id': 157266743, 'wid': 3829545, 'name': 'Commuting', 'billable': False, 'is_private': True, 'active': True, 'template': False, 'at': '2020-06-09T04:07:28+00:00', 'created_at': '2020-02-15T16:58:36+00:00', 'color': '14', 'auto_estimates': False, 'actual_hours': 2, 'hex_color': '#525266'}, {'id': 155771467, 'wid': 3829545, 'name': 'Exercise', 'billable': False, 'is_private': True, 'active': True, 'template': False, 'at': '2020-06-09T04:02:33+00:00', 'created_at': '2019-12-05T13:55:29+00:00', 'color': '11', 'auto_estimates': False, 'actual_hours': 9, 'hex_color': '#566614'}, {'id': 157105935, 'wid': 3829545, 'name': 'Family Time', 'billable': False, 'is_private': True, 'active': True, 'template': False, 'at': '2020-06-09T04:07:18+00:00', 'created_at': '2020-02-10T00:59:21+00:00', 'color': '6', 'auto_estimates': False, 'currency': 'USD', 'hex_color': '#06a893'}, {'id': 155736594, 'wid': 3829545, 'name': 'Issue work', 'billable': False, 'is_private': True, 'active': True, 'template': False, 'at': '2020-06-09T04:02:21+00:00', 'created_at': '2019-12-04T05:02:02+00:00', 'color': '12', 'auto_estimates': False, 'actual_hours': 462, 'hex_color': '#991102'}, {'id': 155736597, 'wid': 3829545, 'name': 'Meeting Prep', 'billable': False, 'is_private': True, 'active': True, 'template': False, 'at': '2020-06-09T04:02:21+00:00', 'created_at': '2019-12-04T05:02:09+00:00', 'color': '6', 'auto_estimates': False, 'actual_hours': 60, 'hex_color': '#06a893'}, {'id': 155736591, 'wid': 3829545, 'name': 'Meetings', 'billable': False, 'is_private': True, 'active': True, 'template': False, 'at': '2020-06-09T04:02:21+00:00', 'created_at': '2019-12-04T05:01:50+00:00', 'color': '8', 'auto_estimates': False, 'actual_hours': 1049, 'hex_color': '#465bb3'}, {'id': 155980477, 'wid': 3829545, 'name': 'Personal', 'billable': False, 'is_private': True, 'active': True, 'template': False, 'at': '2020-06-09T04:03:35+00:00', 'created_at': '2019-12-17T14:47:48+00:00', 'color': '13', 'auto_estimates': False, 'actual_hours': 232, 'hex_color': '#d92b2b'}, {'id': 157777117, 'wid': 3829545, 'name': 'PTO', 'billable': False, 'is_private': True, 'active': True, 'template': False, 'at': '2020-06-09T04:09:52+00:00', 'created_at': '2020-03-06T13:50:25+00:00', 'color': '14', 'auto_estimates': False, 'actual_hours': 27, 'hex_color': '#525266'}, {'id': 157105842, 'wid': 3829545, 'name': 'Reading', 'billable': False, 'is_private': True, 'active': True, 'template': False, 'at': '2020-06-09T04:07:18+00:00', 'created_at': '2020-02-10T00:48:16+00:00', 'color': '7', 'auto_estimates': False, 'currency': 'USD', 'hex_color': '#c9806b'}, {'id': 155736593, 'wid': 3829545, 'name': 'Team Development', 'billable': False, 'is_private': True, 'active': True, 'template': False, 'at': '2020-06-09T04:02:21+00:00', 'created_at': '2019-12-04T05:01:57+00:00', 'color': '10', 'auto_estimates': False, 'actual_hours': 16, 'hex_color': '#c7af14'}, {'id': 155932445, 'wid': 3829545, 'name': 'Watching Videos', 'billable': False, 'is_private': True, 'active': True, 'template': False, 'at': '2020-06-09T04:03:32+00:00', 'created_at': '2019-12-15T02:31:58+00:00', 'color': '14', 'auto_estimates': False, 'hex_color': '#525266'}, {'id': 157105845, 'wid': 3829545, 'name': 'Writing Code', 'billable': False, 'is_private': True, 'active': True, 'template': False, 'at': '2020-06-09T04:07:18+00:00', 'created_at': '2020-02-10T00:48:25+00:00', 'color': '13', 'auto_estimates': False, 'currency': 'USD', 'hex_color': '#d92b2b'}]]
107-
assert actual == expected
108-
109-
11063
def test_get_time_entries_bad_api():
11164
api_token = "api_token"
11265
actual = utils.get_time_entries(api_token=api_token, days=25)
@@ -123,21 +76,4 @@ def test_get_time_entries_bad_days():
12376
api_token = "api_token"
12477
actual = utils.get_time_entries(api_token=api_token, days=days)
12578
expepected = []
126-
assert actual == expepected
127-
128-
129-
130-
def test_get_time_entries_good_api():
131-
"""
132-
Need to figure out how to mock this
133-
"""
134-
api_token = API_TOKEN
135-
actual = utils.get_time_entries(api_token=api_token, days=25)
136-
assert len(actual) == 19
137-
138-
139-
def test_get_time_entries_since_in_the_future():
140-
since = since = datetime.datetime.today() + datetime.timedelta(days=1)
141-
api_token = API_TOKEN
142-
actual = utils.get_time_entries(api_token=api_token, days=25, since=since)
143-
assert len(actual) == 0
79+
assert actual == expepected

0 commit comments

Comments
 (0)