<s> """<STR_LIT>""" <EOL> from cafe . drivers . unittest . decorators import tags <EOL> from cloudcafe . images . common . types import TaskTypes <EOL> from cloudroast . images . fixtures import ImagesFixture <EOL> class TestGetTasks ( ImagesFixture ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> super ( TestGetTasks , cls ) . setUpClass ( ) <EOL> cls . tasks = cls . images_behavior . create_new_tasks ( count = <NUM_LIT:2> ) <EOL> @ tags ( type = '<STR_LIT>' ) <EOL> def test_get_tasks ( self ) : <EOL> """<STR_LIT>""" <EOL> response = self . images_client . list_tasks ( ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> get_tasks = response . entity <EOL> self . assertNotEqual ( len ( get_tasks ) , <NUM_LIT:0> ) <EOL> [ self . _validate_listed_task ( task ) for task in get_tasks ] <EOL> @ tags ( type = '<STR_LIT>' , regression = '<STR_LIT:true>' ) <EOL> def test_get_tasks_pagination ( self ) : <EOL> """<STR_LIT>""" <EOL> count = <NUM_LIT:2> <EOL> created_tasks = [ ] <EOL> first_task = self . tasks . pop ( ) <EOL> second_task = self . tasks . pop ( ) <EOL> get_tasks = self . images_behavior . list_tasks_pagination ( ) <EOL> self . assertNotEqual ( len ( get_tasks ) , <NUM_LIT:0> ) <EOL> for task in get_tasks : <EOL> self . _validate_listed_task ( task ) <EOL> if ( task . id_ == first_task . id_ or task . id_ == second_task . id_ ) : <EOL> created_tasks . append ( task ) <EOL> self . assertEqual ( len ( created_tasks ) , count ) <EOL> @ tags ( type = '<STR_LIT>' , regression = '<STR_LIT:true>' ) <EOL> def test_get_tasks_filter_type ( self ) : <EOL> """<STR_LIT>""" <EOL> get_tasks = self . images_behavior . list_tasks_pagination ( <EOL> type_ = TaskTypes . IMPORT ) <EOL> self . assertNotEqual ( len ( get_tasks ) , <NUM_LIT:0> ) <EOL> for task in get_tasks : <EOL> self . assertEqual ( task . owner , self . tenant_id ) <EOL> self . assertEqual ( task . type_ , TaskTypes . IMPORT ) <EOL> def _validate_listed_task ( self , task ) : <EOL> """<STR_LIT>""" <EOL> errors = [ ] <EOL> if task . input_ is not None : <EOL> errors . append ( self . error_msg . format ( '<STR_LIT:input>' , '<STR_LIT:None>' , task . input_ ) ) <EOL> if task . result is not None : <EOL> errors . append ( self . error_msg . format ( '<STR_LIT:result>' , '<STR_LIT:None>' , task . result ) ) <EOL> if task . owner != self . tenant_id : <EOL> errors . append ( self . error_msg . format ( <EOL> '<STR_LIT>' , self . tenant_id , task . owner ) ) <EOL> self . assertListEqual ( errors , [ ] ) </s>
