-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpipelinedocument_test.go
More file actions
200 lines (183 loc) · 5.66 KB
/
Copy pathpipelinedocument_test.go
File metadata and controls
200 lines (183 loc) · 5.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package cmd
import (
"testing"
"github.com/run-llama/llama-parse-cli/internal/mocktest"
"github.com/run-llama/llama-parse-cli/internal/requestflag"
)
func TestPipelinesDocumentsCreate(t *testing.T) {
t.Skip("Mock server tests are disabled")
t.Run("regular flags", func(t *testing.T) {
mocktest.TestRunMockTestWithFlags(
t,
"--api-key", "string",
"pipelines:documents", "create",
"--pipeline-id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"--body", "{metadata: {foo: bar}, text: text, id: id, excluded_embed_metadata_keys: [string], excluded_llm_metadata_keys: [string], page_positions: [0]}",
)
})
t.Run("inner flags", func(t *testing.T) {
// Check that inner flags have been set up correctly
requestflag.CheckInnerFlags(pipelinesDocumentsCreate)
// Alternative argument passing style using inner flags
mocktest.TestRunMockTestWithFlags(
t,
"--api-key", "string",
"pipelines:documents", "create",
"--pipeline-id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"--body.metadata", "{foo: bar}",
"--body.text", "text",
"--body.id", "id",
"--body.excluded-embed-metadata-keys", "[string]",
"--body.excluded-llm-metadata-keys", "[string]",
"--body.page-positions", "[0]",
)
})
t.Run("piping data", func(t *testing.T) {
// Test piping YAML data over stdin
pipeData := []byte("" +
"- metadata:\n" +
" foo: bar\n" +
" text: text\n" +
" id: id\n" +
" excluded_embed_metadata_keys:\n" +
" - string\n" +
" excluded_llm_metadata_keys:\n" +
" - string\n" +
" page_positions:\n" +
" - 0\n")
mocktest.TestRunMockTestWithPipeAndFlags(
t, pipeData,
"--api-key", "string",
"pipelines:documents", "create",
"--pipeline-id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
})
}
func TestPipelinesDocumentsList(t *testing.T) {
t.Skip("Mock server tests are disabled")
t.Run("regular flags", func(t *testing.T) {
mocktest.TestRunMockTestWithFlags(
t,
"--api-key", "string",
"pipelines:documents", "list",
"--max-items", "10",
"--pipeline-id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"--file-id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"--limit", "0",
"--only-api-data-source-documents=true",
"--only-direct-upload=true",
"--skip", "0",
"--status-refresh-policy", "cached",
)
})
}
func TestPipelinesDocumentsDelete(t *testing.T) {
t.Skip("Mock server tests are disabled")
t.Run("regular flags", func(t *testing.T) {
mocktest.TestRunMockTestWithFlags(
t,
"--api-key", "string",
"pipelines:documents", "delete",
"--pipeline-id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"--document-id", "document_id",
)
})
}
func TestPipelinesDocumentsGet(t *testing.T) {
t.Skip("Mock server tests are disabled")
t.Run("regular flags", func(t *testing.T) {
mocktest.TestRunMockTestWithFlags(
t,
"--api-key", "string",
"pipelines:documents", "get",
"--pipeline-id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"--document-id", "document_id",
)
})
}
func TestPipelinesDocumentsGetChunks(t *testing.T) {
t.Skip("Mock server tests are disabled")
t.Run("regular flags", func(t *testing.T) {
mocktest.TestRunMockTestWithFlags(
t,
"--api-key", "string",
"pipelines:documents", "get-chunks",
"--pipeline-id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"--document-id", "document_id",
)
})
}
func TestPipelinesDocumentsGetStatus(t *testing.T) {
t.Skip("Mock server tests are disabled")
t.Run("regular flags", func(t *testing.T) {
mocktest.TestRunMockTestWithFlags(
t,
"--api-key", "string",
"pipelines:documents", "get-status",
"--pipeline-id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"--document-id", "document_id",
)
})
}
func TestPipelinesDocumentsSync(t *testing.T) {
t.Skip("Mock server tests are disabled")
t.Run("regular flags", func(t *testing.T) {
mocktest.TestRunMockTestWithFlags(
t,
"--api-key", "string",
"pipelines:documents", "sync",
"--pipeline-id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"--document-id", "document_id",
)
})
}
func TestPipelinesDocumentsUpsert(t *testing.T) {
t.Skip("Mock server tests are disabled")
t.Run("regular flags", func(t *testing.T) {
mocktest.TestRunMockTestWithFlags(
t,
"--api-key", "string",
"pipelines:documents", "upsert",
"--pipeline-id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"--body", "{metadata: {foo: bar}, text: text, id: id, excluded_embed_metadata_keys: [string], excluded_llm_metadata_keys: [string], page_positions: [0]}",
)
})
t.Run("inner flags", func(t *testing.T) {
// Check that inner flags have been set up correctly
requestflag.CheckInnerFlags(pipelinesDocumentsUpsert)
// Alternative argument passing style using inner flags
mocktest.TestRunMockTestWithFlags(
t,
"--api-key", "string",
"pipelines:documents", "upsert",
"--pipeline-id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"--body.metadata", "{foo: bar}",
"--body.text", "text",
"--body.id", "id",
"--body.excluded-embed-metadata-keys", "[string]",
"--body.excluded-llm-metadata-keys", "[string]",
"--body.page-positions", "[0]",
)
})
t.Run("piping data", func(t *testing.T) {
// Test piping YAML data over stdin
pipeData := []byte("" +
"- metadata:\n" +
" foo: bar\n" +
" text: text\n" +
" id: id\n" +
" excluded_embed_metadata_keys:\n" +
" - string\n" +
" excluded_llm_metadata_keys:\n" +
" - string\n" +
" page_positions:\n" +
" - 0\n")
mocktest.TestRunMockTestWithPipeAndFlags(
t, pipeData,
"--api-key", "string",
"pipelines:documents", "upsert",
"--pipeline-id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
})
}