@@ -2096,3 +2096,117 @@ def test_validate_pixel_annotation_instance_without_class_name(self):
20962096 data = json .loads (f .read ())
20972097 validator = AnnotationValidators .get_validator ("pixel" )(data )
20982098 self .assertTrue (validator .is_valid ())
2099+
2100+
2101+ def test_validate_document_wrong_meta_data (self ):
2102+ with tempfile .TemporaryDirectory () as tmpdir_name :
2103+ path = f"{ tmpdir_name } /test_validate_document_annotation_without_classname.json"
2104+ with open (path , "w" ) as test_validate_document_annotation_without_classname :
2105+ test_validate_document_annotation_without_classname .write (
2106+ '''
2107+ {
2108+ "metadata": {
2109+ "name": "text_file_example_1",
2110+ "status": "NotStarted",
2111+ "width": ["fsda" ,1],
2112+ "height" : ["dfsadfsdf"],
2113+ "is_pinned": "afdasdfadf",
2114+ "url": "https://sa-public-files.s3.us-west-2.amazonaws.com/Text+project/text_file_example_1.txt",
2115+ "projectId": 167826,
2116+ "annotatorEmail": null,
2117+ "qaEmail": null,
2118+ "lastAction": {
2119+ "email": "some.email@gmail.com",
2120+ "timestamp": 1636620976450
2121+ }
2122+ },
2123+ "instances": [],
2124+ "tags": [],
2125+ "freeText": ""
2126+ }
2127+ '''
2128+ )
2129+ with open (path , "r" ) as f :
2130+ data = json .loads (f .read ())
2131+ validator = AnnotationValidators .get_validator ("vector" )(data )
2132+ validator .is_valid ()
2133+ print (validator .generate_report ())
2134+ self .assertFalse (validator .is_valid ())
2135+ self .assertEqual (len (validator .generate_report ()), 155 )
2136+
2137+ def test_validate_vector_empty_annotation_bad_role (self ):
2138+ with tempfile .TemporaryDirectory () as tmpdir_name :
2139+ with open (f"{ tmpdir_name } /vector_empty.json" , "w" ) as vector_empty :
2140+ vector_empty .write (
2141+ '''
2142+ {
2143+ "metadata":{
2144+ "lastAction":{
2145+ "email":"test@test.com",
2146+ "timestamp":1641910273710
2147+ },
2148+ "width":480,
2149+ "height":270,
2150+ "name":"1 copy_001.jpg",
2151+ "projectId":181302,
2152+ "isPredicted":false,
2153+ "status":"Completed",
2154+ "pinned":false,
2155+ "annotatorEmail":null,
2156+ "qaEmail":null
2157+ },
2158+ "comments":[
2159+
2160+ ],
2161+ "tags":[
2162+
2163+ ],
2164+ "instances":[
2165+ {
2166+ "type":"rbbox",
2167+ "classId":901659,
2168+ "probability":100,
2169+ "points":{
2170+ "x1":213.57,
2171+ "y1":74.08,
2172+ "x2":275.65,
2173+ "y2":128.66,
2174+ "x3":238.51,
2175+ "y3":170.92,
2176+ "x4":176.43,
2177+ "y4":116.34
2178+ },
2179+ "groupId":0,
2180+ "pointLabels":{
2181+
2182+ },
2183+ "locked":false,
2184+ "visible":true,
2185+ "attributes":[
2186+
2187+ ],
2188+ "trackingId":null,
2189+ "error":null,
2190+ "createdAt":"2022-01-11T14:11:30.772Z",
2191+ "createdBy":{
2192+ "email":"test@test.com",
2193+ "role":"bad_role"
2194+ },
2195+ "creationType":"Manual",
2196+ "updatedAt":"2022-01-11T14:11:35.852Z",
2197+ "updatedBy":{
2198+ "email":"test@test.com",
2199+ "role":"Admin"
2200+ },
2201+ "className":"df"
2202+ }
2203+ ]
2204+ }
2205+ '''
2206+ )
2207+
2208+ with open (f"{ tmpdir_name } /vector_empty.json" , "r" ) as f :
2209+ data = json .loads (f .read ())
2210+ validator = AnnotationValidators .get_validator ("vector" )(data )
2211+ self .assertFalse (validator .is_valid ())
2212+ self .assertEqual (len (validator .generate_report ()), 113 )
0 commit comments