Skip to content

Test mock with numeric "offsetgroup" value #4705

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hmf opened this issue Mar 28, 2020 · 4 comments · Fixed by #4708
Closed

Test mock with numeric "offsetgroup" value #4705

hmf opened this issue Mar 28, 2020 · 4 comments · Fixed by #4708

Comments

@hmf
Copy link

hmf commented Mar 28, 2020

The mock bar-alignment-offset.json has the following trace:

    {
      "type": "bar",
      "marker": {
        "color": "orange"
      },
      "opacity": 0.6,
      "name": "B",
      "legendgroup": "B",
      "showlegend": false,
      "hoverinfo": "text",
      "hovertext": "a0",
      "xaxis": "x",
      "yaxis": "y",
      "alignmentgroup": "a",
      "offsetgroup": 0,
      "x": [
        1
      ],
      "y": [
        1
      ]
    },

Note that the "offsetgroup" has a numeric value. But the schema indicates:

valType : "string"

The few examples I have found in Plotly's Github and project/product sites seem to use strings. Is the mock incorrect?

TIA

@archmoj
Copy link
Contributor

archmoj commented Mar 28, 2020

The number is casted to string in this case.

 offsetgroup = "0"

@hmf
Copy link
Author

hmf commented Mar 29, 2020

@archmoj thanks for the info.

I understand that Plotly does this. Maybe I phrased this incorrectly. What I need to know is can the Mock that uses a numeric value be considered incorrect?

Just for some background - I am setting up a round-trip test for a Scala wrapper to read and output the Plotly JSON documents according to the schema (much of the code is generated automatically via the schema). This means that it is not trivial to add support for such conversions or even support deprecated elements.

In such cases, I will opt to change the mocks but must ensure that these changes are correct. Hence the question: is the mock incorrect and will the change I make (use a string) be in accordance with the schema (i.e.: not a schema error)?

Appreciate any feedback on this.

@alexcjohnson
Copy link
Collaborator

In general we accept numbers in string fields. I wouldn't exactly recommend it, but it is officially supported and they get cast to strings. The only exception is attributes labeled strict: true in the schema - these will reject numbers as input and only accept values that are already strings.

@hmf
Copy link
Author

hmf commented Mar 30, 2020

For the Scala wrapper I will assume "strict" and use numeric values only. Easier to maintain the mock change. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants