1- import src .superannotate as sa
21from unittest import TestCase
32
3+ import src .superannotate as sa
4+ from src .superannotate import AppException
5+
46
5- class TestSettings (TestCase ):
7+ class BaseTestCase (TestCase ):
68 PROJECT_NAME = "TestSettings"
79 SECOND_PROJECT_NAME = "SecondTestSettings"
810 PROJECT_DESCRIPTION = "TestSettings"
9- PROJECT_TYPE = "Vector"
1011
1112 def setUp (self ) -> None :
1213 self .tearDown ()
@@ -23,6 +24,12 @@ def tearDown(self) -> None:
2324 except Exception as e :
2425 print (str (e ))
2526
27+
28+ class TestSettings (BaseTestCase ):
29+ PROJECT_NAME = "TestSettings"
30+ SECOND_PROJECT_NAME = "SecondTestSettings"
31+ PROJECT_TYPE = "Vector"
32+
2633 def test_create_project_with_empty_settings (self ):
2734 sa .create_project (
2835 self .PROJECT_NAME ,
@@ -84,4 +91,62 @@ def test_clone_project(self):
8491 assert setting ["value" ] == "original"
8592 break
8693 else :
87- raise Exception ("Test failed" )
94+ raise Exception ("Test failed" )
95+
96+ def test_frame_rate_invalid_range_value (self ):
97+ with self .assertRaisesRegexp (AppException , "FrameRate is available only for Video projects" ):
98+ sa .create_project (
99+ self .PROJECT_NAME ,
100+ self .PROJECT_DESCRIPTION ,
101+ self .PROJECT_TYPE ,
102+ [{"attribute" : "FrameRate" , "value" : 1.0 }])
103+
104+
105+ class TestVideoSettings (BaseTestCase ):
106+ PROJECT_NAME = "TestVideoSettings"
107+ SECOND_PROJECT_NAME = "TestVideoSettings"
108+ PROJECT_TYPE = "Video"
109+
110+ def test_frame_rate (self ):
111+ sa .create_project (
112+ self .PROJECT_NAME ,
113+ self .PROJECT_DESCRIPTION ,
114+ self .PROJECT_TYPE ,
115+ [{"attribute" : "FrameRate" , "value" : 1 }])
116+ settings = sa .get_project_settings (self .SECOND_PROJECT_NAME )
117+ for setting in settings :
118+ if setting ["attribute" ] == "FrameRate" :
119+ assert setting ["value" ] == 1
120+ break
121+ else :
122+ raise Exception ("Test failed" )
123+
124+ def test_frame_rate_float (self ):
125+ sa .create_project (
126+ self .PROJECT_NAME ,
127+ self .PROJECT_DESCRIPTION ,
128+ self .PROJECT_TYPE ,
129+ [{"attribute" : "FrameRate" , "value" : 1.3 }])
130+ settings = sa .get_project_settings (self .SECOND_PROJECT_NAME )
131+ for setting in settings :
132+ if setting ["attribute" ] == "FrameRate" :
133+ assert setting ["value" ] == 1.3
134+ break
135+ else :
136+ raise Exception ("Test failed" )
137+
138+ def test_frame_rate_invalid_range_value (self ):
139+ with self .assertRaisesRegexp (AppException , "The FrameRate value range is between 0.001 - 120" ):
140+ sa .create_project (
141+ self .PROJECT_NAME ,
142+ self .PROJECT_DESCRIPTION ,
143+ self .PROJECT_TYPE ,
144+ [{"attribute" : "FrameRate" , "value" : 1.00003 }])
145+
146+ def test_frame_rate_invalid_str_value (self ):
147+ with self .assertRaisesRegexp (AppException , "The FrameRate value should be float" ):
148+ sa .create_project (
149+ self .PROJECT_NAME ,
150+ self .PROJECT_DESCRIPTION ,
151+ self .PROJECT_TYPE ,
152+ [{"attribute" : "FrameRate" , "value" : "1" }])
0 commit comments