@@ -128,6 +128,77 @@ def test_dataset_show(runner, client, subdirectory):
128
128
assert "##" not in result .output
129
129
130
130
131
+ def test_dataset_show_tag (runner , client , subdirectory ):
132
+ """Test creating and showing a dataset with metadata."""
133
+ result = runner .invoke (cli , ["dataset" , "show" , "my-dataset" ])
134
+ assert 1 == result .exit_code , format_result_exception (result )
135
+ assert 'Dataset "my-dataset" is not found.' in result .output
136
+
137
+ metadata = {
138
+ "@id" : "https://example.com/annotation1" ,
139
+ "@type" : "https://schema.org/specialType" ,
140
+ "https://schema.org/specialProperty" : "some_unique_value" ,
141
+ }
142
+ metadata_path = client .path / "metadata.json"
143
+ metadata_path .write_text (json .dumps (metadata ))
144
+
145
+ result = runner .invoke (
146
+ cli ,
147
+ [
148
+ "dataset" ,
149
+ "create" ,
150
+ "my-dataset" ,
151
+ "--title" ,
152
+ "Long Title" ,
153
+ "--description" ,
154
+ "description1" ,
155
+ ],
156
+ )
157
+ assert 0 == result .exit_code , format_result_exception (result )
158
+ assert "OK" in result .output
159
+
160
+ result = runner .invoke (cli , ["dataset" , "tag" , "my-dataset" , "tag1" ])
161
+ assert 0 == result .exit_code , format_result_exception (result )
162
+
163
+ result = runner .invoke (cli , ["dataset" , "edit" , "-d" , "description2" , "my-dataset" ])
164
+ assert 0 == result .exit_code , format_result_exception (result )
165
+ assert "Successfully updated: description" in result .output
166
+
167
+ result = runner .invoke (cli , ["dataset" , "tag" , "my-dataset" , "tag2" ])
168
+ assert 0 == result .exit_code , format_result_exception (result )
169
+
170
+ result = runner .invoke (cli , ["dataset" , "edit" , "-d" , "description3" , "my-dataset" ])
171
+ assert 0 == result .exit_code , format_result_exception (result )
172
+ assert "Successfully updated: description" in result .output
173
+
174
+ result = runner .invoke (cli , ["dataset" , "tag" , "my-dataset" , "tag3" ])
175
+ assert 0 == result .exit_code , format_result_exception (result )
176
+
177
+ result = runner .invoke (cli , ["dataset" , "show" , "my-dataset" ])
178
+ assert 0 == result .exit_code , format_result_exception (result )
179
+ assert "description3" in result .output
180
+ assert "description2" not in result .output
181
+ assert "description1" not in result .output
182
+
183
+ result = runner .invoke (cli , ["dataset" , "show" , "--tag" , "tag3" , "my-dataset" ])
184
+ assert 0 == result .exit_code , format_result_exception (result )
185
+ assert "description3" in result .output
186
+ assert "description2" not in result .output
187
+ assert "description1" not in result .output
188
+
189
+ result = runner .invoke (cli , ["dataset" , "show" , "--tag" , "tag2" , "my-dataset" ])
190
+ assert 0 == result .exit_code , format_result_exception (result )
191
+ assert "description2" in result .output
192
+ assert "description3" not in result .output
193
+ assert "description1" not in result .output
194
+
195
+ result = runner .invoke (cli , ["dataset" , "show" , "--tag" , "tag1" , "my-dataset" ])
196
+ assert 0 == result .exit_code , format_result_exception (result )
197
+ assert "description1" in result .output
198
+ assert "description2" not in result .output
199
+ assert "description3" not in result .output
200
+
201
+
131
202
def test_datasets_create_different_names (runner , client ):
132
203
"""Test creating datasets with same title but different name."""
133
204
result = runner .invoke (cli , ["dataset" , "create" , "dataset-1" , "--title" , "title" ])
0 commit comments