forked from tleyden/open-ocr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ocr_rpc_client_test.go
61 lines (48 loc) · 1.43 KB
/
ocr_rpc_client_test.go
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
package ocrworker
import (
"testing"
"github.com/couchbaselabs/go.assert"
"github.com/couchbaselabs/logg"
)
func init() {
logg.LogKeys["TEST"] = true
logg.LogKeys["OCR"] = true
logg.LogKeys["OCR_CLIENT"] = true
logg.LogKeys["OCR_WORKER"] = true
logg.LogKeys["PREPROCESSOR_WORKER"] = true
logg.LogKeys["OCR_HTTP"] = true
logg.LogKeys["OCR_TESSERACT"] = true
}
func rabbitConfigForTests() RabbitConfig {
rabbitConfig := DefaultTestConfig()
return rabbitConfig
}
// This test assumes that rabbit mq is running
func DisabledTestOcrRpcClientIntegration(t *testing.T) {
// TODO: serve this up through a fake webserver
// that reads from the filesystem
testImageUrl := "http://localhost:8080/img"
rabbitConfig := rabbitConfigForTests()
// kick off a worker
// this would normally happen on a different machine ..
ocrWorker, err := NewOcrRpcWorker(rabbitConfig)
if err != nil {
logg.LogTo("TEST", "err: %v", err)
}
ocrWorker.Run()
ocrClient, err := NewOcrRpcClient(rabbitConfig)
if err != nil {
logg.LogTo("TEST", "err: %v", err)
}
assert.True(t, err == nil)
for i := 0; i < 50; i++ {
ocrRequest := OcrRequest{ImgUrl: testImageUrl, EngineType: ENGINE_MOCK}
decodeResult, err := ocrClient.DecodeImage(ocrRequest)
if err != nil {
logg.LogTo("TEST", "err: %v", err)
}
assert.True(t, err == nil)
logg.LogTo("TEST", "decodeResult: %v", decodeResult)
assert.Equals(t, decodeResult.Text, MOCK_ENGINE_RESPONSE)
}
}