jrrribeiro commited on
Commit
83fe12c
·
1 Parent(s): 8f555de

test/docs: cover reapply conflict flow and update sprint status

Browse files
README.md CHANGED
@@ -56,3 +56,4 @@ Estrutura base criada por projeto/dataset:
56
  - Sprint 3 (UI): tabela exibe status atual da validacao por detection_key e botao de relatorio por projeto
57
  - Sprint 3 (concorrencia): controle otimista por versao esperada com deteccao de conflito e bloqueio de sobrescrita silenciosa
58
  - Sprint 3 (UX conflito): refresh automatico da tabela em conflito e foco na deteccao impactada para resolucao rapida
 
 
56
  - Sprint 3 (UI): tabela exibe status atual da validacao por detection_key e botao de relatorio por projeto
57
  - Sprint 3 (concorrencia): controle otimista por versao esperada com deteccao de conflito e bloqueio de sobrescrita silenciosa
58
  - Sprint 3 (UX conflito): refresh automatico da tabela em conflito e foco na deteccao impactada para resolucao rapida
59
+ - Sprint 3 (UX conflito+): flag visual de conflito na linha e botao para reaplicar validacao na versao atual
tests/unit/test_app_factory_audio_helpers.py CHANGED
@@ -13,6 +13,7 @@ from src.ui.app_factory import (
13
  _page_to_table,
14
  _save_selected_validation,
15
  _save_selected_validation_with_refresh,
 
16
  )
17
 
18
 
@@ -265,6 +266,21 @@ def test_page_to_table_includes_validation_status() -> None:
265
  assert rows[0][0] == "dkey_01"
266
  assert rows[0][6] == "positive"
267
  assert rows[0][7] == 2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
268
 
269
 
270
  def test_find_detection_row_index() -> None:
@@ -279,7 +295,7 @@ def test_save_selected_validation_with_refresh_success() -> None:
279
  validation_service = FakeValidationService()
280
  rows = [["dkey_01", "audio_11", "sp", 0.9, 0.0, 1.0, "pending", 0]]
281
 
282
- status, cache_key, audio_path, refreshed_rows, refreshed_page, refreshed_index = _save_selected_validation_with_refresh(
283
  validation_service=validation_service,
284
  audio_service=audio_service,
285
  queue_service=FakeQueueService(),
@@ -302,6 +318,8 @@ def test_save_selected_validation_with_refresh_success() -> None:
302
  assert refreshed_page == 1
303
  assert refreshed_index == 0
304
  assert refreshed_rows[0][0] == "dkey_01"
 
 
305
 
306
 
307
  def test_save_selected_validation_with_refresh_conflict() -> None:
@@ -309,7 +327,7 @@ def test_save_selected_validation_with_refresh_conflict() -> None:
309
  validation_service = FakeConflictValidationService()
310
  rows = [["dkey_01", "audio_11", "sp", 0.9, 0.0, 1.0, "pending", 0]]
311
 
312
- status, cache_key, audio_path, refreshed_rows, refreshed_page, refreshed_index = _save_selected_validation_with_refresh(
313
  validation_service=validation_service,
314
  audio_service=audio_service,
315
  queue_service=FakeQueueService(),
@@ -333,3 +351,67 @@ def test_save_selected_validation_with_refresh_conflict() -> None:
333
  assert refreshed_page == 1
334
  assert refreshed_index == 0
335
  assert refreshed_rows[0][0] == "dkey_01"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  _page_to_table,
14
  _save_selected_validation,
15
  _save_selected_validation_with_refresh,
16
+ _reapply_last_conflict_validation_with_refresh,
17
  )
18
 
19
 
 
266
  assert rows[0][0] == "dkey_01"
267
  assert rows[0][6] == "positive"
268
  assert rows[0][7] == 2
269
+ assert rows[0][8] == ""
270
+
271
+
272
+ def test_page_to_table_marks_conflict_row() -> None:
273
+ rows, _, _ = _page_to_table(
274
+ service=FakeQueueService(),
275
+ snapshot_reader=FakeSnapshotReader(),
276
+ project_slug="demo-project",
277
+ page=1,
278
+ scientific_name="",
279
+ min_confidence=0.0,
280
+ conflict_detection_key="dkey_01",
281
+ )
282
+
283
+ assert rows[0][8] == "conflict"
284
 
285
 
286
  def test_find_detection_row_index() -> None:
 
295
  validation_service = FakeValidationService()
296
  rows = [["dkey_01", "audio_11", "sp", 0.9, 0.0, 1.0, "pending", 0]]
297
 
298
+ status, cache_key, audio_path, refreshed_rows, refreshed_page, refreshed_index, pending_status, conflict_key = _save_selected_validation_with_refresh(
299
  validation_service=validation_service,
300
  audio_service=audio_service,
301
  queue_service=FakeQueueService(),
 
318
  assert refreshed_page == 1
319
  assert refreshed_index == 0
320
  assert refreshed_rows[0][0] == "dkey_01"
321
+ assert pending_status == ""
322
+ assert conflict_key == ""
323
 
324
 
325
  def test_save_selected_validation_with_refresh_conflict() -> None:
 
327
  validation_service = FakeConflictValidationService()
328
  rows = [["dkey_01", "audio_11", "sp", 0.9, 0.0, 1.0, "pending", 0]]
329
 
330
+ status, cache_key, audio_path, refreshed_rows, refreshed_page, refreshed_index, pending_status, conflict_key = _save_selected_validation_with_refresh(
331
  validation_service=validation_service,
332
  audio_service=audio_service,
333
  queue_service=FakeQueueService(),
 
351
  assert refreshed_page == 1
352
  assert refreshed_index == 0
353
  assert refreshed_rows[0][0] == "dkey_01"
354
+ assert refreshed_rows[0][8] == "conflict"
355
+ assert pending_status == "positive"
356
+ assert conflict_key == "dkey_01"
357
+
358
+
359
+ def test_reapply_last_conflict_validation_with_refresh() -> None:
360
+ audio_service = FakeAudioService()
361
+ validation_service = FakeValidationService()
362
+ rows = [["dkey_01", "audio_11", "sp", 0.9, 0.0, 1.0, "pending", 2, "conflict"]]
363
+
364
+ status, cache_key, audio_path, refreshed_rows, refreshed_page, refreshed_index, pending_status, conflict_key = _reapply_last_conflict_validation_with_refresh(
365
+ validation_service=validation_service,
366
+ audio_service=audio_service,
367
+ queue_service=FakeQueueService(),
368
+ snapshot_reader=FakeSnapshotReader(),
369
+ project_slug="demo-project",
370
+ rows=rows,
371
+ selected_index=0,
372
+ pending_status_value="positive",
373
+ conflict_detection_key="dkey_01",
374
+ validator="validator-demo",
375
+ notes="retry",
376
+ cache_key="",
377
+ page=1,
378
+ scientific_name="",
379
+ min_confidence=0.0,
380
+ )
381
+
382
+ assert "Validacao salva" in status
383
+ assert cache_key == ""
384
+ assert audio_path is None
385
+ assert refreshed_page == 1
386
+ assert refreshed_index == 0
387
+ assert refreshed_rows[0][0] == "dkey_01"
388
+ assert pending_status == ""
389
+ assert conflict_key == ""
390
+
391
+
392
+ def test_reapply_last_conflict_without_pending_status() -> None:
393
+ audio_service = FakeAudioService()
394
+ validation_service = FakeValidationService()
395
+ rows = [["dkey_01", "audio_11", "sp", 0.9, 0.0, 1.0, "pending", 2, ""]]
396
+
397
+ status, _, _, _, _, _, pending_status, conflict_key = _reapply_last_conflict_validation_with_refresh(
398
+ validation_service=validation_service,
399
+ audio_service=audio_service,
400
+ queue_service=FakeQueueService(),
401
+ snapshot_reader=FakeSnapshotReader(),
402
+ project_slug="demo-project",
403
+ rows=rows,
404
+ selected_index=0,
405
+ pending_status_value="",
406
+ conflict_detection_key="",
407
+ validator="validator-demo",
408
+ notes="retry",
409
+ cache_key="",
410
+ page=1,
411
+ scientific_name="",
412
+ min_confidence=0.0,
413
+ )
414
+
415
+ assert "Nenhuma validacao pendente" in status
416
+ assert pending_status == ""
417
+ assert conflict_key == ""