-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrebelopsio_test.go
More file actions
99 lines (87 loc) · 3.18 KB
/
rebelopsio_test.go
File metadata and controls
99 lines (87 loc) · 3.18 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
package ditzy
import (
"testing"
)
func TestRebelopsioEasternTimezone(t *testing.T) {
// rebelopsio's actual half-hourly activity pattern from internal/detector/rebelopsio_test.go
// He lives in Raleigh, NC (UTC-5 in winter, UTC-4 in summer)
// Shows activity from 06:30 EDT to 21:30 EDT (10:30 UTC to 01:30 UTC)
halfHourCounts := map[float64]int{
// Night/early morning UTC (evening EDT)
0.0: 3, 0.5: 0, // 20:00 EDT previous day
1.0: 3, 1.5: 1, // 21:00-21:30 EDT previous day
2.0: 0, 2.5: 0, // 22:00 EDT (sleep)
3.0: 0, 3.5: 0, // 23:00 EDT (sleep)
4.0: 0, 4.5: 0, // 00:00 EDT (sleep)
5.0: 0, 5.5: 0, // 01:00 EDT (sleep)
6.0: 0, 6.5: 0, // 02:00 EDT (sleep)
7.0: 0, 7.5: 0, // 03:00 EDT (sleep)
8.0: 0, 8.5: 0, // 04:00 EDT (sleep)
9.0: 0, 9.5: 0, // 05:00 EDT (sleep)
10.0: 1, 10.5: 7, // 06:00-06:30 EDT (morning start!)
11.0: 4, 11.5: 1, // 07:00-07:30 EDT
12.0: 9, 12.5: 3, // 08:00-08:30 EDT
13.0: 1, 13.5: 1, // 09:00-09:30 EDT
14.0: 10, 14.5: 5, // 10:00-10:30 EDT
15.0: 11, 15.5: 4, // 11:00-11:30 EDT (peak + lunch start)
16.0: 11, 16.5: 4, // 12:00-12:30 EDT
17.0: 4, 17.5: 9, // 13:00-13:30 EDT
18.0: 14, 18.5: 6, // 14:00-14:30 EDT (afternoon peak)
19.0: 6, 19.5: 5, // 15:00-15:30 EDT
20.0: 9, 20.5: 8, // 16:00-16:30 EDT
21.0: 4, 21.5: 2, // 17:00-17:30 EDT
22.0: 2, 22.5: 4, // 18:00-18:30 EDT
23.0: 3, 23.5: 1, // 19:00-19:30 EDT
}
// Aggregate to hourly counts for the evaluator
hourCounts := make(map[int]int)
for b, n := range halfHourCounts {
hourCounts[int(b)] += n
}
total := 0
for _, n := range halfHourCounts {
total += n
}
// Quiet hours during sleep (22:00-06:00 EDT = 02:00-10:00 UTC)
quietHours := []int{2, 3, 4, 5, 6, 7, 8, 9, 10}
midQuiet := 6.0 // Mid-sleep around 2am local = 6am UTC
candidates := evaluate(evaluationInput{
username: "rebelopsio",
hourCounts: hourCounts,
halfHourCounts: halfHourCounts,
totalActivity: total,
quietHours: quietHours,
midQuiet: midQuiet,
activeStart: 10.0,
profileTimezone: "",
})
if len(candidates) == 0 {
t.Fatal("Expected at least one timezone candidate")
}
// Find positions of key timezones
pos := make(map[float64]int)
for i, c := range candidates {
pos[c.offset] = i + 1 // 1-indexed for readability
}
// Log all candidates for debugging
t.Logf("All candidates:")
for i, c := range candidates {
t.Logf(" %d. %s (%.1f%% conf): %v", i+1, c.timezone, c.confidence, c.scoringDetails)
}
// Test 1: UTC-5 or UTC-4 (Eastern timezone) should be in top 3
// Since DST can shift between -4 and -5, either is acceptable
if pos[-5] > 3 && pos[-4] > 3 {
t.Errorf("Expected UTC-5 or UTC-4 in top 3, got UTC-5 at %d, UTC-4 at %d", pos[-5], pos[-4])
}
// Test 2: UTC-5 or UTC-4 should be ranked higher than UTC+0
// This is a user in Raleigh, NC - not UK
eastBest := min(pos[-5], pos[-4])
if eastBest > pos[0] {
t.Errorf("Expected Eastern timezone to rank higher than UTC+0: UTC-5 at %d, UTC-4 at %d, UTC+0 at %d",
pos[-5], pos[-4], pos[0])
}
// Test 3: Top candidate should have reasonable work hours
if !candidates[0].workHoursReasonable {
t.Logf("Warning: Top candidate %s has unusual work hours", candidates[0].timezone)
}
}