Minimal inventory check test for FRUs.

Resolves openbmc/openbmc-test-automation#722

Change-Id: I8888a0dfda2a134a1b1071259be60a9f4ff72988
Signed-off-by: Sweta Potthuri <spotthur@in.ibm.com>
diff --git a/tests/test_inventory.robot b/tests/test_inventory.robot
index 5403767..a2cbd60 100644
--- a/tests/test_inventory.robot
+++ b/tests/test_inventory.robot
@@ -244,6 +244,61 @@
     Run Keyword If  ${air_cooled}==${0} and ${water_cooled}==${0}
     ...  Fail  Neither AirCooled or WaterCooled.
 
+Verify Minimal CPU Inventory
+    [Documentation]  Verify minimal CPU inventory.
+    [Tags]  Verify_Minimal_CPU_Inventory
+
+    # item         minimum_count
+    cpu            1
+    [Template]     Minimum Inventory
+
+Verify Minimal DIMM Inventory
+    [Documentation]  Verify minimal DIMM inventory.
+    [Tags]  Verify_Minimal_DIMM_Inventory
+
+    # item         minimum_count
+    dimm           2
+    [Template]     Minimum Inventory
+
+Verify Minimal Core Inventory
+    [Documentation]  Verify minimal core inventory.
+    [Tags]  Verify_Minimal_Core_Inventory
+
+    # item         minimum_count
+    core           1
+    [Template]     Minimum Inventory
+
+Verify Minimal Memory Buffer Inventory
+    [Documentation]  Verify minimal memory buffer inventory.
+    [Tags]  Verify_Minimal_Memory_Buffer_Inventory
+
+    # item         minimum_count
+    memory_buffer  1
+    [Template]     Minimum Inventory
+
+Verify Minimal Fan Inventory
+    [Documentation]  Verify minimal fan inventory.
+    [Tags]  Verify_Minimal_Fan_Inventory
+
+    # item         minimum_count
+    fan            2
+    [Template]     Minimum Inventory
+
+Verify Minimal Main Planar Inventory
+    [Documentation]  Verify minimal main planar inventory.
+    [Tags]  Verify_Minimal_Main_Planar_Inventory
+
+    # item         minimum_count
+    main_planar    1
+    [Template]     Minimum Inventory
+
+Verify Minimal System Inventory
+    [Documentation]  Verify minimal system inventory.
+    [Tags]  Verify_Minimal_System_Inventory
+
+    # item         minimum_count
+    system         1
+    [Template]     Minimum Inventory
 
 *** Keywords ***
 
@@ -259,7 +314,6 @@
     Wait Until Keyword Succeeds
     ...  10 min  10 sec  Is OS Starting
 
-
 Get Inventory
     [Documentation]  Get the properties of an endpoint.
     [Arguments]  ${endpoint}
@@ -347,3 +401,31 @@
     Wait Until Keyword Succeeds  10 min  10 sec  Is OS Starting
     ${inv_after}=  Get URL List  ${HOST_INVENTORY_URI}
     Lists Should Be Equal  ${inv_before}  ${inv_after}
+
+Minimum Inventory
+    [Documentation]  Check for minimum inventory.
+    [Arguments]  ${item}  ${minimum_count}
+
+    # Description of argument(s):
+    # item  Inventory name (example: "fan/cpu/dimm/etc").
+    # minimum_count  The minimum number of the given item.
+
+    ${count}=  Get Number Hardware Items  ${item}
+    Should Be True  ${count}>=${minimum_count}
+
+Get Number Hardware Items
+    [Documentation]  Get the count of the total present currently on inventory.
+    [Arguments]  ${item}
+
+    # Description of argument(s):
+    # item  Inventory name (example: "fan/cpu/dimm/etc").
+
+    ${count_inventory}  Set Variable  ${0}
+    ${list}=  Get Endpoint Paths  ${HOST_INVENTORY_URI}/system/
+    ...  ${item}
+
+    : FOR  ${element}  IN  @{list}
+    \  ${present}=  Read Properties  ${element}
+    \  ${count_inventory}=  Set Variable if  ${present['Present']} == 1
+    \  ...  ${count_inventory+1}  ${count_inventory}
+    [return]  ${count_inventory}