From 430440da26aa79c9533131fc6ac46d33d4a7736e Mon Sep 17 00:00:00 2001 From: Travis Smith <141754521+tsm1th@users.noreply.github.com> Date: Tue, 12 Nov 2024 11:44:15 +0000 Subject: [PATCH] Added more test cases --- .../latest/tasks/circuit_termination.yml | 107 ++++++++++++++---- 1 file changed, 84 insertions(+), 23 deletions(-) diff --git a/tests/integration/targets/latest/tasks/circuit_termination.yml b/tests/integration/targets/latest/tasks/circuit_termination.yml index 130b313b..b6f2a6bb 100644 --- a/tests/integration/targets/latest/tasks/circuit_termination.yml +++ b/tests/integration/targets/latest/tasks/circuit_termination.yml @@ -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: @@ -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 }}" @@ -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" \ No newline at end of file + - 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']" \ No newline at end of file