Emmanuel Frimpong Asante
commited on
Commit
·
f7011cc
1
Parent(s):
62b33ab
update space
Browse files- http-client.env.json +5 -0
- test_main.http +156 -0
http-client.env.json
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"dev": {
|
3 |
+
"ACCESS_TOKEN": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ0ZXN0dXNlckBleGFtcGxlLmNvbSIsInJvbGUiOiJhZG1pbiIsInVzZXJfaWQiOiI2NzM1Yjc5OTE0ZTk0YTFmZGQyODA0MmIiLCJleHAiOjE3MzE1Nzg2Mjd9.si9yv2r-DCFFNSjQ55iS2uja31CO1kd8cP6xyI-sE7o"
|
4 |
+
}
|
5 |
+
}
|
test_main.http
ADDED
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Test your FastAPI endpoints
|
2 |
+
|
3 |
+
GET http://127.0.0.1:8000/
|
4 |
+
Accept: application/json
|
5 |
+
|
6 |
+
### Authentication Endpoints
|
7 |
+
|
8 |
+
# Register a new user
|
9 |
+
POST http://127.0.0.1:8000/auth/register
|
10 |
+
Content-Type: application/json
|
11 |
+
|
12 |
+
{
|
13 |
+
"username": "testuser",
|
14 |
+
"email": "testuser@example.com",
|
15 |
+
"password": "securepassword",
|
16 |
+
"role": "admin"
|
17 |
+
}
|
18 |
+
|
19 |
+
### Login Endpoint Test
|
20 |
+
POST http://127.0.0.1:8000/auth/login
|
21 |
+
Content-Type: application/json
|
22 |
+
|
23 |
+
{
|
24 |
+
"email": "testuser@example.com",
|
25 |
+
"password": "securepassword"
|
26 |
+
}
|
27 |
+
|
28 |
+
|
29 |
+
### Farm Management Endpoints
|
30 |
+
|
31 |
+
# Create a new group (requires admin role, assuming a token is provided)
|
32 |
+
POST http://127.0.0.1:8000/groups/
|
33 |
+
Authorization: Bearer {{ACCESS_TOKEN}}
|
34 |
+
Content-Type: application/json
|
35 |
+
|
36 |
+
{
|
37 |
+
"group_name": "Test Farm Group",
|
38 |
+
"farmers": ["farmer_id_1", "farmer_id_2"],
|
39 |
+
"created_by": "admin_id"
|
40 |
+
}
|
41 |
+
|
42 |
+
### Get group by ID
|
43 |
+
GET http://127.0.0.1:8000/groups/{group_id}
|
44 |
+
Authorization: Bearer {{ACCESS_TOKEN}}
|
45 |
+
|
46 |
+
### Update a group
|
47 |
+
PUT http://127.0.0.1:8000/groups/{group_id}
|
48 |
+
Authorization: Bearer {{ACCESS_TOKEN}}
|
49 |
+
Content-Type: application/json
|
50 |
+
|
51 |
+
{
|
52 |
+
"group_name": "Updated Farm Group"
|
53 |
+
}
|
54 |
+
|
55 |
+
### Delete a group
|
56 |
+
DELETE http://127.0.0.1:8000/groups/{group_id}
|
57 |
+
Authorization: Bearer {{ACCESS_TOKEN}}
|
58 |
+
|
59 |
+
### Health Records Endpoints
|
60 |
+
|
61 |
+
# Log a health record
|
62 |
+
POST http://127.0.0.1:8000/health/
|
63 |
+
Authorization: Bearer {{ACCESS_TOKEN}}
|
64 |
+
Content-Type: application/json
|
65 |
+
|
66 |
+
{
|
67 |
+
"farm_id": "test_farm_id",
|
68 |
+
"disease_type": "Coccidiosis",
|
69 |
+
"treatment_given": "Anti-coccidial medication",
|
70 |
+
"logged_by": "admin_id"
|
71 |
+
}
|
72 |
+
|
73 |
+
### Get health records by farm ID
|
74 |
+
GET http://127.0.0.1:8000/health/test_farm_id
|
75 |
+
Authorization: Bearer {{ACCESS_TOKEN}}
|
76 |
+
|
77 |
+
### Task Management Endpoints
|
78 |
+
|
79 |
+
# Create a new task
|
80 |
+
POST http://127.0.0.1:8000/tasks/
|
81 |
+
Authorization: Bearer {{ACCESS_TOKEN}}
|
82 |
+
Content-Type: application/json
|
83 |
+
|
84 |
+
{
|
85 |
+
"task_description": "Feed the chickens",
|
86 |
+
"assigned_to": "farmer_id",
|
87 |
+
"status": "pending",
|
88 |
+
"due_date": "2024-12-31T23:59:59Z"
|
89 |
+
}
|
90 |
+
|
91 |
+
### Get task by ID
|
92 |
+
GET http://127.0.0.1:8000/tasks/{task_id}
|
93 |
+
Authorization: Bearer {{ACCESS_TOKEN}}
|
94 |
+
|
95 |
+
# Update a task
|
96 |
+
PUT http://127.0.0.1:8000/tasks/{task_id}
|
97 |
+
Authorization: Bearer {{ACCESS_TOKEN}}
|
98 |
+
Content-Type: application/json
|
99 |
+
|
100 |
+
{
|
101 |
+
"task_description": "Feed the chickens - updated",
|
102 |
+
"status": "in-progress"
|
103 |
+
}
|
104 |
+
|
105 |
+
### Delete a task
|
106 |
+
DELETE http://127.0.0.1:8000/tasks/{task_id}
|
107 |
+
Authorization: Bearer {{ACCESS_TOKEN}}
|
108 |
+
|
109 |
+
### Inventory Management Endpoints
|
110 |
+
|
111 |
+
# Add an inventory item
|
112 |
+
POST http://127.0.0.1:8000/inventory/
|
113 |
+
Authorization: Bearer {{ACCESS_TOKEN}}
|
114 |
+
Content-Type: application/json
|
115 |
+
|
116 |
+
{
|
117 |
+
"item_name": "Chicken Feed",
|
118 |
+
"quantity": 100,
|
119 |
+
"status": "in-stock",
|
120 |
+
"updated_by": "admin_id"
|
121 |
+
}
|
122 |
+
|
123 |
+
### Get inventory item by ID
|
124 |
+
GET http://127.0.0.1:8000/inventory/{item_id}
|
125 |
+
Authorization: Bearer {{ACCESS_TOKEN}}
|
126 |
+
|
127 |
+
# Update an inventory item
|
128 |
+
PUT http://127.0.0.1:8000/inventory/{item_id}
|
129 |
+
Authorization: Bearer {{ACCESS_TOKEN}}
|
130 |
+
Content-Type: application/json
|
131 |
+
|
132 |
+
{
|
133 |
+
"quantity": 150,
|
134 |
+
"status": "in-stock"
|
135 |
+
}
|
136 |
+
|
137 |
+
# Delete an inventory item
|
138 |
+
DELETE http://127.0.0.1:8000/inventory/{item_id}
|
139 |
+
Authorization: Bearer {{ACCESS_TOKEN}}
|
140 |
+
|
141 |
+
### Disease Detection Endpoint
|
142 |
+
|
143 |
+
# Predict disease from an uploaded image (replace image.png with actual test image path)
|
144 |
+
POST http://127.0.0.1:8000/disease_detection/predict_disease/
|
145 |
+
Authorization: Bearer {{ACCESS_TOKEN}}
|
146 |
+
Content-Type: multipart/form-data
|
147 |
+
|
148 |
+
--boundary
|
149 |
+
Content-Disposition: form-data; name="file"; filename="image.png"
|
150 |
+
Content-Type: image/png
|
151 |
+
|
152 |
+
< ./path/to/your/image.png
|
153 |
+
--boundary--
|
154 |
+
|
155 |
+
|
156 |
+
|