Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes tests for latest ansible versions #289

Merged
merged 5 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 3 additions & 23 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions tests/integration/targets/latest/tasks/lookup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@
##
- name: "PYNAUTOBOT_LOOKUP 1: Lookup returns exactly five locations"
assert:
that: "{{ query_result|count }} == 5"
that: "query_result | count == 5"
vars:
query_result: "{{ query('networktocode.nautobot.lookup', 'locations', api_endpoint=nautobot_url, token=nautobot_token) }}"

- name: "PYNAUTOBOT_LOOKUP 2: Query doesn't return Wibble (sanity check json_query)"
assert:
that: "{{ query_result|json_query('[?value.display==`Wibble`]')|count }} == 0"
that: "query_result | json_query('[?value.display==`Wibble`]') | count == 0"
vars:
query_result: "{{ query('networktocode.nautobot.lookup', 'devices', api_endpoint=nautobot_url, token=nautobot_token) }}"

- name: "PYNAUTOBOT_LOOKUP 3: Device query returns exactly one TestDeviceR1"
assert:
that: "{{ query_result|json_query('[?value.display==`TestDeviceR1`]')|count }} == 1"
that: "query_result | json_query('[?value.display==`TestDeviceR1`]') | count == 1"
vars:
query_result: "{{ query('networktocode.nautobot.lookup', 'devices', api_endpoint=nautobot_url, token=nautobot_token) }}"

- name: "PYNAUTOBOT_LOOKUP 4: VLAN ID 400 can be queried and is named 'Test VLAN'"
assert:
that: "{{ (query_result|json_query('[?value.vid==`400`].value.name'))[0] == 'Test VLAN' }}"
that: "query_result | json_query('[?value.vid==`400`].value.name') | first == 'Test VLAN'"
vars:
query_result: "{{ query('networktocode.nautobot.lookup', 'vlans', api_endpoint=nautobot_url, token=nautobot_token) }}"

Expand Down Expand Up @@ -62,20 +62,20 @@

- name: "PYNAUTOBOT_LOOKUP 7: Device query returns exactly the L2 device"
assert:
that: "{{ query_result|json_query('[?value.display==`L2`]')|count }} == 1"
that: "query_result | json_query('[?value.display==`L2`]') | count == 1"
vars:
query_result: "{{ query('networktocode.nautobot.lookup', 'devices', api_filter='role=\"Core Switch\" tags=Lookup', api_endpoint=nautobot_url, token=nautobot_token) }}"

- name: "PYNAUTOBOT_LOOKUP 8: Device query specifying raw data returns payload without key/value dict"
assert:
that: "{{ query_result|json_query('[?display==`L2`]')|count }} == 1"
that: "query_result | json_query('[?display==`L2`]') | count == 1"
vars:
query_result: "{{ query('networktocode.nautobot.lookup', 'devices', api_filter='role=\"Core Switch\" tags=Lookup', api_endpoint=nautobot_url, token=nautobot_token, raw_data=True) }}"

- name: "PYNAUTOBOT_LOOKUP 9: Device query specifying multiple locations, Make sure L1 and L2 are in the results"
assert:
that:
- "'L1' in {{ query_result |json_query('[*].display') }}"
- "'L2' in {{ query_result |json_query('[*].display') }}"
- "'L1' in query_result | json_query('[*].display')"
- "'L2' in query_result | json_query('[*].display')"
vars:
query_result: "{{ query('networktocode.nautobot.lookup', 'devices', api_filter='role=\"Core Switch\" location=\"Child Test Location\" location=\"Child-Child Test Location\"', api_endpoint=nautobot_url, token=nautobot_token, raw_data=True) }}"
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
- test_one['relationship_associations']['source_id'] == vlan['key']
- test_one['relationship_associations']['destination_type'] == relationship['value']['destination_type']
- test_one['relationship_associations']['destination_id'] == device['key']
- test_one['msg'] == "relationship_associations {{ relationship['value']['source_type'] }} -> {{ relationship['value']['destination_type'] }} created"
- "'created' in test_one['msg']"

- name: "RELATIONSHIP ASSOCIATION 2: Test duplication association (Idempotency)"
networktocode.nautobot.relationship_association:
Expand All @@ -52,7 +52,7 @@
that:
- test_two is not changed
- test_two['relationship_associations']['relationship'] == relationship['key']
- test_two['msg'] == "relationship_associations {{ relationship['value']['source_type'] }} -> {{ relationship['value']['destination_type'] }} already exists"
- "'already exists' in test_two['msg']"

- name: "RELATIONSHIP ASSOCIATION 3: Test absent state"
networktocode.nautobot.relationship_association:
Expand All @@ -77,7 +77,7 @@
- test_three['relationship_associations']['source_id'] == vlan['key']
- test_three['relationship_associations']['destination_type'] == relationship['value']['destination_type']
- test_three['relationship_associations']['destination_id'] == device['key']
- test_three['msg'] == "relationship_associations {{ relationship['value']['source_type'] }} -> {{ relationship['value']['destination_type'] }} deleted"
- "'deleted' in test_three['msg']"

- name: "RELATIONSHIP ASSOCIATION 4: Test absent state (Idempotent)"
networktocode.nautobot.relationship_association:
Expand All @@ -95,4 +95,4 @@
assert:
that:
- test_four is not changed
- test_four['msg'] == "relationship_associations {{ relationship['value']['source_type'] }} -> {{ relationship['value']['destination_type'] }} already absent"
- "'already absent' in test_four['msg']"