-
Notifications
You must be signed in to change notification settings - Fork 2
/
healthministry_test.go
104 lines (83 loc) · 3.12 KB
/
healthministry_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
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
package main
import (
"github.com/stretchr/testify/assert"
"testing"
)
var e = newHealthMinistryExporter()
func TestBezirke(t *testing.T) {
result, err := e.getBezirke()
assert.Nil(t, err)
assert.True(t, len(result) > 10, len(result))
for _, s := range result {
assert.Equal(t, 4, len(*s.Tags), s.Tags)
}
}
func TestBundesland(t *testing.T) {
result, err := e.getBundeslandInfections()
assert.Nil(t, err)
assert.True(t, len(result) == 3*9, len(result))
for _, s := range result {
assert.Equal(t, 4, len(*s.Tags), s.Tags)
}
vienna := result.findMetric("cov19_detail", "province=Wien")
assert.NotNil(t, vienna)
assert.Equal(t, (*vienna.Tags)["country"], "Austria")
assert.Equal(t, (*vienna.Tags)["latitude"], "48.206351")
assert.Equal(t, (*vienna.Tags)["longitude"], "16.374817")
assert.NotNil(t, result.findMetric("cov19_detail_infection_rate", "province=Salzburg"))
infectionRate := result.findMetric("cov19_detail_infection_rate", "province=Wien")
assert.NotNil(t, infectionRate)
assert.True(t, infectionRate.Value > 0 && infectionRate.Value < 1, infectionRate.Value)
infected100k := result.findMetric("cov19_detail_infected_per_100k", "province=Wien")
assert.NotNil(t, infected100k)
assert.True(t, infected100k.Value > 5 && infected100k.Value < 100, infected100k.Value)
}
func TestBundeslandHealedDeaths(t *testing.T) {
result, err := e.getBundeslandHealedDeaths()
assert.Nil(t, err)
assert.True(t, len(result) == 2*9, len(result))
for _, s := range result {
assert.Equal(t, 4, len(*s.Tags), s.Tags)
}
vienna := result.findMetric("cov19_detail_dead", "province=Wien")
assert.NotNil(t, vienna)
assert.Equal(t, (*vienna.Tags)["country"], "Austria")
assert.Equal(t, (*vienna.Tags)["latitude"], "48.206351")
assert.Equal(t, (*vienna.Tags)["longitude"], "16.374817")
vienna = result.findMetric("cov19_detail_healed", "province=Wien")
assert.NotNil(t, vienna)
assert.Equal(t, (*vienna.Tags)["country"], "Austria")
assert.Equal(t, (*vienna.Tags)["latitude"], "48.206351")
assert.Equal(t, (*vienna.Tags)["longitude"], "16.374817")
assert.NotNil(t, result.findMetric("cov19_detail_dead", "province=Salzburg"))
assert.NotNil(t, result.findMetric("cov19_detail_healed", "province=Salzburg"))
}
func TestAltersverteilung(t *testing.T) {
result, err := e.getAgeMetrics()
assert.Nil(t, err)
assert.True(t, len(result) >= 4, len(result))
for _, s := range result {
assert.Equal(t, 2, len(*s.Tags), s.Tags)
}
}
func TestGeschlechtsVerteilung(t *testing.T) {
result, _ := e.getGeschlechtsVerteilung()
assert.Equal(t, 2, len(result))
assert.Equal(t, int64(100), int64(result[0].Value+result[1].Value))
}
func TestSimpleData(t *testing.T) {
result, err := e.getSimpleData()
assert.Equal(t, 0, len(err))
assert.NotNil(t, result.findMetric("cov19_confirmed", ""))
assert.NotNil(t, result.findMetric("cov19_hospitalized", ""))
assert.NotNil(t, result.findMetric("cov19_intensive_care", ""))
}
func TestHealthMinistryHealth(t *testing.T) {
errors := e.Health()
assert.Equal(t, 0, len(errors))
}
func TestHealthMinistryGetMetrics(t *testing.T) {
result, err := e.GetMetrics()
assert.Nil(t, err, err)
assert.NotNil(t, result)
}