Boavizta / boaviztapi

🛠 Giving access to BOAVIZTA reference data and methodologies trough a RESTful API
GNU Affero General Public License v3.0
68 stars 23 forks source link

No CaseComponent is set when empty configuration is given #57

Closed da-ekchajzer closed 2 years ago

da-ekchajzer commented 2 years ago

Bug description

When an empty configuration server is given default case is not set

To Reproduce

POST /v1/server/

{}

No CASE component in verbose object

"verbose": {
"CPU-1": {
      "unit": 2,
      "core_units": 24,
      "die_size_per_core": 0.245,
      "impacts": {
        "gwp": 44,
        "pe": 650,
        "adp": 0.04
      }
    },
    "SSD-1": {
      "unit": 1,
      "capacity": 1000,
      "density": 48.5,
      "impacts": {
        "gwp": 52,
        "pe": 640,
        "adp": 0.002
      }
    },
    "RAM-1": {
      "unit": 24,
      "capacity": 32,
      "density": 0.625,
      "impacts": {
        "gwp": 2832,
        "pe": 35328,
        "adp": 0.12
      }
    },
    "POWER_SUPPLY-1": {
      "unit": 2,
      "unit_weight": 2.99,
      "impacts": {
        "gwp": 146,
        "pe": 2104,
        "adp": 0.05
      }
    },
    "MOTHERBOARD-1": {
      "unit": 1,
      "impacts": {
        "gwp": 66,
        "pe": 836,
        "adp": 0.004
      }
    },
    "ASSEMBLY-1": {
      "unit": 1,
      "impacts": {
        "gwp": 7,
        "pe": 69,
        "adp": 0
      }
    }
}

Expected behavior

If no configuration is given, a default CaseComponent should be added

JSON OUTPUT

"verbose": {
"CPU-1": {
      "unit": 2,
      "core_units": 24,
      "die_size_per_core": 0.245,
      "impacts": {
        "gwp": 44,
        "pe": 650,
        "adp": 0.04
      }
    },
    "SSD-1": {
      "unit": 1,
      "capacity": 1000,
      "density": 48.5,
      "impacts": {
        "gwp": 52,
        "pe": 640,
        "adp": 0.002
      }
    },
    "RAM-1": {
      "unit": 24,
      "capacity": 32,
      "density": 0.625,
      "impacts": {
        "gwp": 2832,
        "pe": 35328,
        "adp": 0.12
      }
    },
    "POWER_SUPPLY-1": {
      "unit": 2,
      "unit_weight": 2.99,
      "impacts": {
        "gwp": 146,
        "pe": 2104,
        "adp": 0.05
      }
    },
    "MOTHERBOARD-1": {
      "unit": 1,
      "impacts": {
        "gwp": 66,
        "pe": 836,
        "adp": 0.004
      }
    },
    "ASSEMBLY-1": {
      "unit": 1,
      "impacts": {
        "gwp": 7,
        "pe": 69,
        "adp": 0
      }
    },
    "CASE-1": {
      "unit": 1,
      "case_type": "used_value": "rack",
      "impacts": {
        "gwp": 150,
        "pe": 2200,
        "adp": 0.02
      }
}

Additional context

Add an empty ComponentCase into the default server configuration in model/devices.py line 142 get_default_configuration_component_list