Files
httprunner/hrp/pkg/uixt/video_crawler_test.go
2023-08-19 11:48:29 +08:00

54 lines
1.2 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//go:build localtest
package uixt
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestVideoCrawler(t *testing.T) {
setupAndroid(t)
configs := &VideoCrawlerConfigs{
AppPackageName: "com.ss.android.ugc.aweme",
Timeout: 600,
Feed: FeedConfig{
TargetCount: 5,
TargetLabels: []TargetLabel{
{Text: `^广告$`, Scope: Scope{0, 0.5, 1, 1}, Regex: true},
{Text: `^图文$`, Scope: Scope{0, 0.5, 1, 1}, Regex: true, Target: 2},
{Text: `^特效\|`, Scope: Scope{0, 0.5, 1, 1}, Regex: true},
{Text: `^模板\|`, Scope: Scope{0, 0.5, 1, 1}, Regex: true},
{Text: `^购物\|`, Scope: Scope{0, 0.5, 1, 1}, Regex: true},
},
SleepRandom: []interface{}{0, 5, 0.7, 5, 10, 0.3},
},
Live: LiveConfig{
TargetCount: 3,
SleepRandom: []interface{}{15, 20},
},
}
err := driverExt.VideoCrawler(configs)
checkErr(t, err)
}
func TestRemoveNonAlphanumeric(t *testing.T) {
testData := []struct {
input string
expect string
}{
{"@Hello 你好123#@", "Hello你好123"},
{"@夏夏在发呆。", "夏夏在发呆"},
{"@·霖霖", "霖霖"},
{"@我❤️小云朵", "我小云朵"},
}
for _, data := range testData {
out := removeNonAlphanumeric(data.input)
assert.Equal(t, data.expect, out)
}
}