forked from guigui42/mcp-vosdroits
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimpots_integration_test.go
More file actions
154 lines (133 loc) · 3.37 KB
/
impots_integration_test.go
File metadata and controls
154 lines (133 loc) · 3.37 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
package client
import (
"context"
"testing"
"time"
)
// Integration tests for impots.gouv.fr scraping
func TestSearchImpotsIntegration(t *testing.T) {
if testing.Short() {
t.Skip("Skipping integration test")
}
client := NewImpotsClient(30 * time.Second)
ctx := context.Background()
tests := []struct {
name string
query string
limit int
expectResults bool
}{
{
name: "Search for formulaire 2042",
query: "formulaire 2042",
limit: 5,
expectResults: true,
},
{
name: "Search for PEA",
query: "PEA",
limit: 5,
expectResults: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
results, err := client.SearchImpots(ctx, tt.query, tt.limit)
if err != nil {
t.Fatalf("SearchImpots failed: %v", err)
}
if tt.expectResults && len(results) == 0 {
t.Error("Expected results but got none")
}
if len(results) > 0 {
t.Logf("Found %d results for '%s':", len(results), tt.query)
for i, result := range results {
t.Logf(" %d. %s", i+1, result.Title)
t.Logf(" URL: %s", result.URL)
if result.Type != "" {
t.Logf(" Type: %s", result.Type)
}
if result.Date != "" {
t.Logf(" Date: %s", result.Date)
}
}
// Verify result structure
firstResult := results[0]
if firstResult.Title == "" {
t.Error("First result has empty title")
}
if firstResult.URL == "" {
t.Error("First result has empty URL")
}
}
})
}
}
func TestGetImpotsArticleIntegration(t *testing.T) {
if testing.Short() {
t.Skip("Skipping integration test")
}
client := NewImpotsClient(30 * time.Second)
ctx := context.Background()
tests := []struct {
name string
url string
}{
{
name: "Formulaire 2042",
url: "https://www.impots.gouv.fr/formulaire/2042/declaration-des-revenus",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
article, err := client.GetImpotsArticle(ctx, tt.url)
if err != nil {
t.Fatalf("GetImpotsArticle failed: %v", err)
}
if article.Title == "" {
t.Error("Article has empty title")
}
if article.Content == "" {
t.Error("Article has empty content")
}
if article.URL != tt.url {
t.Errorf("Expected URL %s, got %s", tt.url, article.URL)
}
t.Logf("Title: %s", article.Title)
t.Logf("URL: %s", article.URL)
t.Logf("Type: %s", article.Type)
t.Logf("Content length: %d characters", len(article.Content))
if len(article.Content) > 200 {
t.Logf("Content preview: %s...", article.Content[:200])
}
})
}
}
func TestListImpotsCategoriesIntegration(t *testing.T) {
if testing.Short() {
t.Skip("Skipping integration test")
}
client := NewImpotsClient(30 * time.Second)
ctx := context.Background()
categories, err := client.ListImpotsCategories(ctx)
if err != nil {
t.Fatalf("ListImpotsCategories failed: %v", err)
}
if len(categories) == 0 {
t.Fatal("Expected at least one category")
}
t.Logf("Found %d categories:", len(categories))
for i, cat := range categories {
t.Logf(" %d. %s: %s", i+1, cat.Name, cat.Description)
t.Logf(" URL: %s", cat.URL)
if cat.Name == "" {
t.Error("Category has empty name")
}
if cat.Description == "" {
t.Error("Category has empty description")
}
if cat.URL == "" {
t.Error("Category has empty URL")
}
}
}