Skip to content

Commit

Permalink
Fix failing tests on Python3.10+ by rewriting vcrpy casettes (#21)
Browse files Browse the repository at this point in the history
* Rewrite vcrpy casettes

When running toggl-track on Python 3.10+ all tests using vcrpy fail,
while they keep running on 3.8 and 3.9.

The new default for vcrpy is to store the request body as a string,
so I decided to rewrite the cassettes.

* Pin Pydantic < 2

* Run tests on push only

* Fix syntax error

* Pin dependencies to avoid drift

* Require pytest 7.4.4 to keep Python 3.7 compatibility
  • Loading branch information
zmoog authored Apr 26, 2024
1 parent 05d5bb3 commit 9cce38e
Show file tree
Hide file tree
Showing 16 changed files with 293 additions and 550 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Test

on: [push, pull_request]
on: [push]

permissions:
contents: read
Expand Down
12 changes: 6 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ def get_long_description():
tgl=toggl_track.cli:cli
""",
install_requires=[
"click",
"pydantic",
"requests",
"rich",
"click == 8.1.7",
"pydantic < 2",
"requests == 2.31.0",
"rich == 13.7.1",
],
extras_require={
"test": [
"pytest",
"pytest-recording",
"pytest == 7.4.4",
"pytest-recording == 0.13.1",
]
},
python_requires=">=3.7",
Expand Down
55 changes: 17 additions & 38 deletions tests/cassettes/test_entries_group_by/test_group_by_initiative.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,70 +9,49 @@ interactions:
Connection:
- keep-alive
User-Agent:
- python-requests/2.28.2
- python-requests/2.31.0
method: GET
uri: https://api.track.toggl.com/api/v9/me/time_entries?start_date=2023-01-26T00%3A00%3A00Z&end_date=2023-01-27T00%3A00%3A00Z
uri: https://api.track.toggl.com/api/v9/me/time_entries?start_date=2024-01-26T00%3A00%3A00Z&end_date=2024-01-27T00%3A00%3A00Z
response:
body:
string: !!binary |
H4sIAAAAAAAEA9WZ3Y7jNBTHX8XKLR3JH7GT+G6ZYaWVQCDNSkisViNP47bZpklInC2ziDd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Sa3kJPq+
hOkEjDoKtMjTDbrRSfQBXafFukwuT+jAy8YmRD3ieZMEEJOYDI+XCMyWQEYJmxBnbr/ZrSIFtDVM
mNK8KkZX6Fut1zADqkdE3ehoo7WB5/boKAiYgAL3tKhrN9QF/dg4YJbGPXFSwLS17LxaRAGFZEO9
D4g+mAQe0iBuEBzWItDPv6Evy2S+6sz/ifIZ/gzQ8730ekFLt5baLxyE+rwagY2fmajEUBYHJdgO
BrH9Hlyh5/fFQzLvbNwUhWrNMnczGiUnOHjzz9M5OPa48CapCJBs4POE3Ws0tt0pqSqWrbaWCtp3
GHCm217G/5cZpucdF/T7o4oJw2h6kvsEAvEMgmNoOEZ2jA4cvxq9HwJQlcalEsbM9W1C2RsxL1MV
H40CdkIUNNuYLAo8z2e0ur0ZPftg6P5cSQZ7joaTHQUB7uf5i2efnoeM7Pyeh6G+Qv06we4BxzQQ
VZN+xl0azLypL929ctbrFoAMfAi2zU6ZgOpvJx+TLpfxlcnVfC2hV4DLluqiBUGDkEd6r0ewasDT
Xt9uYBSvb623V3I9GHrgAOw5uvHrLpQP+TzwgTkDPhhYEeH3LsXGMn6zgemMz+Am+bS628ql8zxf
VHJnsOxWNbca3x54PnePCMs/fkGf51qtF9CRdcLnUz295xAXzDOttSxPJxga3wk8vbr7He6pwNg1
D9vYjAa98d5Ynt5ziAsa/zHNvP0bd0fgfDIhAAA=
string: "[{\"id\":3297435983,\"workspace_id\":1815018,\"project_id\":178435728,\"task_id\":null,\"billable\":false,\"start\":\"2024-01-26T17:26:31+00:00\",\"stop\":\"2024-01-26T18:00:35+00:00\",\"duration\":2044,\"description\":\"IHAC
using AWS WAF integration and expresses concern about the throughput\",\"tags\":[\"type:support/question\"],\"tag_ids\":[14969753],\"duronly\":true,\"at\":\"2024-01-28T08:39:01+00:00\",\"server_deleted_at\":null,\"user_id\":2621333,\"uid\":2621333,\"wid\":1815018,\"pid\":178435728,\"permissions\":null},{\"id\":3297355840,\"workspace_id\":1815018,\"project_id\":28041930,\"task_id\":null,\"billable\":false,\"start\":\"2024-01-26T16:34:40+00:00\",\"stop\":\"2024-01-26T17:26:32+00:00\",\"duration\":3112,\"description\":\"\U0001F68C
Shuttling kids between home and whatever\",\"tags\":[],\"tag_ids\":[],\"duronly\":true,\"at\":\"2024-01-26T17:26:32+00:00\",\"server_deleted_at\":null,\"user_id\":2621333,\"uid\":2621333,\"wid\":1815018,\"pid\":28041930,\"permissions\":null},{\"id\":3297169916,\"workspace_id\":1815018,\"project_id\":178435728,\"task_id\":null,\"billable\":false,\"start\":\"2024-01-26T14:48:28+00:00\",\"stop\":\"2024-01-26T16:34:41+00:00\",\"duration\":6373,\"description\":\"S3
SQS ingest delay in performance with Elastic Agent #4264\",\"tags\":[\"type:support/sdh\"],\"tag_ids\":[15007828],\"duronly\":true,\"at\":\"2024-01-26T16:34:41+00:00\",\"server_deleted_at\":null,\"user_id\":2621333,\"uid\":2621333,\"wid\":1815018,\"pid\":178435728,\"permissions\":null},{\"id\":3297063846,\"workspace_id\":1815018,\"project_id\":178435728,\"task_id\":null,\"billable\":false,\"start\":\"2024-01-26T13:50:21+00:00\",\"stop\":\"2024-01-26T14:48:28+00:00\",\"duration\":3487,\"description\":\"Migrate
to ecs@mappings template shipped with Elasticsearch [step 3]\",\"tags\":[\"type:goal\"],\"tag_ids\":[12078063],\"duronly\":true,\"at\":\"2024-01-26T14:48:28+00:00\",\"server_deleted_at\":null,\"user_id\":2621333,\"uid\":2621333,\"wid\":1815018,\"pid\":178435728,\"permissions\":null},{\"id\":3297055770,\"workspace_id\":1815018,\"project_id\":178435728,\"task_id\":null,\"billable\":false,\"start\":\"2024-01-26T13:45:19+00:00\",\"stop\":\"2024-01-26T13:50:21+00:00\",\"duration\":302,\"description\":\"sync\",\"tags\":[\"type:sync\"],\"tag_ids\":[12078061],\"duronly\":true,\"at\":\"2024-01-26T13:50:21+00:00\",\"server_deleted_at\":null,\"user_id\":2621333,\"uid\":2621333,\"wid\":1815018,\"pid\":178435728,\"permissions\":null},{\"id\":3296925719,\"workspace_id\":1815018,\"project_id\":28041930,\"task_id\":null,\"billable\":false,\"start\":\"2024-01-26T12:20:36+00:00\",\"stop\":\"2024-01-26T13:45:19+00:00\",\"duration\":5083,\"description\":\"\U0001F35C
Lunch\",\"tags\":[],\"tag_ids\":[],\"duronly\":true,\"at\":\"2024-01-26T13:45:19+00:00\",\"server_deleted_at\":null,\"user_id\":2621333,\"uid\":2621333,\"wid\":1815018,\"pid\":28041930,\"permissions\":null},{\"id\":3296620722,\"workspace_id\":1815018,\"project_id\":178435728,\"task_id\":null,\"billable\":false,\"start\":\"2024-01-26T08:44:02+00:00\",\"stop\":\"2024-01-26T12:20:37+00:00\",\"duration\":12995,\"description\":\"Migrate
to ecs@mappings template shipped with Elasticsearch [step 3]\",\"tags\":[\"type:goal\"],\"tag_ids\":[12078063],\"duronly\":true,\"at\":\"2024-01-26T12:20:37+00:00\",\"server_deleted_at\":null,\"user_id\":2621333,\"uid\":2621333,\"wid\":1815018,\"pid\":178435728,\"permissions\":null},{\"id\":3296545927,\"workspace_id\":1815018,\"project_id\":178435728,\"task_id\":null,\"billable\":false,\"start\":\"2024-01-26T07:48:47+00:00\",\"stop\":\"2024-01-26T08:44:02+00:00\",\"duration\":3315,\"description\":\"sync\",\"tags\":[\"type:sync\"],\"tag_ids\":[12078061],\"duronly\":true,\"at\":\"2024-01-26T08:44:02+00:00\",\"server_deleted_at\":null,\"user_id\":2621333,\"uid\":2621333,\"wid\":1815018,\"pid\":178435728,\"permissions\":null}]"
headers:
Alt-Svc:
- h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
Cache-Control:
- no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0
Content-Encoding:
- gzip
Content-Length:
- '3477'
Content-Type:
- application/json; charset=utf-8
Date:
- Mon, 06 Feb 2023 04:51:02 GMT
- Fri, 26 Apr 2024 04:59:26 GMT
Instance:
- time-public-api
- track-public-api-proxy-f666f86df-kw6z2
Referrer-Policy:
- strict-origin-when-cross-origin
Server:
- nginx
Strict-Transport-Security:
- max-age=15552000; includeSubDomains
Transfer-Encoding:
- chunked
Vary:
- Accept-Encoding
Via:
- 1.1 google
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- SAMEORIGIN
X-Request-ID:
- bc548dc060c4f515eb43a2fe1591c8a7
- 347b30cd322573b65a1f7f194b69867b
X-Service-Level:
- GREEN
X-Toggl-Request-Id:
- bc548dc060c4f515eb43a2fe1591c8a7
- 99c18309-93a8-498b-9339-7e8408412d02
X-We-are-hiring:
- https://toggl.com/jobs/
status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,70 +9,49 @@ interactions:
Connection:
- keep-alive
User-Agent:
- python-requests/2.28.2
- python-requests/2.31.0
method: GET
uri: https://api.track.toggl.com/api/v9/me/time_entries?start_date=2023-01-26T00%3A00%3A00Z&end_date=2023-01-27T00%3A00%3A00Z
uri: https://api.track.toggl.com/api/v9/me/time_entries?start_date=2024-01-26T00%3A00%3A00Z&end_date=2024-01-27T00%3A00%3A00Z
response:
body:
string: !!binary |
H4sIAAAAAAAEA9WZ3Y7jNBTHX8XKLR3JH7GT+G6ZYaWVQCDNSkisViNP47bZpklInC2ziDdgJa4R
Ele8AE/GI3CSJpO6KZluacIg9aZO1Nrndz7+5/jNj04UOpL6JCCU48CbOds0XxeZmuu76gnxCcfE
nzlZnr7Tc7Nb9HyXcY/CslHFul5LyjieOfdRHKv7WDtyoeJCz5zCqNw40qGYsitMrqh4TamkXDL+
GcYSY6d6J816r3BXMvYdPA3LXJkoTWAvHoN/DHUxz6Nst+Rcp5tNmUTmQaIXcZxuUabyIkqWKF2g
V9+8F0iFYa6LQhcoSuCz1IVBWZTpOEo0/LpRy8KRbxzzkGlZlFmWwnbf1utwrOoRodjzscCwCFtJ
k/jBkSYv4Wyqf7B6193BdP5e53ehjrXR4V31/s5MZQHLteEFJYyxmVNa37a26etvrc1/mnXMsE+p
oFMwI9LlkpDuaMeY1VhtZtSl7gCzl9EPj8R0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ftg6P5cSQZ7joaTHQUB7uf5i2efnoeM7Pyeh6G+Qv06we4BxzQQ
VZN+xl0azLypL929ctbrFoAMfAi2zU6ZgOpvJx+TLpfxlcnVfC2hV4DLluqiBUGDkEd6r0ewasDT
Xt9uYBSvb623V3I9GHrgAOw5uvHrLpQP+TzwgTkDPhhYEeH3LsXGMn6zgemMz+Am+bS628ql8zxf
VHJnsOxWNbca3x54PnePCMs/fkGf51qtF9CRdcLnUz295xAXzDOttSxPJxga3wk8vbr7He6pwNg1
D9vYjAa98d5Ynt5ziAsa/zHNvP0bd0fgfDIhAAA=
string: "[{\"id\":3297435983,\"workspace_id\":1815018,\"project_id\":178435728,\"task_id\":null,\"billable\":false,\"start\":\"2024-01-26T17:26:31+00:00\",\"stop\":\"2024-01-26T18:00:35+00:00\",\"duration\":2044,\"description\":\"IHAC
using AWS WAF integration and expresses concern about the throughput\",\"tags\":[\"type:support/question\"],\"tag_ids\":[14969753],\"duronly\":true,\"at\":\"2024-01-28T08:39:01+00:00\",\"server_deleted_at\":null,\"user_id\":2621333,\"uid\":2621333,\"wid\":1815018,\"pid\":178435728,\"permissions\":null},{\"id\":3297355840,\"workspace_id\":1815018,\"project_id\":28041930,\"task_id\":null,\"billable\":false,\"start\":\"2024-01-26T16:34:40+00:00\",\"stop\":\"2024-01-26T17:26:32+00:00\",\"duration\":3112,\"description\":\"\U0001F68C
Shuttling kids between home and whatever\",\"tags\":[],\"tag_ids\":[],\"duronly\":true,\"at\":\"2024-01-26T17:26:32+00:00\",\"server_deleted_at\":null,\"user_id\":2621333,\"uid\":2621333,\"wid\":1815018,\"pid\":28041930,\"permissions\":null},{\"id\":3297169916,\"workspace_id\":1815018,\"project_id\":178435728,\"task_id\":null,\"billable\":false,\"start\":\"2024-01-26T14:48:28+00:00\",\"stop\":\"2024-01-26T16:34:41+00:00\",\"duration\":6373,\"description\":\"S3
SQS ingest delay in performance with Elastic Agent #4264\",\"tags\":[\"type:support/sdh\"],\"tag_ids\":[15007828],\"duronly\":true,\"at\":\"2024-01-26T16:34:41+00:00\",\"server_deleted_at\":null,\"user_id\":2621333,\"uid\":2621333,\"wid\":1815018,\"pid\":178435728,\"permissions\":null},{\"id\":3297063846,\"workspace_id\":1815018,\"project_id\":178435728,\"task_id\":null,\"billable\":false,\"start\":\"2024-01-26T13:50:21+00:00\",\"stop\":\"2024-01-26T14:48:28+00:00\",\"duration\":3487,\"description\":\"Migrate
to ecs@mappings template shipped with Elasticsearch [step 3]\",\"tags\":[\"type:goal\"],\"tag_ids\":[12078063],\"duronly\":true,\"at\":\"2024-01-26T14:48:28+00:00\",\"server_deleted_at\":null,\"user_id\":2621333,\"uid\":2621333,\"wid\":1815018,\"pid\":178435728,\"permissions\":null},{\"id\":3297055770,\"workspace_id\":1815018,\"project_id\":178435728,\"task_id\":null,\"billable\":false,\"start\":\"2024-01-26T13:45:19+00:00\",\"stop\":\"2024-01-26T13:50:21+00:00\",\"duration\":302,\"description\":\"sync\",\"tags\":[\"type:sync\"],\"tag_ids\":[12078061],\"duronly\":true,\"at\":\"2024-01-26T13:50:21+00:00\",\"server_deleted_at\":null,\"user_id\":2621333,\"uid\":2621333,\"wid\":1815018,\"pid\":178435728,\"permissions\":null},{\"id\":3296925719,\"workspace_id\":1815018,\"project_id\":28041930,\"task_id\":null,\"billable\":false,\"start\":\"2024-01-26T12:20:36+00:00\",\"stop\":\"2024-01-26T13:45:19+00:00\",\"duration\":5083,\"description\":\"\U0001F35C
Lunch\",\"tags\":[],\"tag_ids\":[],\"duronly\":true,\"at\":\"2024-01-26T13:45:19+00:00\",\"server_deleted_at\":null,\"user_id\":2621333,\"uid\":2621333,\"wid\":1815018,\"pid\":28041930,\"permissions\":null},{\"id\":3296620722,\"workspace_id\":1815018,\"project_id\":178435728,\"task_id\":null,\"billable\":false,\"start\":\"2024-01-26T08:44:02+00:00\",\"stop\":\"2024-01-26T12:20:37+00:00\",\"duration\":12995,\"description\":\"Migrate
to ecs@mappings template shipped with Elasticsearch [step 3]\",\"tags\":[\"type:goal\"],\"tag_ids\":[12078063],\"duronly\":true,\"at\":\"2024-01-26T12:20:37+00:00\",\"server_deleted_at\":null,\"user_id\":2621333,\"uid\":2621333,\"wid\":1815018,\"pid\":178435728,\"permissions\":null},{\"id\":3296545927,\"workspace_id\":1815018,\"project_id\":178435728,\"task_id\":null,\"billable\":false,\"start\":\"2024-01-26T07:48:47+00:00\",\"stop\":\"2024-01-26T08:44:02+00:00\",\"duration\":3315,\"description\":\"sync\",\"tags\":[\"type:sync\"],\"tag_ids\":[12078061],\"duronly\":true,\"at\":\"2024-01-26T08:44:02+00:00\",\"server_deleted_at\":null,\"user_id\":2621333,\"uid\":2621333,\"wid\":1815018,\"pid\":178435728,\"permissions\":null}]"
headers:
Alt-Svc:
- h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
Cache-Control:
- no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0
Content-Encoding:
- gzip
Content-Length:
- '3477'
Content-Type:
- application/json; charset=utf-8
Date:
- Fri, 17 Feb 2023 05:34:18 GMT
- Fri, 26 Apr 2024 04:59:26 GMT
Instance:
- time-public-api
- track-public-api-proxy-f666f86df-kw6z2
Referrer-Policy:
- strict-origin-when-cross-origin
Server:
- nginx
Strict-Transport-Security:
- max-age=15552000; includeSubDomains
Transfer-Encoding:
- chunked
Vary:
- Accept-Encoding
Via:
- 1.1 google
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- SAMEORIGIN
X-Request-ID:
- 1905fe2a68d1344282b34731513e9084
- ea580eb96a5fab5db3584b6aa62e036b
X-Service-Level:
- GREEN
X-Toggl-Request-Id:
- 1905fe2a68d1344282b34731513e9084
- 68a21ff2-c386-482f-9ecc-110a27d4cbc9
X-We-are-hiring:
- https://toggl.com/jobs/
status:
Expand Down
Loading

0 comments on commit 9cce38e

Please sign in to comment.