# Process for updating queries in tests

**URL:** <https://forum.ansible.com/t/process-for-updating-queries-in-tests/34221>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [November 22, 2020, 6:58pm UTC](https://forum.ansible.com/t/process-for-updating-queries-in-tests/34221 "2020-11-22T18:58:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sophie\_Xie](https://avatars.discourse-cdn.com/v4/letter/s/dbc845/32.png) [@Sophie\_Xie](https://forum.ansible.com/u/Sophie_Xie)\
**Post date:** [November 22, 2020, 6:58pm UTC](https://forum.ansible.com/t/process-for-updating-queries-in-tests/34221/1 "2020-11-22T18:58:07Z")

</div>

Hi,

Below are a few queries in some tests that have yet to be updated. These are queries that still refer to deleted queries. For example, in the lines below the deleted field ‘organization’ in both the project and workflowjobtemplate model was deleted in previous migrations, yet they’re still referenced here in these tests. I’m wondering what the protocol here is when updating queries that reference deleted or renamed fields in tests.

[awx/awx/main/tests/functional/test\_projects.py](https://github.com/ansible/awx/blob/b6a55e53d525655a116b99e9b825c9f9a87845e1/awx/main/tests/functional/test_projects.py#L202)

Line 202  
assert Project.objects.filter(name=‘Project’, organization=organization).exists()

[awx/awx/main/tests/functional/api/test\_rbac\_displays.py](https://github.com/ansible/awx/blob/b6a55e53d525655a116b99e9b825c9f9a87845e1/awx/main/tests/functional/api/test_rbac_displays.py#L317)

Line 317

wfjt = WorkflowJobTemplate.objects.create(name=‘test’, organization=None)

---

<div class="post-metadata">

**Author:** ![Bill\_Nottingham1](https://avatars.discourse-cdn.com/v4/letter/b/58f4c7/32.png) [@Bill\_Nottingham1](https://forum.ansible.com/u/Bill_Nottingham1)\
**Post date:** [November 23, 2020, 6:03pm UTC](https://forum.ansible.com/t/process-for-updating-queries-in-tests/34221/2 "2020-11-23T18:03:37Z")

</div>

Where do you see them being removed? Organization is a field on both projects and workflow templates.

Bill

---

<div class="post-metadata">

**Author:** ![Sophie\_Xie](https://avatars.discourse-cdn.com/v4/letter/s/dbc845/32.png) [@Sophie\_Xie](https://forum.ansible.com/u/Sophie_Xie)\
**Post date:** [November 23, 2020, 11:44pm UTC](https://forum.ansible.com/t/process-for-updating-queries-in-tests/34221/3 "2020-11-23T23:44:22Z")

</div>

In migration 0109, lines 41-49, it looks like the organization field got removed from the models project and workflowjobtemplate. Also, it looks like in the versions before the migration was committed there were quite a few queries that referred to the fields, but in the versions after the migration was commited it looks like the only queries left are in some tests. Right now in the models files too, I don’t see any organization field in the project or workflowjobtemplate models. I could definitely be mistaken about this, so it would be great if you could tell me what I am seeing wrong.

[https://github.com/ansible/awx/blob/devel/awx/main/migrations/0109\_v370\_job\_template\_organization\_field.py](https://github.com/ansible/awx/blob/devel/awx/main/migrations/0109_v370_job_template_organization_field.py)

Thank you,  
Sophie

---

<div class="post-metadata">

**Author:** ![Bill\_Nottingham1](https://avatars.discourse-cdn.com/v4/letter/b/58f4c7/32.png) [@Bill\_Nottingham1](https://forum.ansible.com/u/Bill_Nottingham1)\
**Post date:** [November 24, 2020, 9:51pm UTC](https://forum.ansible.com/t/process-for-updating-queries-in-tests/34221/4 "2020-11-24T21:51:45Z")

</div>

Sophie Xie (sxie2@cps.edu) said:

> In migration 0109, lines 41-49, it looks like the organization field got  
> removed from the models project and workflowjobtemplate. Also, it looks  
> like in the versions before the migration was committed there were quite a  
> few queries that referred to the fields, but in the versions after the  
> migration was commited it looks like the only queries left are in some  
> tests. Right now in the models files too, I don't see any organization  
> field in the project or workflowjobtemplate models. I could definitely be  
> mistaken about this, so it would be great if you could tell me what I am  
> seeing wrong.

The migration moved 'organization' to the UnifiedJobTemplate, from which  
Projects and Workflow Templates both inherit things, so they both still have  
'organization' as an field/attribute.

Bill

---

<div class="post-metadata">

**Author:** ![Sophie\_Xie](https://avatars.discourse-cdn.com/v4/letter/s/dbc845/32.png) [@Sophie\_Xie](https://forum.ansible.com/u/Sophie_Xie)\
**Post date:** [November 24, 2020, 10:00pm UTC](https://forum.ansible.com/t/process-for-updating-queries-in-tests/34221/5 "2020-11-24T22:00:30Z")

</div>

Oh, I see. Thank you!
