-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: update PaperListParams to match Python
See https://github.com/paperswithcode/paperswithcode-client/blob/develop/paperswithcode/client.py#L91-L129 for Python counterpart.
- Loading branch information
Showing
2 changed files
with
82 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,65 @@ | ||
package paperswithcode_go | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestClient_PaperList(t *testing.T) { | ||
client := NewClient(WithAPIToken(apiToken)) | ||
_, err := client.PaperList(PaperListParamsDefault()) | ||
assert.NoError(t, err) | ||
} | ||
|
||
func TestPaperListParams_Build(t *testing.T) { | ||
type fields struct { | ||
Q string | ||
ArxivID string | ||
Title string | ||
Abstract string | ||
Page int | ||
ItemsPerPage int | ||
} | ||
tests := []struct { | ||
name string | ||
fields fields | ||
want string | ||
}{ | ||
{ | ||
name: "Q is given, it passes Q", | ||
fields: fields{ | ||
Q: "wow", | ||
Page: 1, | ||
ItemsPerPage: 50, | ||
}, | ||
want: "page=1&items_per_page=50&q=wow", | ||
}, | ||
{ | ||
name: "Q is not given, it shouldn't add Q param", | ||
fields: fields{ | ||
Page: 1, | ||
ItemsPerPage: 50, | ||
}, | ||
want: "page=1&items_per_page=50", | ||
}, | ||
{ | ||
name: "Default Param is valid", | ||
fields: fields(PaperListParamsDefault()), | ||
want: "page=1&items_per_page=50", | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
p := PaperListParams{ | ||
Q: tt.fields.Q, | ||
ArxivID: tt.fields.ArxivID, | ||
Title: tt.fields.Title, | ||
Abstract: tt.fields.Abstract, | ||
Page: tt.fields.Page, | ||
ItemsPerPage: tt.fields.ItemsPerPage, | ||
} | ||
assert.Equal(t, tt.want, p.Build()) | ||
}) | ||
} | ||
} |