Skip to content

Commit c0af92d

Browse files
jorwoodsjacalata
authored andcommitted
fix: put special fields first (#1622)
Closes #1620 Sorting the fields prior to putting them in the query string assures that '_all_' and '_default_' appear first in the field list, satisfying the criteria of Tableau Server/Cloud to process those first. Order of other fields appeared to be irrelevant, so the test simply ensures their presence. Co-authored-by: Jordan Woods <13803242+jorwoods@users.noreply.github.com>
1 parent 6da100f commit c0af92d

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

test/test_request_option.py

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -431,13 +431,31 @@ def test_queryset_field_order(server: TSC.Server) -> None:
431431
assert "name" in fields
432432

433433

434-
def test_queryset_field_all(server: TSC.Server) -> None:
435-
with requests_mock.mock() as m:
436-
m.get(server.views.baseurl, text=SLICING_QUERYSET_PAGE_1.read_text())
437-
loop = server.views.fields("id", "name", "_all_")
438-
list(loop)
439-
history = m.request_history[0]
440-
441-
fields = history.qs.get("fields", [""])[0]
442-
443-
assert fields == "_all_"
434+
def test_queryset_only_fields(self) -> None:
435+
loop = self.server.users.only_fields("id")
436+
assert "id" in loop.request_options.fields
437+
assert "_default_" not in loop.request_options.fields
438+
439+
def test_queryset_field_order(self) -> None:
440+
with requests_mock.mock() as m:
441+
m.get(self.server.views.baseurl, text=SLICING_QUERYSET_PAGE_1.read_text())
442+
loop = self.server.views.fields("id", "name")
443+
list(loop)
444+
history = m.request_history[0]
445+
446+
fields = history.qs.get("fields", [""])[0].split(",")
447+
448+
assert fields[0] == "_default_"
449+
assert "id" in fields
450+
assert "name" in fields
451+
452+
def test_queryset_field_all(self) -> None:
453+
with requests_mock.mock() as m:
454+
m.get(self.server.views.baseurl, text=SLICING_QUERYSET_PAGE_1.read_text())
455+
loop = self.server.views.fields("id", "name", "_all_")
456+
list(loop)
457+
history = m.request_history[0]
458+
459+
fields = history.qs.get("fields", [""])[0]
460+
461+
assert fields == "_all_"

0 commit comments

Comments
 (0)