Modify

#23509 closed defect (fixed)

[RFC Patch] Test-Failure because of r18994,r18996

Reported by: stoecker Owned by: team
Priority: normal Milestone: 24.02
Component: Core Version:
Keywords: Cc: taylor.smock

Description

Currently tests fail because of my changes to the save dialog.

@Taylor: I'm not 100% sure, but I think the test is probably wrong or tuned to bad behaviour? What do you think?

Change History (10)

comment:1 by taylor.smock, 15 months ago

I assume you are talking about the non-regression test for #22817.
I think the test is probably partly wrong. Specifically BLOCKED files don't have a way to become blocked via the UI, so they must be loaded from disk is wrong (I forgot about remote control).
With that said, I think the test as written is currently fine. We do want to nag the user if the layer is BLOCKED and has a backing file.
The failing test is DISCOURAGED though. Not BLOCKED.

So, to clarify, we want the user to be nagged to save in the following cases:

  • Layer is modifiable AND modified AND upload policy is NORMAL
  • Layer is modifiable AND modified AND upload policy is DISCOURAGED (reminder: user can set the discouraged flag via UI)
  • Layer is modifiable AND modified AND upload policy is NEVER AND layer has backing file

We do not want to nag the user to save in the following circumstances

  • Layer is not modifiable
  • Layer is not modified
  • Layer has upload policy of NEVER AND has no backing file

EDIT: The problematic layers are usually from HOTOSM. The remote control command they use is as follows:
http://127.0.0.1:8111/import?new_layer=true&layer_name=Boundary for task: 386 of TM Project #16178 - Do not edit or upload&layer_locked=true&download_policy=never&upload_policy=never&url=https://tasking-manager-tm4-production-api.hotosm.org/api/v2/projects/16178/tasks/queries/xml/?tasks=386

  • layer_locked=true
  • upload_policy=never
Last edited 15 months ago by taylor.smock (previous) (diff)

comment:2 by taylor.smock, 15 months ago

Maybe

  • TabularUnified src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java b/src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java
    a b  
    123123                AbstractModifiableLayer odl = (AbstractModifiableLayer) l;
    124124                if (odl.isModified() && (
    125125                        (odl.isSavable() && odl.requiresSaveToFile()) ||
    126                         (odl.isUploadable() && odl.requiresUploadToServer() && !odl.isUploadDiscouraged()))) {
     126                        (odl.isUploadable() && odl.requiresUploadToServer()))) {
    127127                    layersWithUnsavedChanges.add(odl);
    128128                }
    129129            }

isUploadable is data.getUploadPolicy() != UploadPolicy.BLOCKED && !isLocked().

in reply to:  1 comment:3 by stoecker, 15 months ago

Replying to taylor.smock:

I assume you are talking about the non-regression test for #22817.

Jupp.

I think the test is probably partly wrong. Specifically BLOCKED files don't have a way to become blocked via the UI, so they must be loaded from disk is wrong (I forgot about remote control).

Long text, I have to think more about it. Didn't think that's so complex. ;-)

With that said, I think the test as written is currently fine. We do want to nag the user if the layer is BLOCKED and has a backing file.
The failing test is DISCOURAGED though. Not BLOCKED.

So, to clarify, we want the user to be nagged to save in the following cases:

  • Layer is modifiable AND modified AND upload policy is NORMAL

Yes. But why "nagged to save"? Do you mean "nagged to upload"?

  • Layer is modifiable AND modified AND upload policy is DISCOURAGED (reminder: user can set the discouraged flag via UI)
  • Layer is modifiable AND modified AND upload policy is NEVER AND layer has backing file

Regarding upload? Why do you want to nag about upload for non-uploadable layers? Or do you mean saving them?

We do not want to nag the user to save in the following circumstances

  • Layer is not modifiable

Yes.

  • Layer is not modified

Yes.

  • Layer has upload policy of NEVER AND has no backing file

What has upload policy to do with saving?

EDIT: The problematic layers are usually from HOTOSM. The remote control command they use is as follows:
http://127.0.0.1:8111/import?new_layer=true&layer_name=Boundary for task: 386 of TM Project #16178 - Do not edit or upload&layer_locked=true&download_policy=never&upload_policy=never&url=https://tasking-manager-tm4-production-api.hotosm.org/api/v2/projects/16178/tasks/queries/xml/?tasks=386

  • layer_locked=true
  • upload_policy=never

I viewed the save and upload as to different decisions only presented in one dialog.

I think your patch isn't right either, as it will again nag about my local file with upload=false/never which is not meant for uploading. It will open a dialog which offers save, but save is unchecked by default. That's the reason why I added that additional check. ATM I only get the dialog when I change the file: That's what I expect.

comment:4 by stoecker, 15 months ago

Maybe we should drop the double logic altogether, simply construct the dialog and don't show it when none of the buttons is checked by default?

comment:5 by GerdP, 15 months ago

The test iterates over the different upload strategies, so it should not test wether the data is savable.

by GerdP, 15 months ago

Attachment: 23509.patch added

possible fix

comment:6 by GerdP, 15 months ago

The patch changes the failing test so that it

  • doesn't use a new file but reads from an existing one so that the result doesn't depend on that part
  • tests more methods to show the differences between DataSet.requiresUploadToServer() and OsmDataLayer.requiresUploadToServer()
  • tests the effect of the upload policy on the SaveLayersDialog

comment:7 by GerdP, 15 months ago

Summary: Test-Failure because of r18994,r18996[RFC Patch] Test-Failure because of r18994,r18996

I think the code in core is correct, just the unit test has to be fixed. Any complains about the attached patch?

comment:8 by taylor.smock, 15 months ago

I don't see anything objectionable in the patch.

comment:9 by GerdP, 15 months ago

Resolution: fixed
Status: newclosed

In 19011/josm:

fix #23509: Test-Failure because of r18994,r18996
The patch changes the failing test so that it

  • doesn't use a new file but reads from an existing one so that the result doesn't depend on that part
  • tests more methods to show the differences between DataSet.requiresUploadToServer() and OsmDataLayer.requiresUploadToServer()
  • tests the effect of the upload policy on the SaveLayersDialog

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.