Skip to content

Commit

Permalink
Merge pull request #2 from cloudscale-ch/add-tests-for-mr-1105
Browse files Browse the repository at this point in the history
Add tests for PR 1105
  • Loading branch information
k-304 authored Oct 31, 2023
2 parents 393d084 + 8f87441 commit f5d6b77
Show file tree
Hide file tree
Showing 2 changed files with 186 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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"

0 comments on commit f5d6b77

Please sign in to comment.