Skip to content

Commit 5b92a9f

Browse files
committed
test: cima api
1 parent 9cba74e commit 5b92a9f

4 files changed

Lines changed: 181 additions & 15 deletions

File tree

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{
2+
"nregistro": "79717",
3+
"cn": "706083",
4+
"nombre": "ACTYNOX 50%/50% GAS COMPRIMIDO MEDICINAL, 1 bala de gas de 15 l",
5+
"pactivos": "OXIDO NITROSO, OXIGENO",
6+
"labtitular": "S.E. De Carburos Metalicos, S.A.",
7+
"cpresc": "Uso Hospitalario",
8+
"estado": {
9+
"aut": 1428530400000
10+
},
11+
"comerc": false,
12+
"conduc": false,
13+
"receta": true,
14+
"generico": false,
15+
"triangulo": false,
16+
"huerfano": false,
17+
"biosimilar": false,
18+
"nosustituible": {
19+
"id": 0,
20+
"nombre": "N/A"
21+
},
22+
"psum": false,
23+
"notas": false,
24+
"materialesInf": true,
25+
"ema": false,
26+
"docs": [
27+
{
28+
"tipo": 1,
29+
"url": "https://cima.aemps.es/cima/pdfs/ft/79717/FT_79717.pdf",
30+
"secc": false
31+
},
32+
{
33+
"tipo": 2,
34+
"url": "https://cima.aemps.es/cima/pdfs/p/79717/P_79717.pdf",
35+
"secc": false
36+
}
37+
],
38+
"principiosActivos": [
39+
{
40+
"id": 5007,
41+
"codigo": "5007OX",
42+
"nombre": "OXIDO NITROSO",
43+
"cantidad": "50",
44+
"unidad": "%",
45+
"orden": 1
46+
},
47+
{
48+
"id": 2972,
49+
"codigo": "2972A",
50+
"nombre": "OXIGENO",
51+
"cantidad": "50",
52+
"unidad": "%",
53+
"orden": 2
54+
}
55+
],
56+
"atcs": [
57+
{
58+
"codigo": "N01A",
59+
"nombre": "ANEST\u00C9SICOS GENERALES",
60+
"nivel": 3
61+
},
62+
{
63+
"codigo": "N01AX",
64+
"nombre": "Otros anest\u00E9sicos generales",
65+
"nivel": 4
66+
},
67+
{
68+
"codigo": "N01AX63",
69+
"nombre": "\u00D3xido nitroso, combinaciones con",
70+
"nivel": 5
71+
}
72+
],
73+
"vtm": {
74+
"id": 421569007,
75+
"nombre": "oxígeno + óxido nitroso"
76+
},
77+
"dcp": {
78+
"id": 62201000140100,
79+
"nombre": "Oxígeno/Óxido nitroso 50%/50% v/v gas medicinal"
80+
},
81+
"dcpf": {
82+
"id": 62211000140102,
83+
"nombre": "Oxígeno/Óxido nitroso 50%/50% v/v gas medicinal"
84+
}
85+
}

packages/cima_api/test/src/cima_api_client_test.dart

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,87 @@ void main() {
9696
});
9797
});
9898

99+
group('getPresentation', () {
100+
final presentationEndPoint = '/cima/rest/presentacion';
101+
test('get presentation with valid cn', () async {
102+
final nationalcode = '712729';
103+
104+
when(
105+
() => client.get(Uri.https(
106+
baseUrl,
107+
'$presentationEndPoint/$nationalcode',
108+
)),
109+
).thenAnswer((_) async => Response(jsonEncode(jsonResponse), 200));
110+
final apiClient = CimaApiClient(
111+
httpClient: client,
112+
baseUrl: baseUrl,
113+
);
114+
final result =
115+
await apiClient.getPresentation(nationalCode: nationalcode);
116+
expect(result, isA<Response>());
117+
expect(result.statusCode, 200);
118+
});
119+
120+
test('get presentation with invalid cn', () async {
121+
final nationalCode = 'fake';
122+
123+
when(
124+
() => client.get(Uri.https(
125+
baseUrl,
126+
'$presentationEndPoint/$nationalCode',
127+
)),
128+
).thenAnswer((_) async => Response('', 204));
129+
final apiClient = CimaApiClient(
130+
httpClient: client,
131+
baseUrl: baseUrl,
132+
);
133+
final result =
134+
await apiClient.getPresentation(nationalCode: nationalCode);
135+
expect(result, isA<Response>());
136+
expect(result.statusCode, 204);
137+
});
138+
});
139+
140+
group('findPresentation', () {
141+
final presentationEndPoint = '/cima/rest/presentaciones';
142+
final params = <String, String>{};
143+
test('find presentation with valid cn', () async {
144+
final nationalCode = '712729';
145+
params['cn'] = nationalCode;
146+
147+
when(
148+
() => client.get(Uri.https(baseUrl, presentationEndPoint, params)),
149+
).thenAnswer((_) async => Response(jsonEncode(jsonResponse), 200));
150+
final apiClient = CimaApiClient(
151+
httpClient: client,
152+
baseUrl: baseUrl,
153+
);
154+
final result = await apiClient.searchPresentations(conditions: params);
155+
expect(result, isA<Response>());
156+
expect(result.statusCode, 200);
157+
});
158+
159+
test('find presentation with invalid cn', () async {
160+
final nationalCode = 'fake';
161+
params['cn'] = nationalCode;
162+
163+
when(
164+
() => client.get(Uri.https(
165+
baseUrl,
166+
presentationEndPoint,
167+
params,
168+
)),
169+
).thenAnswer((_) async => Response('', 204));
170+
final apiClient = CimaApiClient(
171+
httpClient: client,
172+
baseUrl: baseUrl,
173+
);
174+
final result = await apiClient.searchPresentations(conditions: params);
175+
expect(result, isA<Response>());
176+
expect(result.statusCode, 204);
177+
});
178+
});
179+
99180
group('getMedications', () {
100181
test('get medications without params', () async {
101182
final params = <String, String>{};

pubspec.lock

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -284,18 +284,18 @@ packages:
284284
dependency: "direct main"
285285
description:
286286
name: go_router
287-
sha256: d687b6129476c92bd75244b8dfc1bb56f9a287ab3d51cdf0baf570afeb923c51
287+
sha256: "1531542666c2d052c44bbf6e2b48011bf3771da0404b94c60eabec1228a62906"
288288
url: "https://pub.dev"
289289
source: hosted
290-
version: "8.0.3"
290+
version: "9.0.0"
291291
http:
292292
dependency: transitive
293293
description:
294294
name: http
295-
sha256: "4c3f04bfb64d3efd508d06b41b825542f08122d30bda4933fb95c069d22a4fa3"
295+
sha256: "759d1a329847dd0f39226c688d3e06a6b8679668e350e2891a6474f8b4bb8525"
296296
url: "https://pub.dev"
297297
source: hosted
298-
version: "1.0.0"
298+
version: "1.1.0"
299299
http_multi_server:
300300
dependency: transitive
301301
description:
@@ -588,10 +588,10 @@ packages:
588588
dependency: transitive
589589
description:
590590
name: shared_preferences_platform_interface
591-
sha256: fb5cf25c0235df2d0640ac1b1174f6466bd311f621574997ac59018a6664548d
591+
sha256: "23b052f17a25b90ff2b61aad4cc962154da76fb62848a9ce088efe30d7c50ab1"
592592
url: "https://pub.dev"
593593
source: hosted
594-
version: "2.2.0"
594+
version: "2.3.0"
595595
shared_preferences_web:
596596
dependency: transitive
597597
description:
@@ -745,10 +745,10 @@ packages:
745745
dependency: transitive
746746
description:
747747
name: url_launcher_android
748-
sha256: eed4e6a1164aa9794409325c3b707ff424d4d1c2a785e7db67f8bbda00e36e51
748+
sha256: "15f5acbf0dce90146a0f5a2c4a002b1814a6303c4c5c075aa2623b2d16156f03"
749749
url: "https://pub.dev"
750750
source: hosted
751-
version: "6.0.35"
751+
version: "6.0.36"
752752
url_launcher_ios:
753753
dependency: transitive
754754
description:
@@ -777,10 +777,10 @@ packages:
777777
dependency: transitive
778778
description:
779779
name: url_launcher_platform_interface
780-
sha256: "6c9ca697a5ae218ce56cece69d46128169a58aa8653c1b01d26fcd4aad8c4370"
780+
sha256: bfdfa402f1f3298637d71ca8ecfe840b4696698213d5346e9d12d4ab647ee2ea
781781
url: "https://pub.dev"
782782
source: hosted
783-
version: "2.1.2"
783+
version: "2.1.3"
784784
url_launcher_web:
785785
dependency: transitive
786786
description:
@@ -825,10 +825,10 @@ packages:
825825
dependency: transitive
826826
description:
827827
name: vm_service
828-
sha256: c620a6f783fa22436da68e42db7ebbf18b8c44b9a46ab911f666ff09ffd9153f
828+
sha256: b8c67f5fa3897b122cf60fe9ff314f7b0ef71eab25c5f8b771480bc338f48823
829829
url: "https://pub.dev"
830830
source: hosted
831-
version: "11.7.1"
831+
version: "11.7.2"
832832
watcher:
833833
dependency: transitive
834834
description:
@@ -857,10 +857,10 @@ packages:
857857
dependency: transitive
858858
description:
859859
name: win32
860-
sha256: "7dacfda1edcca378031db9905ad7d7bd56b29fd1a90b0908b71a52a12c41e36b"
860+
sha256: dfdf0136e0aa7a1b474ea133e67cb0154a0acd2599c4f3ada3b49d38d38793ee
861861
url: "https://pub.dev"
862862
source: hosted
863-
version: "5.0.3"
863+
version: "5.0.5"
864864
xdg_directories:
865865
dependency: transitive
866866
description:

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dependencies:
2626
sdk: flutter
2727
formz_inputs:
2828
path: packages/formz_inputs
29-
go_router: ^8.0.1
29+
go_router: ^9.0.0
3030
intl: ^0.18.0
3131
package_info_plus: ^4.0.2
3232
share_plus: ^7.0.2

0 commit comments

Comments
 (0)