Skip to content

Commit

Permalink
test: clean up mock blueprint provider, and also simpler blueprintNames
Browse files Browse the repository at this point in the history
  • Loading branch information
pbullhove committed Sep 11, 2023
1 parent 06e9cbd commit 50a8954
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 91 deletions.
28 changes: 7 additions & 21 deletions src/tests/unit/mock_data/mock_blueprint_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,16 @@ def get_blueprint(type: str):
"two_contained_deep_attributes",
"uncontained_blueprint",
"uncontained_list_blueprint",
"FuelPumpTest",
"CarTest",
"WheelTest",
"EngineTest",
"CarRental",
"Customer",
"RentalCar",
]:
with open(_FILE_PATH + type + ".blueprint.json") as f:
return Blueprint(json.load(f), type)
if type == "test_data/complex/FuelPumpTest":
with open(_FILE_PATH + "FuelPumpTest.blueprint.json") as f:
return Blueprint(json.load(f), type)
if type == "test_data/complex/EngineTest":
with open(_FILE_PATH + "EngineTest.blueprint.json") as f:
return Blueprint(json.load(f), type)
if type == "test_data/complex/CarTest":
with open(_FILE_PATH + "CarTest.blueprint.json") as f:
return Blueprint(json.load(f), type)
if type == "test_data/complex/WheelTest":
with open(_FILE_PATH + "WheelTest.blueprint.json") as f:
return Blueprint(json.load(f), type)
if type == "test_data/complex/CarRental":
with open(_FILE_PATH + "CarRental.blueprint.json") as f:
return Blueprint(json.load(f), type)
if type == "test_data/complex/RentalCar":
with open(_FILE_PATH + "RentalCar.blueprint.json") as f:
return Blueprint(json.load(f), type)
if type == "test_data/complex/Customer":
with open(_FILE_PATH + "Customer.blueprint.json") as f:
return Blueprint(json.load(f), type)
else:
return Blueprint(file_repository_test.get(type), type)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
"name": "cars",
"type": "system/SIMOS/BlueprintAttribute",
"dimensions": "*",
"attributeType": "test_data/complex/RentalCar"
"attributeType": "RentalCar"
},
{
"name": "customers",
"type": "system/SIMOS/BlueprintAttribute",
"dimensions": "*",
"attributeType": "test_data/complex/Customer"
"attributeType": "Customer"
}
]
}
16 changes: 8 additions & 8 deletions src/tests/unit/mock_data/mock_blueprints/CarTest.blueprint.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"name": "type",
"type": "system/SIMOS/BlueprintAttribute",
"attributeType": "string",
"default": "test_data/complex/CarTest"
"default": "CarTest"
},
{
"name": "plateNumber",
Expand All @@ -22,12 +22,12 @@
{
"name": "wheel",
"type": "system/SIMOS/BlueprintAttribute",
"attributeType": "test_data/complex/WheelTest"
"attributeType": "WheelTest"
},
{
"name": "wheels",
"type": "system/SIMOS/BlueprintAttribute",
"attributeType": "test_data/complex/WheelTest",
"attributeType": "WheelTest",
"dimensions": "*"
},
{
Expand Down Expand Up @@ -90,25 +90,25 @@
{
"name": "engine",
"type": "system/SIMOS/BlueprintAttribute",
"attributeType": "test_data/complex/EngineTest"
"attributeType": "EngineTest"
},
{
"name": "engine2",
"type": "system/SIMOS/BlueprintAttribute",
"optional": true,
"attributeType": "test_data/complex/EngineTest"
"attributeType": "EngineTest"
},
{
"name": "engine3",
"type": "system/SIMOS/BlueprintAttribute",
"optional": true,
"attributeType": "test_data/complex/EngineTest",
"attributeType": "EngineTest",
"default": {
"name": "default engine",
"type": "test_data/complex/EngineTest",
"type": "EngineTest",
"fuelPump": {
"name": "fuelPump",
"type": "test_data/complex/FuelPumpTest",
"type": "FuelPumpTest",
"description": "A standard fuel pump"
},
"power": 9
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{
"name": "car",
"type": "system/SIMOS/BlueprintAttribute",
"attributeType": "test_data/complex/RentalCar",
"attributeType": "RentalCar",
"contained": false
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
{
"name": "fuelPump",
"type": "system/SIMOS/BlueprintAttribute",
"attributeType": "test_data/complex/FuelPumpTest",
"attributeType": "FuelPumpTest",
"default": {
"name": "fuelPump",
"type": "test_data/complex/FuelPumpTest",
"type": "FuelPumpTest",
"description": "A standard fuel pump"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"name": "type",
"type": "system/SIMOS/BlueprintAttribute",
"attributeType": "string",
"default": "test_data/complex/RentalCar"
"default": "RentalCar"
},
{
"name": "plateNumber",
Expand All @@ -22,7 +22,7 @@
{
"name": "engine",
"type": "system/SIMOS/BlueprintAttribute",
"attributeType": "test_data/complex/EngineTest",
"attributeType": "EngineTest",
"optional": true
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ def test_reference_with_query_and_slash_to_reference_items(self):
)

def test_reference_with_query_2_to_reference_items(self):
path = "/(type=test_data/complex/Customer)"
path = "/(type=Customer)"
items = path_to_path_items(path)
self.assertEqual(
items,
[
QueryItem(query="type=test_data/complex/Customer"),
QueryItem(query="type=Customer"),
],
)

Expand Down
12 changes: 6 additions & 6 deletions src/tests/unit/test_common/test_utils/test_resolve_address.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ class ResolveReferenceTestCase(unittest.TestCase):
def setUp(self):
self.car_rental_company = {
"_id": "car_rental_company_id",
"type": "test_data/complex/CarRental",
"type": "CarRental",
"name": "myCarRentalCompany",
"cars": [
{
"type": "test_data/complex/RentalCar",
"type": "RentalCar",
"name": "Volvo 240",
"plateNumber": "123",
"engine": {
Expand All @@ -36,7 +36,7 @@ def setUp(self):
"referenceType": REFERENCE_TYPES.LINK.value,
},
{
"type": "test_data/complex/Customer",
"type": "Customer",
"name": "Jon",
"car": {
"address": "^.cars[0]",
Expand All @@ -48,7 +48,7 @@ def setUp(self):
}
self.customer = {
"_id": "customer_id",
"type": "test_data/complex/Customer",
"type": "Customer",
"name": "Jane",
"car": {
"address": "$car_rental_company_id.cars[0]",
Expand All @@ -58,7 +58,7 @@ def setUp(self):
}
self.engine = {
"_id": "engine_id",
"type": "test_data/complex/EngineTest",
"type": "EngineTest",
"name": "myEngine",
"description": "",
"fuelPump": {
Expand All @@ -70,7 +70,7 @@ def setUp(self):
}
self.fuel_pump = {
"_id": "fuel_pump_id",
"type": "test_data/complex/FuelPumpTest",
"type": "FuelPumpTest",
"name": "fuelPump",
"description": "A standard fuel pump",
}
Expand Down
10 changes: 5 additions & 5 deletions src/tests/unit/test_create_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@ def test_blueprint_entity(self):
"fuelPump": {
"name": "fuelPump",
"description": "A standard fuel pump",
"type": "test_data/complex/FuelPumpTest",
"type": "FuelPumpTest",
},
"power": 120,
"type": "test_data/complex/EngineTest",
"type": "EngineTest",
},
"is_sedan": True,
"name": "CarTest",
"plateNumber": "",
"seats": 2,
"type": "test_data/complex/CarTest",
"wheel": {"name": "Wheel", "power": 0.0, "type": "test_data/complex/WheelTest"},
"type": "CarTest",
"wheel": {"name": "Wheel", "power": 0.0, "type": "WheelTest"},
"wheels": [],
"floatValues": [2.1, 3.1, 4.2],
"intValues": [1, 5, 4, 2],
"boolValues": [True, False, True],
"stringValues": ["one", "two", "three"],
}

entity = CreateEntity(blueprint_provider=blueprint_provider, type="test_data/complex/CarTest").entity
entity = CreateEntity(blueprint_provider=blueprint_provider, type="CarTest").entity

self.assertEqual(expected_entity, entity)

Expand Down
10 changes: 5 additions & 5 deletions src/tests/unit/test_get_document/test_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ class GetDocumentInputTestCase(unittest.TestCase):
def setUp(self):
self.car_rental_company = {
"_id": "1",
"type": "test_data/complex/CarRental",
"type": "CarRental",
"name": "myCarRentalCompany",
"cars": [
{
"type": "test_data/complex/RentalCar",
"type": "RentalCar",
"name": "Volvo 240",
"plateNumber": "123",
"engine": {
Expand All @@ -36,7 +36,7 @@ def setUp(self):
}
self.customer = {
"_id": "4",
"type": "test_data/complex/Customer",
"type": "Customer",
"name": "Jane",
"car": {
"address": "$1.cars[0]",
Expand All @@ -46,7 +46,7 @@ def setUp(self):
}
self.engine = {
"_id": "2",
"type": "test_data/complex/EngineTest",
"type": "EngineTest",
"name": "myEngine",
"description": "",
"fuelPump": {
Expand All @@ -58,7 +58,7 @@ def setUp(self):
}
self.fuel_pump = {
"_id": "3",
"type": "test_data/complex/FuelPumpTest",
"type": "FuelPumpTest",
"name": "fuelPump",
"description": "A standard fuel pump",
}
Expand Down
Loading

0 comments on commit 50a8954

Please sign in to comment.