From c41332946c472193bd4e7744dc615bbff764891a Mon Sep 17 00:00:00 2001 From: Kenneth Joss Date: Tue, 31 Oct 2023 11:09:26 +0100 Subject: [PATCH 1/2] Add integration tests for v3.6 --- .../v3.6/tasks/netbox_power_port_template.yml | 94 ++++++++++++++++++- 1 file changed, 93 insertions(+), 1 deletion(-) diff --git a/tests/integration/targets/v3.6/tasks/netbox_power_port_template.yml b/tests/integration/targets/v3.6/tasks/netbox_power_port_template.yml index 9e7547fd9..aaa5eb43c 100644 --- a/tests/integration/targets/v3.6/tasks/netbox_power_port_template.yml +++ b/tests/integration/targets/v3.6/tasks/netbox_power_port_template.yml @@ -7,7 +7,7 @@ ### NETBOX_POWER_PORT_TEMPLATE ## ## -- name: "POWER_PORT_TEMPLATE 0: Create device type for testing power ports" +- name: "POWER_PORT_TEMPLATE 0.1: Create device type for testing power ports on device types" netbox.netbox.netbox_device_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 @@ -16,6 +16,15 @@ manufacturer: Test Manufacturer state: present +- name: "POWER_PORT_TEMPLATE 0.2: Create module type for testing power ports on module types" + netbox.netbox.netbox_module_type: + netbox_url: http://localhost:32768 + netbox_token: 0123456789abcdef0123456789abcdef01234567 + data: + model: Module Type Power Tests + manufacturer: Test Manufacturer + state: present + - name: "POWER_PORT_TEMPLATE 1: Necessary info creation" netbox.netbox.netbox_power_port_template: netbox_url: http://localhost:32768 @@ -118,3 +127,86 @@ - test_five['diff']['before']['state'] == "present" - test_five['diff']['after']['state'] == "absent" - test_five['msg'] == "power_port_template Power Port Template 2 deleted" + +- name: "POWER_PORT_TEMPLATE 6: Necessary info creation" + netbox.netbox.netbox_power_port_template: + netbox_url: http://localhost:32768 + netbox_token: 0123456789abcdef0123456789abcdef01234567 + data: + name: Module Power Port Template + module_type: Module Type Power Tests + state: present + register: test_six + +- name: "POWER_PORT_TEMPLATE 6: ASSERT - Necessary info creation" + assert: + that: + - test_six is changed + - test_six['diff']['before']['state'] == "absent" + - test_six['diff']['after']['state'] == "present" + - test_six['power_port_template']['name'] == "Module Power Port Template" + - test_six['power_port_template']['module_type'] == 1 + - test_six['msg'] == "power_port_template Module Power Port Template created" + +- name: "POWER_PORT_TEMPLATE 7: Create duplicate" + netbox.netbox.netbox_power_port_template: + netbox_url: http://localhost:32768 + netbox_token: 0123456789abcdef0123456789abcdef01234567 + data: + name: Module Power Port Template + module_type: Module Type Power Tests + state: present + register: test_seven + +- name: "POWER_PORT_TEMPLATE 7: ASSERT - Create duplicate" + assert: + that: + - not test_seven['changed'] + - test_seven['power_port_template']['name'] == "Module Power Port Template" + - test_seven['power_port_template']['module_type'] == 1 + - test_seven['msg'] == "power_port_template Module Power Port Template already exists" + +- name: "POWER_PORT_TEMPLATE 8: Update power_port_template with other fields" + netbox.netbox.netbox_power_port_template: + netbox_url: http://localhost:32768 + netbox_token: 0123456789abcdef0123456789abcdef01234567 + data: + name: Module Power Port Template + module_type: Module Type Power Tests + type: ita-e + allocated_draw: 10 + maximum_draw: 20 + state: present + register: test_eight + +- name: "POWER_PORT_TEMPLATE 8: ASSERT - Update power_port_template with other fields" + assert: + that: + - test_eight is changed + - test_eight['diff']['after']['type'] == "ita-e" + - test_eight['diff']['after']['allocated_draw'] == 10 + - test_eight['diff']['after']['maximum_draw'] == 20 + - test_eight['power_port_template']['name'] == "Module Power Port Template" + - test_eight['power_port_template']['module_type'] == 1 + - test_eight['power_port_template']['type'] == "ita-e" + - test_eight['power_port_template']['allocated_draw'] == 10 + - test_eight['power_port_template']['maximum_draw'] == 20 + - test_eight['msg'] == "power_port_template Module Power Port Template updated" + +- name: "POWER_PORT_TEMPLATE 9: Delete Power Port Template" + netbox.netbox.netbox_power_port_template: + netbox_url: http://localhost:32768 + netbox_token: 0123456789abcdef0123456789abcdef01234567 + data: + name: Module Power Port Template + module_type: Module Type Power Tests + state: absent + register: test_nine + +- name: "POWER_PORT_TEMPLATE 9: ASSERT - Delete Power Port Template" + assert: + that: + - test_nine is changed + - test_nine['diff']['before']['state'] == "present" + - test_nine['diff']['after']['state'] == "absent" + - test_nine['msg'] == "power_port_template Module Power Port Template deleted" From 8f874413ec2fcc5cb766a587fc5cf52b30e00ac7 Mon Sep 17 00:00:00 2001 From: Kenneth Joss Date: Tue, 31 Oct 2023 13:16:10 +0100 Subject: [PATCH 2/2] Add integration tests for v3.5 --- .../v3.5/tasks/netbox_power_port_template.yml | 94 ++++++++++++++++++- 1 file changed, 93 insertions(+), 1 deletion(-) diff --git a/tests/integration/targets/v3.5/tasks/netbox_power_port_template.yml b/tests/integration/targets/v3.5/tasks/netbox_power_port_template.yml index 9e7547fd9..aaa5eb43c 100644 --- a/tests/integration/targets/v3.5/tasks/netbox_power_port_template.yml +++ b/tests/integration/targets/v3.5/tasks/netbox_power_port_template.yml @@ -7,7 +7,7 @@ ### NETBOX_POWER_PORT_TEMPLATE ## ## -- name: "POWER_PORT_TEMPLATE 0: Create device type for testing power ports" +- name: "POWER_PORT_TEMPLATE 0.1: Create device type for testing power ports on device types" netbox.netbox.netbox_device_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 @@ -16,6 +16,15 @@ manufacturer: Test Manufacturer state: present +- name: "POWER_PORT_TEMPLATE 0.2: Create module type for testing power ports on module types" + netbox.netbox.netbox_module_type: + netbox_url: http://localhost:32768 + netbox_token: 0123456789abcdef0123456789abcdef01234567 + data: + model: Module Type Power Tests + manufacturer: Test Manufacturer + state: present + - name: "POWER_PORT_TEMPLATE 1: Necessary info creation" netbox.netbox.netbox_power_port_template: netbox_url: http://localhost:32768 @@ -118,3 +127,86 @@ - test_five['diff']['before']['state'] == "present" - test_five['diff']['after']['state'] == "absent" - test_five['msg'] == "power_port_template Power Port Template 2 deleted" + +- name: "POWER_PORT_TEMPLATE 6: Necessary info creation" + netbox.netbox.netbox_power_port_template: + netbox_url: http://localhost:32768 + netbox_token: 0123456789abcdef0123456789abcdef01234567 + data: + name: Module Power Port Template + module_type: Module Type Power Tests + state: present + register: test_six + +- name: "POWER_PORT_TEMPLATE 6: ASSERT - Necessary info creation" + assert: + that: + - test_six is changed + - test_six['diff']['before']['state'] == "absent" + - test_six['diff']['after']['state'] == "present" + - test_six['power_port_template']['name'] == "Module Power Port Template" + - test_six['power_port_template']['module_type'] == 1 + - test_six['msg'] == "power_port_template Module Power Port Template created" + +- name: "POWER_PORT_TEMPLATE 7: Create duplicate" + netbox.netbox.netbox_power_port_template: + netbox_url: http://localhost:32768 + netbox_token: 0123456789abcdef0123456789abcdef01234567 + data: + name: Module Power Port Template + module_type: Module Type Power Tests + state: present + register: test_seven + +- name: "POWER_PORT_TEMPLATE 7: ASSERT - Create duplicate" + assert: + that: + - not test_seven['changed'] + - test_seven['power_port_template']['name'] == "Module Power Port Template" + - test_seven['power_port_template']['module_type'] == 1 + - test_seven['msg'] == "power_port_template Module Power Port Template already exists" + +- name: "POWER_PORT_TEMPLATE 8: Update power_port_template with other fields" + netbox.netbox.netbox_power_port_template: + netbox_url: http://localhost:32768 + netbox_token: 0123456789abcdef0123456789abcdef01234567 + data: + name: Module Power Port Template + module_type: Module Type Power Tests + type: ita-e + allocated_draw: 10 + maximum_draw: 20 + state: present + register: test_eight + +- name: "POWER_PORT_TEMPLATE 8: ASSERT - Update power_port_template with other fields" + assert: + that: + - test_eight is changed + - test_eight['diff']['after']['type'] == "ita-e" + - test_eight['diff']['after']['allocated_draw'] == 10 + - test_eight['diff']['after']['maximum_draw'] == 20 + - test_eight['power_port_template']['name'] == "Module Power Port Template" + - test_eight['power_port_template']['module_type'] == 1 + - test_eight['power_port_template']['type'] == "ita-e" + - test_eight['power_port_template']['allocated_draw'] == 10 + - test_eight['power_port_template']['maximum_draw'] == 20 + - test_eight['msg'] == "power_port_template Module Power Port Template updated" + +- name: "POWER_PORT_TEMPLATE 9: Delete Power Port Template" + netbox.netbox.netbox_power_port_template: + netbox_url: http://localhost:32768 + netbox_token: 0123456789abcdef0123456789abcdef01234567 + data: + name: Module Power Port Template + module_type: Module Type Power Tests + state: absent + register: test_nine + +- name: "POWER_PORT_TEMPLATE 9: ASSERT - Delete Power Port Template" + assert: + that: + - test_nine is changed + - test_nine['diff']['before']['state'] == "present" + - test_nine['diff']['after']['state'] == "absent" + - test_nine['msg'] == "power_port_template Module Power Port Template deleted"