Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pugnacity committed Oct 15, 2024
1 parent ab3b86d commit ce9adf4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 2 additions & 0 deletions plugins/lookup/lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ def get_endpoint(nautobot, term):
"circuits": {"endpoint": nautobot.circuits.circuits},
"circuit-providers": {"endpoint": nautobot.circuits.providers},
"cables": {"endpoint": nautobot.dcim.cables},
"controllers": {"endpoint": nautobot.dcim.controllers},
"controller-managed-device-groups": {"endpoint": nautobot.dcim.controller_managed_device_groups},
"cluster-groups": {"endpoint": nautobot.virtualization.cluster_groups},
"cluster-types": {"endpoint": nautobot.virtualization.cluster_types},
"clusters": {"endpoint": nautobot.virtualization.clusters},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@
url: "{{ nautobot_url }}"
token: "{{ nautobot_token }}"
name: Test Controller Group One
controller: controller_one
controller: "{{ controller['key'] }}"
weight: 1000
state: present
register: test_two
vars:
# yamllint disable-line rule:line-length
controller: "{{ lookup('networktocode.nautobot.lookup', 'controllers', validate_certs=documentation_nautobot.validate_certs, num_retries=3, api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=controller_one') }}"

- name: "CONTROLLER 2: ASSERT - Create duplicate"
assert:
Expand All @@ -52,15 +55,16 @@
assert:
that:
- test_three['changed']
- test_three['controller_managed_device_group']['name'] == "Test Controller One"
- test_three['controller_managed_device_group']['name'] == "Test Controller Group One"
- test_three['controller_managed_device_group']['controller'] == "controller_two"
- test_three['msg'] == "Test Controller Group One updated"
- test_three['msg'] == "controller_managed_device_group Test Controller Group One updated"

- name: "CONTROLLER GROUP 4: ASSERT - Delete"
networktocode.nautobot.controller_managed_device_group:
url: "{{ nautobot_url }}"
token: "{{ nautobot_token }}"
name: Test Controller Group One
controller: controller_two
state: absent
register: test_four

Expand All @@ -70,13 +74,14 @@
- test_four is changed
- test_four['diff']['before']['state'] == "present"
- test_four['diff']['after']['state'] == "absent"
- test_four['msg'] == "Test Controller Group One deleted"
- test_four['msg'] == "controller_managed_device_group Test Controller Group One deleted"

- name: "CONTROLLER GROUP 5: ASSERT - Delete non existing"
networktocode.nautobot.controller_managed_device_group:
url: "{{ nautobot_url }}"
token: "{{ nautobot_token }}"
name: Test Controller Two
name: Test Controller Group Two
controller: controller_two
state: absent
register: test_five

Expand All @@ -85,7 +90,7 @@
that:
- not test_five['changed']
- test_five['controller_managed_device_group'] == None
- test_five['msg'] == "controller Test Controller Two already absent"
- test_five['msg'] == "controller_managed_device_group Test Controller Two already absent"

when:
# Controllers are only available on Nautobot 2.2+
Expand Down

0 comments on commit ce9adf4

Please sign in to comment.