Skip to content

Commit 9265a0b

Browse files
authored
Merge pull request #57 from ryokat3/id54
Changed subcommand name from purge to prune
2 parents 35a086d + 40ae394 commit 9265a0b

File tree

8 files changed

+826
-440
lines changed

8 files changed

+826
-440
lines changed

qiita_sync/qiita_sync.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ def qsync_do_sync(qsync: QiitaSync, status: SyncStatus, g_atcl: GitHubArticle, l
10101010
raise ApplicationError(f"{g_atcl.filepath}: Unknown status")
10111011

10121012

1013-
def qsync_do_purge(qsync: QiitaSync, status: SyncStatus, g_atcl: GitHubArticle, lq_atcl: Optional[GitHubArticle]):
1013+
def qsync_do_prune(qsync: QiitaSync, status: SyncStatus, g_atcl: GitHubArticle, lq_atcl: Optional[GitHubArticle]):
10141014
if g_atcl.data.private:
10151015
qsync.delete(g_atcl)
10161016
if g_atcl.filepath is not None:
@@ -1071,8 +1071,8 @@ def qsync_subcommand_sync(qsync: QiitaSync, target: Path, _: Any):
10711071
qsync_traverse(qsync, target, qsync_do_sync)
10721072

10731073

1074-
def qsync_subcommand_purge(qsync: QiitaSync, target: Path, _: Any):
1075-
qsync_traverse(qsync, target, qsync_do_purge)
1074+
def qsync_subcommand_prune(qsync: QiitaSync, target: Path, _: Any):
1075+
qsync_traverse(qsync, target, qsync_do_prune)
10761076

10771077

10781078
def qsync_argparse() -> ArgumentParser:
@@ -1094,7 +1094,7 @@ def common_arg(parser: ArgumentParser) -> ArgumentParser:
10941094
common_arg(subparsers.add_parser("check", help="check help")).set_defaults(func=qsync_subcommand_check)
10951095
common_arg(subparsers.add_parser("delete", help="delete help")).set_defaults(func=qsync_subcommand_delete)
10961096
common_arg(subparsers.add_parser("sync", help="sync help")).set_defaults(func=qsync_subcommand_sync)
1097-
common_arg(subparsers.add_parser("purge", help="purge help")).set_defaults(func=qsync_subcommand_purge)
1097+
common_arg(subparsers.add_parser("prune", help="prune help")).set_defaults(func=qsync_subcommand_prune)
10981098

10991099
return parser
11001100

tests/cassettes/test_qiita_create_caller.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ interactions:
2626
Content-Type:
2727
- application/json; charset=utf-8
2828
Date:
29-
- Sun, 16 Jan 2022 14:29:36 GMT
29+
- Wed, 19 Jan 2022 01:45:28 GMT
3030
ETag:
3131
- W/"2aaf04820679c58d926153e93c3c317f"
3232
Rate-Limit:
3333
- '1000'
3434
Rate-Remaining:
35-
- '915'
35+
- '972'
3636
Rate-Reset:
37-
- '1642344297'
37+
- '1642559772'
3838
Referrer-Policy:
3939
- strict-origin-when-cross-origin
4040
Server:
@@ -54,9 +54,9 @@ interactions:
5454
X-Permitted-Cross-Domain-Policies:
5555
- none
5656
X-Request-Id:
57-
- 4d77dcb7-9de1-4b95-b732-8ebb8bfd4a87
57+
- d21ea347-9dc9-4d29-8620-eefceab08f27
5858
X-Runtime:
59-
- '0.093739'
59+
- '0.249712'
6060
X-XSS-Protection:
6161
- 1; mode=block
6262
status:

tests/cassettes/test_subcommand_check.yaml

Lines changed: 159 additions & 82 deletions
Large diffs are not rendered by default.

tests/cassettes/test_subcommand_purge.yaml renamed to tests/cassettes/test_subcommand_prune.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ interactions:
2323
Content-Type:
2424
- application/json
2525
Date:
26-
- Sun, 16 Jan 2022 14:33:42 GMT
26+
- Wed, 19 Jan 2022 01:45:27 GMT
2727
Rate-Limit:
2828
- '1000'
2929
Rate-Remaining:
30-
- '901'
30+
- '973'
3131
Rate-Reset:
32-
- '1642344296'
32+
- '1642559772'
3333
Server:
3434
- nginx
3535
Strict-Transport-Security:
@@ -39,9 +39,9 @@ interactions:
3939
Vary:
4040
- Origin
4141
X-Request-Id:
42-
- 929cfe73-9358-49e5-bd0c-770dbcd1ef21
42+
- 79b37e5e-e2ac-4310-9fec-7ed3edc120c8
4343
X-Runtime:
44-
- '0.221728'
44+
- '0.231783'
4545
status:
4646
code: 404
4747
message: Not Found

tests/cassettes/test_subcommand_show_diff.yaml

Lines changed: 318 additions & 164 deletions
Large diffs are not rendered by default.

tests/cassettes/test_subcommand_sync.yaml

Lines changed: 318 additions & 164 deletions
Large diffs are not rendered by default.

tests/cassettes/test_subcommand_upload.yaml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ interactions:
2323
body:
2424
string: '{"rendered_body":"\u003cp\u003e\u003ca href=\"https://camo.qiitausercontent.com/d42dfcd6e60ca82bd25818138a4adf6a51e83e2f/68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f6769746875622d69642f6769746875622d7265706f2f6d61737465722f696d67312e706e67\"
2525
target=\"_blank\" rel=\"nofollow noopener\"\u003e\u003cimg src=\"https://camo.qiitausercontent.com/d42dfcd6e60ca82bd25818138a4adf6a51e83e2f/68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f6769746875622d69642f6769746875622d7265706f2f6d61737465722f696d67312e706e67\"
26-
alt=\"img1\" data-canonical-src=\"https://raw.githubusercontent.com/github-id/github-repo/master/img1.png\"\u003e\u003c/a\u003e\u003c/p\u003e\n","body":"![img1](https://raw.githubusercontent.com/github-id/github-repo/master/img1.png)\n","coediting":false,"comments_count":0,"created_at":"2022-01-16T23:33:40+09:00","group":null,"id":"74f0120f486b3ad86390","likes_count":0,"private":true,"reactions_count":0,"tags":[{"name":"test","versions":[]}],"title":"md3","updated_at":"2022-01-16T23:33:40+09:00","url":"https://qiita.com/ryokat3/private/74f0120f486b3ad86390","user":{"description":"Programmer","facebook_id":"","followees_count":2,"followers_count":1,"github_login_name":"ryokat3","id":"ryokat3","items_count":9,"linkedin_id":"","location":"Japan","name":"Ryoji
26+
alt=\"img1\" data-canonical-src=\"https://raw.githubusercontent.com/github-id/github-repo/master/img1.png\"\u003e\u003c/a\u003e\u003c/p\u003e\n","body":"![img1](https://raw.githubusercontent.com/github-id/github-repo/master/img1.png)\n","coediting":false,"comments_count":0,"created_at":"2022-01-19T10:45:25+09:00","group":null,"id":"43f84c5209394386851b","likes_count":0,"private":true,"reactions_count":0,"tags":[{"name":"test","versions":[]}],"title":"md3","updated_at":"2022-01-19T10:45:25+09:00","url":"https://qiita.com/ryokat3/private/43f84c5209394386851b","user":{"description":"Programmer","facebook_id":"","followees_count":2,"followers_count":1,"github_login_name":"ryokat3","id":"ryokat3","items_count":9,"linkedin_id":"","location":"Japan","name":"Ryoji
2727
Kato","organization":"","permanent_id":115148,"profile_image_url":"https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/115148/profile-images/1641617983","team_only":false,"twitter_screen_name":null,"website_url":""},"page_views_count":null,"team_membership":null}'
2828
headers:
2929
Cache-Control:
@@ -33,15 +33,15 @@ interactions:
3333
Content-Type:
3434
- application/json; charset=utf-8
3535
Date:
36-
- Sun, 16 Jan 2022 14:33:40 GMT
36+
- Wed, 19 Jan 2022 01:45:25 GMT
3737
ETag:
38-
- W/"587fd07f34a3268eff76294b588093ea"
38+
- W/"1f1c5c7f927af2a8af42a711edd0a582"
3939
Rate-Limit:
4040
- '1000'
4141
Rate-Remaining:
42-
- '907'
42+
- '979'
4343
Rate-Reset:
44-
- '1642344296'
44+
- '1642559773'
4545
Referrer-Policy:
4646
- strict-origin-when-cross-origin
4747
Server:
@@ -61,9 +61,9 @@ interactions:
6161
X-Permitted-Cross-Domain-Policies:
6262
- none
6363
X-Request-Id:
64-
- 325b6c22-1d2e-4e5d-9dc5-e6638dc0a20a
64+
- 5a05cac8-f169-4bd4-b6cc-f9cd4c320b61
6565
X-Runtime:
66-
- '0.261906'
66+
- '0.373759'
6767
X-XSS-Protection:
6868
- 1; mode=block
6969
status:
@@ -83,7 +83,7 @@ interactions:
8383
User-Agent:
8484
- Python-urllib/3.10
8585
method: DELETE
86-
uri: https://qiita.com/api/v2/items/74f0120f486b3ad86390
86+
uri: https://qiita.com/api/v2/items/43f84c5209394386851b
8787
response:
8888
body:
8989
string: ''
@@ -93,13 +93,13 @@ interactions:
9393
Connection:
9494
- close
9595
Date:
96-
- Sun, 16 Jan 2022 14:33:40 GMT
96+
- Wed, 19 Jan 2022 01:45:25 GMT
9797
Rate-Limit:
9898
- '1000'
9999
Rate-Remaining:
100-
- '906'
100+
- '978'
101101
Rate-Reset:
102-
- '1642344296'
102+
- '1642559772'
103103
Referrer-Policy:
104104
- strict-origin-when-cross-origin
105105
Server:
@@ -117,9 +117,9 @@ interactions:
117117
X-Permitted-Cross-Domain-Policies:
118118
- none
119119
X-Request-Id:
120-
- 20b9cfd8-611d-42fe-81e1-fee5223dc470
120+
- 7db05eb0-653b-4b63-b1da-656f9cf77481
121121
X-Runtime:
122-
- '0.214891'
122+
- '0.555126'
123123
X-XSS-Protection:
124124
- 1; mode=block
125125
status:

tests/test_qiita_sync.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ def update_test_file(fp: Path):
209209
# CLI Test
210210
########################################################################
211211

212+
212213
@pytest.mark.vcr()
213214
def test_subcommand_download(topdir_fx: Path, mocker: MockerFixture):
214215
get_qsync([MarkdownAsset("md2.md", gen_md2), MarkdownAsset("md3.md", gen_md3), Asset("img1.png")])
@@ -279,13 +280,13 @@ def test_subcommand_sync(topdir_fx: Path, mocker: MockerFixture, capsys: Capture
279280

280281

281282
@pytest.mark.vcr()
282-
def test_subcommand_purge(topdir_fx: Path, mocker: MockerFixture, capsys: CaptureFixture):
283+
def test_subcommand_prune(topdir_fx: Path, mocker: MockerFixture, capsys: CaptureFixture):
283284
get_qsync([MarkdownAsset("md2.md", gen_md2), MarkdownAsset("md3.md", gen_md3), Asset("img1.png")])
284285
target = topdir_fx.joinpath("md2.md")
285286

286287
assert target.is_file()
287288

288-
mocker.patch('sys.argv', ['qiita_sync.py', 'purge', str(target)])
289+
mocker.patch('sys.argv', ['qiita_sync.py', 'prune', str(target)])
289290
qsync_main()
290291

291292
assert not target.is_file()
@@ -347,7 +348,7 @@ def test_url_add_path(url, subpath, expected):
347348
assert url_add_path(url, Path(subpath)) == expected
348349

349350

350-
def test_get_utc():
351+
def test_get_utc():
351352
assert get_utc('2021-12-27T00:40:01+09:00') == get_utc('2021-12-26T15:40:01+00:00')
352353
assert get_utc('2022-01-18T02:35:19+00:00') > get_utc('2022-01-18T10:01:07+09:00')
353354
assert str(get_utc('2021-12-27T00:40:01+09:00')).endswith("+00:00")

0 commit comments

Comments
 (0)