def _test_history_table_job_order(self):
        in_progress_job2 = JobFactory.create(user=self.user, status=Job.IN_PROGRESS)
        held_job2 = JobFactory.create(user=self.user, status=Job.HELD, description='2nd held job (should appear first in list)')
        in_progress_job3 = JobFactory.create(user=self.user, status=Job.IN_PROGRESS)
        in_progress_job4 = JobFactory.create(user=self.user, status=Job.IN_PROGRESS, description='most recent in progress job (should appear before other in_progress jobs)')
        self.visit('job_index')

        expected_jobs = [held_job2, self.held_job, self.submitted_job, self.queued_job, in_progress_job4, in_progress_job3, in_progress_job2, self.in_progress_job, self.completed_job, self.error_job2, self.error_job]
        self.assert_job_table_equals(expected_jobs)
    def setUp(self):
        super(DiskStorageTests, self).setUp()

        username = '******'
        password = '******'

        self.user = UserFactory.create(username=username, is_superuser=True)
        self.user.set_password(password)
        self.user.save()
        self.login(username, password)

        output_path = 'job_output'
        self.job = JobFactory.create(user=self.user, status=Job.COMPLETED, output_path=output_path)
        file_content = 'abc' * 2000000
        file_name_to_content = {'file_name': file_content}
        helper.create_file(os.path.join(settings.FILES_BASE, output_path), 'file_name', file_name_to_content)
        self.job.save()

        self.simulation = SimulationFactory.create()
        self.galaxy = GalaxyModelFactory.create()
        self.dataset = DataSetFactory.create(simulation=self.simulation, galaxy_model=self.galaxy)
        self.output_prop = DataSetPropertyFactory.create(dataset=self.dataset, name='Central op', is_filter=False)
        self.filter = DataSetPropertyFactory.create(name='CentralMvir rf', units="Msun/h", dataset=self.dataset)
        self.computed_filter = DataSetPropertyFactory.create(name='Computed Property', dataset=self.dataset, is_computed=True)
        self.snapshot = SnapshotFactory.create(dataset=self.dataset, redshift='0.33')
        self.survey_preset = SurveyPresetFactory.create(name='Preset 1', parameters='<xml></xml>')

        self.default_disk_quota = GlobalParameterFactory.create(parameter_name='default_disk_quota', parameter_value='6')
    def setUp(self):
        super(ListJobsTests, self).setUp()

        username = "******"
        password = "******"
        self.user = UserFactory.create(username=username, password=password)
        self.user.save()
        self.login(username, password)

        parameters = """<lightcone>
                        <database_type>sqlite</database_type>
                        <database_name>random.db</database_name>
                        <catalogue_geometry>cone</catalogue_geometry>
                        </lightcone>
                    """
        error_message = ['blah blah', 'wah wah', 'lah lah']

        self.held_job = JobFactory.create(user=self.user, parameters=parameters, status=Job.HELD)
        self.error_job = JobFactory.create(user=self.user, parameters=parameters, status=Job.ERROR, error_message=error_message[0])
        self.in_progress_job = JobFactory.create(user=self.user, parameters=parameters, status=Job.IN_PROGRESS)
        self.submitted_job = JobFactory.create(user=self.user, parameters=parameters, status=Job.SUBMITTED)
        self.completed_job = JobFactory.create(user=self.user, parameters=parameters, status=Job.COMPLETED)
        self.queued_job = JobFactory.create(user=self.user, parameters=parameters, status=Job.QUEUED)
        self.error_job2 = JobFactory.create(user=self.user, parameters=parameters, status=Job.ERROR, error_message=error_message[1])

        self.visit('job_index')
示例#4
0
 def test_handle_bad_xml(self):
     bad_params = str.replace(self.job.parameters, '</record-filter>','</record-filter><skymaker id="6"><images><item><format>PNG</format></item></images></skymaker>')
     self.completed_job = JobFactory.create(user=self.user, status=Job.COMPLETED, output_path=self.output_paths[0], parameters=bad_params)
     self.login(self.username, self.password)
     self.visit('view_job', id=self.completed_job.id)
     self.assert_page_has_content('mock_image missing parameter')
     self.click('id_error_report_ok')
     self.click('id-job_output_delete')
     self.click('id_confirm_delete_output')
     self.assert_on_page('job_index')
示例#5
0
    def setUp(self):
        super(JobTest, self).setUp()
        
        self.username = '******'
        self.password = '******'

        self.user = UserFactory.create(username=self.username, is_superuser=True)
        self.user.set_password(self.password)
        self.user.save()

        # self.job_description = 'This is a job description'
        self.job = JobFactory.create(user=self.user)
        GlobalParameterFactory.create(parameter_name='maximum-random-light-cones', parameter_value='10000')

        self.simulation = SimulationFactory.create()
        self.galaxy = GalaxyModelFactory.create()
        self.dataset = DataSetFactory.create(simulation=self.simulation, galaxy_model=self.galaxy)
        self.output_prop = DataSetPropertyFactory.create(dataset=self.dataset, name='Central op', is_filter=False)
        self.filter = DataSetPropertyFactory.create(name='CentralMvir rf', units="Msun/h", dataset=self.dataset)
        self.computed_filter = DataSetPropertyFactory.create(name='Computed Property', dataset=self.dataset, is_computed=True)
        self.sed = StellarModelFactory.create()
        self.dust = DustModelFactory.create()
        self.snapshot = SnapshotFactory.create(dataset=self.dataset, redshift='0.33')
        self.band_pass_filters = [BandPassFilterFactory.create(), BandPassFilterFactory.create()]

        self.output_paths = ['job1', 'large_job']
        self.dir_paths = [os.path.join(settings.FILES_BASE, output_path) for output_path in self.output_paths]
        txt_template = loader.get_template('jobs/light_cone_job-summary.txt')
        summary_context = Context(self.make_parameters())
        self.summary_text = txt_template.render(summary_context)
        self.file_names_to_contents = {
                                       'file1': 'abc\n',
                                       'filez2.txt': 'pqr\n',
                                       'file3': 'xyz\n',
                                       'job2/fileA.html': 'aaaahhhh & aaaaa',
                                       'job2/fileB': 'baaaaaa',
                                       'summary.txt': self.summary_text,
                                       }
        self.file_names_to_contents2 = {
                                       'waybigfile1': 'xnfaihnehrawlrwerajelrjxmjaeimrjwmrejlxaljrxm;kjmrlakjemrajlejrljrljaereirje;rjmriarie;rirjijeaim;jea;ljmxirjwra;ojer',
                                       'waybigfile2': 'xnfaihnehrawlrwerajelrjxmjaeimrjwmrejlxaljrxm;kjmrlakjemrajlejrljrljaereirje;rjmriarie;rirjijeaim;jea;ljmxirjwra;ojer',
                                       'waybigfile3': 'xnfaihnehrawlrwerajelrjxmjaeimrjwmrejlxaljrxm;kjmrlakjemrajlejrljrljaereirje;rjmriarie;rirjijeaim;jea;ljmxirjwra;ojer',
                                       'waybigfile4': 'xnfaihnehrawlrwerajelrjxmjaeimrjwmrejlxaljrxm;kjmrlakjemrajlejrljrljaereirje;rjmriarie;rirjijeaim;jea;ljmxirjwra;ojer',
                                       'waybigfile5': 'xnfaihnehrawlrwerajelrjxmjaeimrjwmrejlxaljrxm;kjmrlakjemrajlejrljrljaereirje;rjmriarie;rirjijeaim;jea;ljmxirjwra;ojer',
                                       }
        for file_name in self.file_names_to_contents.keys():
            helper.create_file(self.dir_paths[0], file_name, self.file_names_to_contents)
        for file_name in self.file_names_to_contents2.keys():
            helper.create_file(self.dir_paths[1], file_name, self.file_names_to_contents2)
        parameters = self.make_xml_parameters()
        self.job.parameters = parameters
        self.job.save()
        self.completed_job = JobFactory.create(user=self.user, status=Job.COMPLETED, output_path=self.output_paths[0], parameters=parameters)
        self.held_job = JobFactory.create(user=self.user, parameters=parameters, status=Job.HELD)
        self.error_job = JobFactory.create(user=self.user, parameters=parameters, status=Job.ERROR, error_message="error")
        self.in_progress_job = JobFactory.create(user=self.user, parameters=parameters, status=Job.IN_PROGRESS)
        self.submitted_job = JobFactory.create(user=self.user, parameters=parameters, status=Job.SUBMITTED)
        self.queued_job = JobFactory.create(user=self.user, parameters=parameters, status=Job.QUEUED)
    def setUp(self):
        super(JobApiTest, self).setUp()

        self.client = Client()
        self.client.defaults = {'REMOTE_ADDR': '123.2.3.4'}

        user = UserFactory.create()
        self.job = JobFactory.create(user=user, status='HELD')

        self.url_all_job = reverse('api_dispatch_list', kwargs={'resource_name': 'job', 'api_name': 'v1'})
        self.url_by_job_id = reverse('api_dispatch_detail', kwargs={'resource_name': 'job', 'api_name': 'v1', 'pk': self.job.id})
        self.url_by_status = self.url_all_job + '?status=HELD'
        self.data = {'format': 'json'}
示例#7
0
    def test_anonymous_user_cannot_view_or_download(self):
        completed_job = JobFactory.create(user=self.user, status=Job.COMPLETED, output_path=self.output_paths[0])
        self.visit('view_job', completed_job.id)
        
        self.assert_on_page('login', ignore_query_string=True)
        
        first_filename = self.file_names_to_contents.keys()[0]

        self.visit('get_file', completed_job.id, first_filename) 
        
        self.assert_on_page('login', ignore_query_string=True)
        
        download_path = os.path.join(self.DOWNLOAD_DIRECTORY, first_filename)
        self.assertFalse(os.path.exists(download_path))
    def setUp(self):
        super(WorkflowApiTest, self).setUp()

        self.client = Client()
        self.client.defaults = {'REMOTE_ADDR': '123.2.3.4'}

        user = UserFactory.create()
        self.job = JobFactory.create(user=user)
        self.wfcommand = WorkflowCommandFactory.create(job_id=self.job, submitted_by=user, execution_status='QUEUED')

        self.url_all_wfcommand = reverse('api_dispatch_list', kwargs={'resource_name': 'workflowcommand', 'api_name': 'v1'})
        # print self.url_all_wfcommand
        self.url_by_wf_id = reverse('api_dispatch_detail', kwargs={'resource_name': 'workflowcommand', 'api_name': 'v1', 'pk': self.wfcommand.id})
        # self.url_by_job_id = reverse('api_dipatch_detail', kwargs={'resource_name': 'workflowcommand', 'api_name': 'v1'}, job_id = job.id)
        # print self.url_by_job_id
        self.data = {'format': 'json'}
示例#9
0
    def test_other_user_cannot_view_or_download(self):
        username = '******'
        password = '******'

        user2 = UserFactory.create(username=username)
        user2.set_password(password)
        user2.save()
                
        completed_job = JobFactory.create(user=self.user, status=Job.COMPLETED, output_path=self.output_paths[0])
        
        helper.create_file(self.dir_paths[0], 'file1', self.file_names_to_contents)
        
        self.login(username, password)
        self.visit('view_job', completed_job.id)
        self.assert_page_has_content('Forbidden')
        
        self.visit('get_file', completed_job.id, 'file1')
        self.assert_page_has_content('Forbidden')
        
        download_path = os.path.join(self.DOWNLOAD_DIRECTORY, 'file1')
        self.assertFalse(os.path.exists(download_path))
 def setUp(self):
     super(WorkflowCommandsTests, self).setUp()
     user = UserFactory.create()
     job = JobFactory.create(user=user)
     self.jobID = job.id
     self.wfcommand = WorkflowCommandFactory.create(submitted_by=user, job_id=job, execution_comment='')
 def test_description_displayed_in_listing(self):
     job = JobFactory.create(user=self.user)
     self.wait(1)
     self.visit('job_index')
     self.assert_page_has_content(job.description)