mirror of
https://github.com/icereed/paperless-gpt.git
synced 2025-03-13 21:28:02 -05:00
feat: add mock response for correspondents API and update document correspondent type
This commit is contained in:
parent
91da6eff80
commit
127b501f0a
1 changed files with 28 additions and 18 deletions
|
@ -55,6 +55,12 @@ func newTestEnv(t *testing.T) *testEnv {
|
|||
env.client = NewPaperlessClient(env.server.URL, "test-token")
|
||||
env.client.HTTPClient = env.server.Client()
|
||||
|
||||
// Add mock response for /api/correspondents/
|
||||
env.setMockResponse("/api/correspondents/", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write([]byte(`{"results": [{"id": 1, "name": "Alpha"}, {"id": 2, "name": "Beta"}]}`))
|
||||
})
|
||||
|
||||
return env
|
||||
}
|
||||
|
||||
|
@ -176,7 +182,7 @@ func TestGetDocumentsByTags(t *testing.T) {
|
|||
documentsResponse := GetDocumentsApiResponse{
|
||||
Results: []struct {
|
||||
ID int `json:"id"`
|
||||
Correspondent interface{} `json:"correspondent"`
|
||||
Correspondent int `json:"correspondent"`
|
||||
DocumentType interface{} `json:"document_type"`
|
||||
StoragePath interface{} `json:"storage_path"`
|
||||
Title string `json:"title"`
|
||||
|
@ -204,12 +210,14 @@ func TestGetDocumentsByTags(t *testing.T) {
|
|||
Title: "Document 1",
|
||||
Content: "Content 1",
|
||||
Tags: []int{1, 2},
|
||||
Correspondent: 1,
|
||||
},
|
||||
{
|
||||
ID: 2,
|
||||
Title: "Document 2",
|
||||
Content: "Content 2",
|
||||
Tags: []int{2, 3},
|
||||
Correspondent: 2,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -249,12 +257,14 @@ func TestGetDocumentsByTags(t *testing.T) {
|
|||
Title: "Document 1",
|
||||
Content: "Content 1",
|
||||
Tags: []string{"tag1", "tag2"},
|
||||
Correspondent: "Alpha",
|
||||
},
|
||||
{
|
||||
ID: 2,
|
||||
Title: "Document 2",
|
||||
Content: "Content 2",
|
||||
Tags: []string{"tag2", "tag3"},
|
||||
Correspondent: "Beta",
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -413,7 +423,7 @@ func TestDownloadDocumentAsImages_ManyPages(t *testing.T) {
|
|||
ID: 321,
|
||||
}
|
||||
|
||||
// Get sample PDF from tests/pdf/sample.pdf
|
||||
// Get sample PDF from tests/pdf/many-pages.pdf
|
||||
pdfFile := "tests/pdf/many-pages.pdf"
|
||||
pdfContent, err := os.ReadFile(pdfFile)
|
||||
require.NoError(t, err)
|
||||
|
|
Loading…
Reference in a new issue