feat: Implement GetBinInfo XML command

- Add GetBinInfo command to XML API endpoint
- Return bin details including ID and ContentCode in XML format
- Implement comprehensive error handling for missing bins and invalid requests
- Add validation for required Bin ID parameter
- Add 3 comprehensive test cases covering success and error scenarios
- Update USER_MANUAL.md with detailed GetBinInfo documentation
- Maintain backward compatibility with existing XML commands

Resolves #13
This commit is contained in:
GitHub Copilot committed 2025-09-01 17:15:45 +00:00
1 parent 682a85c6eb
commit 917ea44b71
4 files changed
+131 -1

No files matched your search

+48 -1
View File
@@ -56,6 +56,44 @@ Die API verfügt über eine integrierte Hintergrund-Simulationslogik, die automa
- `POST /api` - XML-basierte Befehle
- `CreateTaskgroup` - Neue Aufgabengruppe erstellen
- `GetTaskInfo` - Aufgaben- oder Gruppeninformationen abrufen
- `GetBinInfo` - Detaillierte Informationen über einen Behälter abrufen (NEU)
#### GetBinInfo-Befehl (NEU)
Der `GetBinInfo`-Befehl ermöglicht das Abrufen detaillierter Informationen über einen bestimmten Behälter.
**Anfrage-Format:**
```xml
<AutoStore>
<GetBinInfo>
<Bin>BIN-12345</Bin>
</GetBinInfo>
</AutoStore>
```
**Antwort-Format (Erfolg):**
```xml
<AutoStore>
<GetBinInfo>
<Bin>BIN-12345</Bin>
<ContentCode>5</ContentCode>
</GetBinInfo>
</AutoStore>
```
**Antwort-Format (Fehler):**
```xml
<AutoStore>
<Error>
<Description>Bin not found: BIN-99999</Description>
</Error>
</AutoStore>
```
**Validierungen:**
- Bin-ID ist erforderlich
- Behälter muss in der Datenbank existieren
- Gibt HTTP 400 bei fehlender Bin-ID zurück
- Gibt HTTP 404 bei nicht gefundenem Behälter zurück
## Installation und Start
@@ -109,7 +147,16 @@ Die Anwendung verwendet SQLite für Entwicklung und Tests. Für Produktion kann
## Changelog
### Version 0.2.0 (Aktuell)
### Version 0.3.0 (Aktuell)
- ✅ **GetBinInfo XML-Befehl implementiert**
- Detaillierte Behälterinformationen über XML-API abrufbar
- Vollständige Fehlerbehandlung für nicht existierende Behälter
- Validierung für fehlende Bin-IDs
- Umfassende Tests für alle Szenarien
- ✅ Verbesserte XML-Fehlerbehandlung
- ✅ Erweiterte API-Dokumentation
### Version 0.2.0
- ✅ **Hintergrund-Simulationslogik implementiert**
- Automatische Verarbeitung von Aufgaben im Hintergrund
- Statusaktualisierung von Tasks und TaskGroups
+26
View File
@@ -183,6 +183,32 @@ async def handle_xml_request(request: Request, db: Session = Depends(get_db)):
}
}
}
elif command == "GetBinInfo":
bin_info_data = autostore_data[command]
# Handle case where GetBinInfo is empty or None
if not bin_info_data or not isinstance(bin_info_data, dict):
raise HTTPException(status_code=400, detail="Bin ID is required for GetBinInfo.")
bin_id = bin_info_data.get("Bin")
if not bin_id:
raise HTTPException(status_code=400, detail="Bin ID is required for GetBinInfo.")
bin_obj = crud.get_bin(db, bin_id=bin_id)
if not bin_obj:
raise ValueError(f"Bin not found: {bin_id}")
response_dict = {
"AutoStore": {
"GetBinInfo": {
"Bin": bin_obj.id,
"ContentCode": str(bin_obj.content_code)
}
}
}
else:
# Placeholder for other commands
raise HTTPException(status_code=400, detail=f"Unknown or unimplemented command: {command}")
BIN
View File
Binary file not shown.
+57
View File
@@ -577,3 +577,60 @@ def test_get_task_info_not_found(client):
assert response.status_code == 404
response_data = xmltodict.parse(response.content)
assert "Taskgroup not found" in response_data["AutoStore"]["Error"]["Description"]
def test_get_bin_info_xml(client, db_session):
"""Tests the GetBinInfo command for a specific bin."""
# Arrange: Create a bin in the database
bin_id = "BIN-INFO-01"
bin_data = schemas.BinCreate(id=bin_id, content_code=5)
crud.create_bin(db_session, bin_data)
# Act: Send GetBinInfo XML request
xml_request = f"""
<AutoStore>
<GetBinInfo>
<Bin>{bin_id}</Bin>
</GetBinInfo>
</AutoStore>
"""
headers = {"Content-Type": "application/xml"}
response = client.post("/api", content=xml_request, headers=headers)
# Assert: Check response
assert response.status_code == 200
response_data = xmltodict.parse(response.content)
bin_info = response_data["AutoStore"]["GetBinInfo"]
assert bin_info["Bin"] == bin_id
assert bin_info["ContentCode"] == "5"
def test_get_bin_info_not_found_xml(client):
"""Tests that GetBinInfo returns an error for a non-existent bin."""
xml_request = """
<AutoStore>
<GetBinInfo>
<Bin>NON-EXISTENT-BIN</Bin>
</GetBinInfo>
</AutoStore>
"""
headers = {"Content-Type": "application/xml"}
response = client.post("/api", content=xml_request, headers=headers)
assert response.status_code == 404
response_data = xmltodict.parse(response.content)
assert "Bin not found" in response_data["AutoStore"]["Error"]["Description"]
def test_get_bin_info_missing_bin_id_xml(client):
"""Tests that GetBinInfo returns an error when Bin ID is missing."""
xml_request = """
<AutoStore>
<GetBinInfo>
</GetBinInfo>
</AutoStore>
"""
headers = {"Content-Type": "application/xml"}
response = client.post("/api", content=xml_request, headers=headers)
assert response.status_code == 400
response_data = xmltodict.parse(response.content)
assert "Bin ID is required" in response_data["AutoStore"]["Error"]["Description"]