Skip to content

Commit

Permalink
Added more test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
tsm1th committed Nov 12, 2024
1 parent ec19e80 commit 430440d
Showing 1 changed file with 84 additions and 23 deletions.
107 changes: 84 additions & 23 deletions tests/integration/targets/latest/tasks/circuit_termination.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
circuit: '{{ lookup(''networktocode.nautobot.lookup'', ''circuits'', api_endpoint=nautobot_url, token=nautobot_token, api_filter=''cid="Test Circuit"'') }}'
circuit2: '{{ lookup(''networktocode.nautobot.lookup'', ''circuits'', api_endpoint=nautobot_url, token=nautobot_token, api_filter=''cid="Test Circuit Two"'') }}'
provider_network: '{{ lookup(''networktocode.nautobot.lookup'', ''provider-networks'', api_endpoint=nautobot_url, token=nautobot_token, api_filter=''name="Test Provider Network"'') }}'
cloud_network: '{{ lookup(''networktocode.nautobot.lookup'', ''cloud-networks'', api_endpoint=nautobot_url, token=nautobot_token, api_filter=''name="CiscoCloudNetwork"'') }}'

- name: "PYNAUTOBOT_CIRCUIT_TERMINATION 1: Create provider within Nautobot with only required information"
networktocode.nautobot.circuit_termination:
Expand Down Expand Up @@ -135,7 +134,7 @@
- test_five['circuit_termination']['port_speed'] == 10000
- test_five['msg'] == "circuit_termination test_circuit_two_z created"

- name: "PYNAUTOBOT_CIRCUIT_TERMINATION 6: Delete provider within nautobot"
- name: "PYNAUTOBOT_CIRCUIT_TERMINATION 6: Delete provider termination within nautobot"
networktocode.nautobot.circuit_termination:
url: "{{ nautobot_url }}"
token: "{{ nautobot_token }}"
Expand All @@ -158,25 +157,87 @@
- test_six['circuit_termination']['description'] == "Test description"
- test_six['msg'] == "circuit_termination test_circuit_a deleted"

- name: "PYNAUTOBOT_CIRCUIT_TERMINATION 7: Create connection to cloud_network within Nautobot with only required information"
networktocode.nautobot.circuit_termination:
url: "{{ nautobot_url }}"
token: "{{ nautobot_token }}"
circuit: Test Circuit
term_side: A
cloud_network: "CiscoCloudNetwork"
port_speed: 10000
state: present
register: test_seven
- name: "NAUTOBOT 2.3+ TESTS"
when:
- "nautobot_version is version('2.3', '>=')"
block:
- name: "SET ADDITIONAL FACTS"
set_fact:
cloud_network: '{{ lookup(''networktocode.nautobot.lookup'', ''cloud-networks'', api_endpoint=nautobot_url, token=nautobot_token, api_filter=''name="CiscoCloudNetwork"'') }}'

- name: "PYNAUTOBOT_CIRCUIT_TERMINATION 7: ASSERT - Necessary info creation"
assert:
that:
- test_seven is changed
- test_seven['diff']['before']['state'] == "absent"
- test_seven['diff']['after']['state'] == "present"
- test_seven['circuit_termination']['circuit'] == circuit['key']
- test_seven['circuit_termination']['term_side'] == "A"
- test_seven['circuit_termination']['cloud_network'] == cloud_network['key']
- test_seven['circuit_termination']['port_speed'] == 10000
- test_seven['msg'] == "circuit_termination test_circuit_a created"
- name: "PYNAUTOBOT_CIRCUIT_TERMINATION 7: Create connection to cloud_network within Nautobot with only required information"
networktocode.nautobot.circuit_termination:
url: "{{ nautobot_url }}"
token: "{{ nautobot_token }}"
circuit: Test Circuit
term_side: A
cloud_network: "CiscoCloudNetwork"
port_speed: 10000
state: present
register: test_seven

- name: "PYNAUTOBOT_CIRCUIT_TERMINATION 7: ASSERT"
assert:
that:
- test_seven is changed
- test_seven['diff']['before']['state'] == "absent"
- test_seven['diff']['after']['state'] == "present"
- test_seven['circuit_termination']['circuit'] == circuit['key']
- test_seven['circuit_termination']['term_side'] == "A"
- test_seven['circuit_termination']['cloud_network'] == cloud_network['key']
- test_seven['circuit_termination']['port_speed'] == 10000
- test_seven['msg'] == "circuit_termination test_circuit_a created"

- name: "PYNAUTOBOT_CIRCUIT_TERMINATION 8: Create connection to cloud_network idempotent"
networktocode.nautobot.circuit_termination:
url: "{{ nautobot_url }}"
token: "{{ nautobot_token }}"
circuit: Test Circuit
term_side: A
cloud_network: "CiscoCloudNetwork"
port_speed: 10000
state: present
register: test_eight

- name: "PYNAUTOBOT_CIRCUIT_TERMINATION 8: ASSERT"
assert:
that:
- not test_eight['changed']
- test_eight['circuit_termination']['circuit'] == circuit['key']
- test_eight['circuit_termination']['term_side'] == "A"
- test_eight['circuit_termination']['cloud_network'] == cloud_network['key']
- test_eight['circuit_termination']['port_speed'] == 10000
- test_eight['msg'] == "circuit_termination test_circuit_a already exists"

- name: "PYNAUTOBOT_CIRCUIT_TERMINATION 9: Delete cloud network termination"
networktocode.nautobot.circuit_termination:
url: "{{ nautobot_url }}"
token: "{{ nautobot_token }}"
circuit: Test Circuit
term_side: A
state: absent
register: test_nine

- name: "PYNAUTOBOT_CIRCUIT_TERMINATION 9: ASSERT"
assert:
that:
- test_nine is changed
- test_nine['diff']['before']['state'] == "present"
- test_nine['diff']['after']['state'] == "absent"
- test_nine['circuit_termination']['circuit'] == circuit['key']
- "'deleted' in test_nine['msg']"

- name: "PYNAUTOBOT_CIRCUIT_TERMINATION 10: Delete cloud network termination idempotent"
networktocode.nautobot.circuit_termination:
url: "{{ nautobot_url }}"
token: "{{ nautobot_token }}"
circuit: Test Circuit
term_side: A
state: absent
register: test_ten

- name: "PYNAUTOBOT_CIRCUIT_TERMINATION 10: ASSERT - Delete"
assert:
that:
- not test_ten['changed']
- "'already absent' in test_ten['msg']"

0 comments on commit 430440d

Please sign in to comment.