@@ -130,6 +130,21 @@ def test_link_post(postits_create, authenticated_user, client):
130
130
)
131
131
132
132
133
+ def test_link_post_already_exists (postits_create , authenticated_user , client ):
134
+ result = client .post ("/api/datafiles/link/tapis/system/path" )
135
+ assert json .loads (result .content )["data" ] == "https://tenant/uuid"
136
+ assert Link .objects .all ()[0 ].get_uuid () == "uuid"
137
+ postits_create .assert_called_with (
138
+ systemId = "system" ,
139
+ path = "path" ,
140
+ allowedUses = - 1 ,
141
+ validSeconds = 31536000
142
+ )
143
+ result = client .post ("/api/datafiles/link/tapis/system/path" )
144
+ assert result .status_code == 400
145
+ assert result .json () == {"message" : "Link for this file already exists" }
146
+
147
+
133
148
def test_link_delete (postits_create , authenticated_user , mock_tapis_client , client ):
134
149
mock_tapis_client .files .deletePostIt .return_value = "OK"
135
150
client .post ("/api/datafiles/link/tapis/system/path" )
@@ -139,6 +154,13 @@ def test_link_delete(postits_create, authenticated_user, mock_tapis_client, clie
139
154
assert len (Link .objects .all ()) == 0
140
155
141
156
157
+ def test_link_delete_dne (authenticated_user , mock_tapis_client , client ):
158
+ mock_tapis_client .files .deletePostIt .return_value = "Bad Request"
159
+ result = client .delete ("/api/datafiles/link/tapis/system/path" )
160
+ assert result .status_code == 400
161
+ assert result .json () == {"message" : "Post-it does not exist" }
162
+
163
+
142
164
def test_link_put (postits_create , authenticated_user , mock_tapis_client , client ):
143
165
mock_tapis_client .files .deletePostIt .return_value = "OK"
144
166
Link .objects .create (
@@ -150,6 +172,13 @@ def test_link_put(postits_create, authenticated_user, mock_tapis_client, client)
150
172
assert Link .objects .all ()[0 ].get_uuid () == "uuid"
151
173
152
174
175
+ def test_link_put_dne (postits_create , authenticated_user , mock_tapis_client , client ):
176
+ mock_tapis_client .files .deletePostIt .return_value = "Bad Request"
177
+ result = client .put ("/api/datafiles/link/tapis/system/path" )
178
+ assert result .status_code == 400
179
+ assert result .json () == {"message" : "Could not find pre-existing link" }
180
+
181
+
153
182
def test_get_system (client , authenticated_user , mock_tapis_client , agave_storage_system_mock ):
154
183
mock_tapis_client .systems .getSystem .return_value = TapisResult (** agave_storage_system_mock )
155
184
0 commit comments