@@ -24,11 +24,10 @@ def test_file_put_get(boto3_mock, test_client, some_hash, simple_file):
2424
2525 assert response .status_code == 200 , response .get_data ()
2626 expected = simple_file .copy ()
27- expected ['post_url_fields' ] = post_values
28-
2927
3028 formatter = dateformat .DateFormat (created )
3129 expected ['created' ] = formatter .format (settings .DATETIME_FORMAT )
30+ expected ['version' ] = 1
3231 assert response .json == expected
3332
3433 try :
@@ -70,7 +69,7 @@ def test_file_search_empty(test_client, some_uuid):
7069 'what' : 'a thing' ,
7170 'cid' : 'nope' ,
7271 'where' : 'nowhere' ,
73- 'task_run ' : some_uuid ,
72+ 'work_id ' : some_uuid ,
7473 'range_start' : "2018-11-25T00:00:00.000000Z" ,
7574 'range_end' : "2018-11-25T00:00:00.000000Z" ,
7675 })
@@ -121,7 +120,7 @@ def create_asset(asset_type, asset):
121120 json = simple_task_run )
122121 assert response .status_code == 201 , response .get_data ()
123122
124- simple_file ['task_run ' ] = some_uuid
123+ simple_file ['work_id ' ] = some_uuid
125124 created = timezone .now ()
126125 with patch ('django.utils.timezone.now' , return_value = created ):
127126 response = test_client .put (f'/api/v0/files/{ some_hash } /' , json = simple_file )
@@ -130,6 +129,7 @@ def create_asset(asset_type, asset):
130129 expected = simple_file .copy ()
131130 formatter = dateformat .DateFormat (created )
132131 expected ['created' ] = formatter .format (settings .DATETIME_FORMAT )
132+ expected ['version' ] = 1
133133
134134 search_query = simple_file .copy ()
135135 search_query ['range_start' ] = search_query .pop ('start' )
@@ -142,7 +142,7 @@ def create_asset(asset_type, asset):
142142
143143 # Make sure changing some of the searches *DON'T* find it.
144144 simple_query_false = simple_file .copy ()
145- simple_query_false ['task_run ' ] = uuid .uuid4 ()
145+ simple_query_false ['work_id ' ] = uuid .uuid4 ()
146146 simple_query_false ['range_start' ] = simple_query_false .pop ('start' )
147147 response = test_client .get (f'/api/v0/files/' , query_string = simple_query_false )
148148 assert response .status_code == 200 , response .get_data ()
@@ -159,4 +159,26 @@ def create_asset(asset_type, asset):
159159 expected ['stdout' ] = simple_file ['cid' ]
160160 expected ['stderr' ] = None
161161
162- assert response .json == expected
162+ assert response .json == expected
163+
164+
165+ @pytest .mark .django_db
166+ def test_version_increment (test_client , simple_file , some_hash , another_hash ):
167+ created = timezone .now ()
168+ with patch ('django.utils.timezone.now' , return_value = created ):
169+ response = test_client .put (f'/api/v0/files/{ some_hash } /' , json = simple_file )
170+ assert response .status_code == 201 , response .get_data ()
171+ result1 = response .json
172+
173+ simple_file ['cid' ] = another_hash
174+ with patch ('django.utils.timezone.now' , return_value = created ):
175+ response = test_client .put (f'/api/v0/files/{ another_hash } /' , json = simple_file )
176+ assert response .status_code == 201 , response .get_data ()
177+ result2 = response .json
178+
179+ assert result1 .pop ('version' ) == 1
180+ assert result2 .pop ('version' ) == 2
181+
182+ assert result1 .pop ('cid' ) == some_hash
183+ assert result2 .pop ('cid' ) == another_hash
184+ assert result1 == result2
0 commit comments