
    	]j$                         d Z ddlZddlZddlmZ ddlmZ ddlmZm	Z	 ddl
mZmZ d Zd	 Zej                  j                   d
        Zy)zThis file and its contents are licensed under the Apache License 2.0. Please see the included NOTICE for copyright information and LICENSE for a copy of the license.
    N)settings)7recalculate_created_annotations_and_labels_from_scratch)ProjectProjectSummary   )	make_task
project_idc                     | j                  d|       }|j                         }d|v sJ |       |d   D cg c]  }|d   	 c}S c c}w )Nz/api/tasks/?view=tasksid)getjson)business_clientview_idresponseresponse_datatasks        X/root/env/lib/python3.12/site-packages/label_studio/tests/data_manager/test_undefined.pyget_filtered_task_idsr      sU    ""%6wi#@AHMMOMm#2]2##0#9:4DJ:::s   Ac                     |d|id}| j                  dt        j                  |      d      }|j                  dk(  sJ |j                         |j                         d   S )Nfilters)projectdataz/api/dm/views/zapplication/json)r   content_type   r   )postr   dumpsstatus_codecontent)r   r	   r   payloadr   s        r   apply_filter_and_get_view_idr!      so    G$G ##ZZ ' $ H
 3&8(8(88&==?4      c                    t         j                  j                  |      }d|_        |j	                          t
        j                  }t        d|dii|      }|j                  }ddddd	d
gd}t        | ||      }t        | |      }t        |      |hk(  sJ d|g d|        d|_        |j	                          d|d   d   d<   t        | ||      }t        | |      }t        |      |hk(  sJ d|g d|        t        d|dddii|      }	|	j                  }
d|d   d   d<   d|d   d   d<   t        | ||      }t        | |      }t        |      |
hk(  sJ d|
g d|        d|d   d   d<   d	|d   d   d<   t        | ||      }t        | |      }t        |      ||
hk(  sJ d||
g d|        d|j                  d<   |j	                          t        ||j                  d       |j                          t         j                  j                  |      }t        |j"                        |dhk(  sJ d|dg d|j"                          t        | ||      }t        | |      }t        |      ||
hk(  sJ d||
g d|        y)a  
    1. Import task 1: {"$undefined$": "photo1.jpg"}
    2. Filter by `data` with value `photo`
    3. It should return task 1

    4. Set labeling config <View> <Image value="$image" name="img"/> </View>
    5. Filter by `image` with value `photo`
    6. It should return task 1

    7. Add task 2: {"$undefined$": "photo2.jpg", "extra": "123"}
    8. Filter by "extra": "123"
    9. It should return task 2
    10. Filter by "image" with value `photo`
    11. It should return task 1 and task 2

    12. Update task 1 with {"extra": "456"}
    13. Check project.summary.common_data_columns, there should be ["$undefined$", "extra"]

    14. Filter by "image" with "photo" should return task 1 and task 2
    )pkz<View></View>r   z
photo1.jpgandzfilter:tasks:data.datacontainsStringphoto)filteroperatortypevalue)conjunctionitemsz	Expected z, got z1<View> <Image value="$image" name="img"/> </View>zfilter:tasks:data.imager.   r   r)   z
photo2.jpgextra123zfilter:tasks:data.extrar,   456   )r   N)r   objectsr   label_configsaver   DATA_UNDEFINED_NAMEr   r   r!   r   setr   r   summaryrefresh_from_dbr   common_data_columns)r   r	   r   task_data_field_nametask_1	task_id_1r   r   response_idstask_2	task_id_2r8   s               r   !test_views_filters_with_undefinedrA   "   s.   , oo!!Z!0G*GLLN $77!5| DEwOF		I 
 3&  	
G +?JPG('BL|+Zy)VL>-ZZ+ OGLLN %>GGQ!*?JPG('BL|+Zy)VL>-ZZ+ !5|We TUW^_F		I %>GGQ!#(GGQ *?JPG('BL|+Zy)VL>-ZZ+ %>GGQ!#*GGQ *?JPG('BL|I 66p)YPYDZC[[abnao8pp6 !FKK
KKM <GW__VWX $$(((9Gw**+0  X 
('236':U:U9VWX  +?JPG('BL|I 66p)YPYDZC[[abnao8pp6r"   )__doc__r   pytestdjango.confr   projects.functions.utilsr   projects.modelsr   r   utilsr   r	   r   r!   mark	django_dbrA    r"   r   <module>rK      sH        \ 3 );! `q `qr"   