Skip to content

Commit

Permalink
Add testfiles and include server tests in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
somsonson committed Feb 10, 2025
1 parent ea18cc7 commit b5846db
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
5 changes: 2 additions & 3 deletions api/test/examples/aasx_packages.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from aas_core3.types import AssetAdministrationShell
from aas_core3 import jsonization

json = {"id": "aasx_package_test", "assetInformation": {"assetKind": "Type"}, "modelType": "AssetAdministrationShell"}
aasx_package = jsonization.asset_administration_shell_from_jsonable(json)
aasx_package_json = {"id": "aasx_package_test", "assetInformation": {"assetKind": "Type"}, "modelType": "AssetAdministrationShell"}
aasx_package = jsonization.asset_administration_shell_from_jsonable(aasx_package_json)
29 changes: 13 additions & 16 deletions api/test/test_aasx_file_server_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,37 @@
from fastapi.testclient import TestClient

from api.server import app
from .examples.aasx_packages import aasx_package
from .examples.aasx_packages import aasx_package_json
from .examples.submodels import test_submodel_modified, test_submodel

client = TestClient(app)
BASE_URL = "/api/v3.0/"


class TestFastAPIEndpoints(unittest.TestCase):
test_submode_id = test_submodel["id"]
test_aasx_package_id = aasx_package_json["id"]
invalid_submodel_id = "some_blob"

def test_01_(self):
# Test the GET /items/{item_id} endpoint
def test_01_get_all_aasx_package_ids(self):
# Test the GET / endpoint
response = client.get(BASE_URL + "aasx/")
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json(), [])

def test_02_post_aasx_package(self):

response = client.post(BASE_URL + "aasx/", json=test_submodel)
response = client.post(BASE_URL + "aasx/", json=aasx_package_json)
self.assertEqual(response.status_code, 200)

def test_03_get_submodel_undefined(self):
response_test_undefined = client.get(BASE_URL + "aasx/" + self.invalid_submodel_id + "/")
self.assertEqual(response_test_undefined.status_code, 404)

def test_04_get_submodel(self):
response_test_entry = client.get(BASE_URL + "aasx/" + self.test_submode_id + "/")
def test_03_get_aasx_package(self):
response_test_entry = client.get(BASE_URL + "aasx/" + self.test_aasx_package_id + "/")
self.assertEqual(response_test_entry.status_code, 200)
self.assertEqual(response_test_entry.json(), test_submodel)
self.assertEqual(response_test_entry.json(), aasx_package_json)

def test_05_get_submodel_element(self):
response = client.get(BASE_URL + "aasx/" + self.test_submode_id + "/submodel-elements/" + "list_1")
self.assertEqual(response.status_code, 200)
def test_04_delete_aasx_package(self):
pass

def test_05_put_aasx_package(self):
pass


if __name__ == "__main__":
Expand Down

0 comments on commit b5846db

Please sign in to comment.