-
Notifications
You must be signed in to change notification settings - Fork 2
/
inverter_test.go
56 lines (45 loc) · 1.54 KB
/
inverter_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
package solaredge_test
import (
"context"
"github.com/clambin/solaredge"
"github.com/clambin/solaredge/testutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"net/http"
"testing"
"time"
)
func TestInverter_GetTelemetry(t *testing.T) {
c := solaredge.Client{Token: "1234"}
c.HTTPClient = &http.Client{Transport: &testutil.Server{Token: "1234"}}
ctx := context.Background()
sites, err := c.GetSites(ctx)
require.NoError(t, err)
require.Len(t, sites, 1)
inverters, err := sites[0].GetInverters(ctx)
require.NoError(t, err)
require.Len(t, inverters, 1)
assert.Equal(t, "SN1234", inverters[0].GetSerialNumber())
telemetries, err := inverters[0].GetTelemetry(ctx,
time.Date(2023, time.March, 1, 0, 0, 0, 0, time.UTC),
time.Date(2023, time.March, 2, 0, 0, 0, 0, time.UTC))
require.NoError(t, err)
assert.NotZero(t, telemetries)
}
func TestInverterEquipment_GetTelemetry(t *testing.T) {
c := solaredge.Client{Token: "1234"}
c.HTTPClient = &http.Client{Transport: &testutil.Server{Token: "1234"}}
ctx := context.Background()
sites, err := c.GetSites(ctx)
require.NoError(t, err)
require.Len(t, sites, 1)
inventory, err := sites[0].GetInventory(ctx)
require.NoError(t, err)
require.Len(t, inventory.Inverters, 1)
assert.Equal(t, "SN1234", inventory.Inverters[0].GetSerialNumber())
telemetries, err := inventory.Inverters[0].GetTelemetry(ctx,
time.Date(2023, time.March, 1, 0, 0, 0, 0, time.UTC),
time.Date(2023, time.March, 2, 0, 0, 0, 0, time.UTC))
require.NoError(t, err)
assert.NotZero(t, telemetries)
}