Skip to content

Commit 4b4fa4e

Browse files
committed
Add tests for tag migration
Test the tag migration functionality Signed-off-by: Shounak Dey <shounakdey@ymail.com>
1 parent 45f1ba1 commit 4b4fa4e

File tree

9 files changed

+425
-153
lines changed

9 files changed

+425
-153
lines changed

test/conftest.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,14 @@ def transfer_cassette_to_response(path: str) -> list:
5555
except (json.JSONDecodeError, TypeError):
5656
json_body = None
5757

58-
defs.append(ResponseDefinition(
59-
method=method.upper(),
60-
url=url,
61-
json=json_body,
62-
status=status,
63-
content_type=content_type,
64-
))
58+
defs.append(
59+
ResponseDefinition(
60+
method=method.upper(),
61+
url=url,
62+
json=json_body,
63+
status=status,
64+
content_type=content_type,
65+
)
66+
)
6567

6668
return defs

test/test_main.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
"Initialize transfer of repository assets",
7474
"Options:",
7575
"List of branches to extract",
76+
"List of tags to extract",
7677
"Show this message and exit.",
7778
],
7879
id="Repositories help",
@@ -125,6 +126,12 @@
125126
["Error: Option '--brcs' requires an argument."],
126127
id="Providing empty input to the `brcs` option",
127128
),
129+
pytest.param(
130+
"-a a -b a -s a -d a -p a -g a -f a -t a repo --tags",
131+
2,
132+
["Error: Option '--tags' requires an argument."],
133+
id="Providing empty input to the `tags` option",
134+
),
128135
pytest.param(
129136
"-a a -b a -s a -d a -p a -g a -f a -t a",
130137
2,

test/test_repo_cent.py

Lines changed: 114 additions & 40 deletions
Large diffs are not rendered by default.

test/test_repo_dist.py

Lines changed: 122 additions & 49 deletions
Large diffs are not rendered by default.

test/test_repo_fedo.py

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"- (SRCE branch) test-dddd",
5454
"- (SRCE branch) test-eeee",
5555
"- (SRCE branch) test-ffff",
56-
"[ BUSY ] Initializing namespace assets transfer...",
56+
"[ BUSY ] Initializing namespace assets branch(es) transfer...",
5757
"[ WARN ] Transferring 8 available branches",
5858
"[1/8] Branch 'HEAD' was transferred to the destination namespace",
5959
"[2/8] Branch 'main' was transferred to the destination namespace",
@@ -64,9 +64,15 @@
6464
"[7/8] Branch 'test-eeee' was transferred to the destination namespace",
6565
"[8/8] Branch 'test-ffff' was transferred to the destination namespace",
6666
"Assets transferred: 8 branch(es) completed, 8 branch(es) requested",
67-
"[ PASS ] Namespace assets transfer succeeded!",
67+
"[ PASS ] Namespace assets branch(es) transfer succeeded!",
68+
"[ BUSY ] Reading tags data from the locally cloned assets...",
69+
"[ PASS ] Tags data reading succeeded!",
70+
"Available in source namespace: 0 tag(s)",
71+
"[ BUSY ] Initializing namespace assets tag(s) transfer...",
72+
"[ WARN ] Transferring 0 available tags",
73+
"[ PASS ] Namespace assets tag(s) transfer succeeded!",
6874
],
69-
id="pagure.io - Migrating repository contents with specifying zero valid branch names",
75+
id="pagure.io - Migrating repository contents with specifying zero valid branch and tag names",
7076
),
7177
pytest.param(
7278
f"--splt {envr['TEST_SPLT_FEDO']} --dplt {envr['TEST_DPLT']} --srce {envr['TEST_SRCE']} --dest {envr['TEST_DEST']} --pkey {envr['TEST_PKEY']} --gkey {envr['TEST_GKEY']} --fusr {envr['TEST_FUSR']} --tusr {envr['TEST_TUSR']} repo --brcs test-aaaa,test-bbbb,test-cccc,test-dddd", # noqa: E501
@@ -83,16 +89,22 @@
8389
"- (RQST branch) test-bbbb",
8490
"- (RQST branch) test-cccc",
8591
"- (RQST branch) test-dddd",
86-
"[ BUSY ] Initializing namespace assets transfer...",
92+
"[ BUSY ] Initializing namespace assets branch(es) transfer...",
8793
"[ WARN ] Transferring 4 requested branches",
8894
"[1/4] Branch 'test-aaaa' was transferred to the destination namespace",
8995
"[2/4] Branch 'test-bbbb' was transferred to the destination namespace",
9096
"[3/4] Branch 'test-cccc' was transferred to the destination namespace",
9197
"[4/4] Branch 'test-dddd' was transferred to the destination namespace",
9298
"Assets transferred: 4 branch(es) completed, 4 branch(es) requested",
93-
"[ PASS ] Namespace assets transfer succeeded!",
99+
"[ PASS ] Namespace assets branch(es) transfer succeeded!",
100+
"[ BUSY ] Reading tags data from the locally cloned assets...",
101+
"[ PASS ] Tags data reading succeeded!",
102+
"Available in source namespace: 0 tag(s)",
103+
"[ BUSY ] Initializing namespace assets tag(s) transfer...",
104+
"[ WARN ] Transferring 0 available tags",
105+
"[ PASS ] Namespace assets tag(s) transfer succeeded!",
94106
],
95-
id="pagure.io - Migrating repository contents with specifying four valid branch names",
107+
id="pagure.io - Migrating repository contents with specifying four valid branch names and zero valid tag names",
96108
),
97109
pytest.param(
98110
f"--splt {envr['TEST_SPLT_FEDO']} --dplt {envr['TEST_DPLT']} --srce {envr['TEST_SRCE']} --dest {envr['TEST_DEST']} --pkey {envr['TEST_PKEY']} --gkey {envr['TEST_GKEY']} --fusr {envr['TEST_FUSR']} --tusr {envr['TEST_TUSR']} repo --brcs test-aaaa,test-bbbb,test-cxxc,test-dxxd", # noqa: E501
@@ -109,16 +121,22 @@
109121
"- (RQST branch) test-bbbb",
110122
"- (RQST branch) test-cxxc",
111123
"- (RQST branch) test-dxxd",
112-
"[ BUSY ] Initializing namespace assets transfer...",
124+
"[ BUSY ] Initializing namespace assets branch(es) transfer...",
113125
"[ WARN ] Transferring 4 requested branches",
114126
"[1/4] Branch 'test-aaaa' was transferred to the destination namespace",
115127
"[2/4] Branch 'test-bbbb' was transferred to the destination namespace",
116128
"[3/4] Branch 'test-cxxc' was not found in the source namespace",
117129
"[4/4] Branch 'test-dxxd' was not found in the source namespace",
118130
"Assets transferred: 2 branch(es) completed, 4 branch(es) requested",
119-
"[ WARN ] Namespace assets transfer partially completed!",
131+
"[ WARN ] Namespace assets branch(es) transfer partially completed!",
132+
"[ BUSY ] Reading tags data from the locally cloned assets...",
133+
"[ PASS ] Tags data reading succeeded!",
134+
"Available in source namespace: 0 tag(s)",
135+
"[ BUSY ] Initializing namespace assets tag(s) transfer...",
136+
"[ WARN ] Transferring 0 available tags",
137+
"[ PASS ] Namespace assets tag(s) transfer succeeded!",
120138
],
121-
id="pagure.io - Migrating repository contents with specifying two valid branch names and two invalid branch names", # noqa: E501
139+
id="pagure.io - Migrating repository contents with specifying two valid branch names and two invalid branch names and zero valid tag names", # noqa: E501
122140
),
123141
pytest.param(
124142
f"--splt {envr['TEST_SPLT_FEDO']} --dplt {envr['TEST_DPLT']} --srce {envr['TEST_SRCE']} --dest {envr['TEST_DEST']} --pkey {envr['TEST_PKEY']} --gkey {envr['TEST_GKEY']} --fusr {envr['TEST_FUSR']} --tusr {envr['TEST_TUSR']} repo --brcs test-axxa,test-bxxb,test-cxxc,test-dxxd", # noqa: E501
@@ -135,16 +153,22 @@
135153
"- (RQST branch) test-bxxb",
136154
"- (RQST branch) test-cxxc",
137155
"- (RQST branch) test-dxxd",
138-
"[ BUSY ] Initializing namespace assets transfer...",
156+
"[ BUSY ] Initializing namespace assets branch(es) transfer...",
139157
"[ WARN ] Transferring 4 requested branches",
140158
"[1/4] Branch 'test-axxa' was not found in the source namespace",
141159
"[2/4] Branch 'test-bxxb' was not found in the source namespace",
142160
"[3/4] Branch 'test-cxxc' was not found in the source namespace",
143161
"[4/4] Branch 'test-dxxd' was not found in the source namespace",
144162
"Assets transferred: 0 branch(es) completed, 4 branch(es) requested",
145-
"[ FAIL ] Namespace assets transfer failed!",
163+
"[ FAIL ] Namespace assets branch(es) transfer failed!",
164+
"[ BUSY ] Reading tags data from the locally cloned assets...",
165+
"[ PASS ] Tags data reading succeeded!",
166+
"Available in source namespace: 0 tag(s)",
167+
"[ BUSY ] Initializing namespace assets tag(s) transfer...",
168+
"[ WARN ] Transferring 0 available tags",
169+
"[ PASS ] Namespace assets tag(s) transfer succeeded!",
146170
],
147-
id="pagure.io - Migrating repository contents with specifying four invalid branch names",
171+
id="pagure.io - Migrating repository contents with specifying four invalid branch names and zero invalid tag names",
148172
),
149173
pytest.param(
150174
f"--splt {envr['TEST_SPLT_FEDO']} --dplt {envr['TEST_DPLT']} --srce {envr['TEST_SRCE']} --dest {envr['TEST_DEST']} --pkey {envr['TEST_PKEY']} --gkey {envr['TEST_GKEY']} --fusr {envr['TEST_FUSR']} --tusr {envr['TEST_TUSR']} repo", # noqa: E501
@@ -170,7 +194,8 @@ def test_main_repo(caplog, cmdl, code, text):
170194

171195
# Changing the shared variable back to its default
172196
# Please check https://github.com/gridhead/protop2g/issues/35 for additional details
173-
standard.transfer_index = 0
197+
standard.branch_transfer_index = 0
198+
standard.tag_transfer_index = 0
174199

175200
assert result.exit_code == code # noqa: S101
176201
for indx in text:

test/test_stat.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,13 @@
5252
def test_stat_destdata_obtninfo(caplog, cmdl, code, text, request):
5353
resplist = transfer_cassette_to_response(f"test/cassettes/test_stat/{request.node.name}.yaml")
5454
for item in resplist:
55-
responses.add(method=item.method, url=item.url, json=item.json, status=item.status, content_type=item.content_type)
55+
responses.add(
56+
method=item.method,
57+
url=item.url,
58+
json=item.json,
59+
status=item.status,
60+
content_type=item.content_type,
61+
)
5662

5763
runner = CliRunner()
5864
result = runner.invoke(main, cmdl)

test/test_tkts.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@
136136
],
137137
id="Transferring issue tickets with SHUT status along with states but without comments, without privacy, without labels and with order", # noqa: E501
138138
),
139-
140139
pytest.param(
141140
f"--splt {envr['TEST_SPLT_FEDO']} --dplt {envr['TEST_DPLT']} --srce {envr['TEST_SRCE']} --dest {envr['TEST_DEST']} --pkey {envr['TEST_PKEY']} --gkey {envr['TEST_GKEY']} --fusr {envr['TEST_FUSR']} --tusr {envr['TEST_TUSR']} tkts --status OPEN --secret --series", # noqa: E501
142141
0,
@@ -517,7 +516,13 @@
517516
def test_main_tkts(caplog, cmdl, code, text, request):
518517
resplist = transfer_cassette_to_response(f"test/cassettes/test_tkts/{request.node.name}.yaml")
519518
for item in resplist:
520-
responses.add(method=item.method, url=item.url, json=item.json, status=item.status, content_type=item.content_type)
519+
responses.add(
520+
method=item.method,
521+
url=item.url,
522+
json=item.json,
523+
status=item.status,
524+
content_type=item.content_type,
525+
)
521526

522527
runner = CliRunner()
523528
result = runner.invoke(main, cmdl)

0 commit comments

Comments
 (0)