Changeset 451bb19 in flex_extract.git


Ignore:
Timestamp:
Aug 31, 2018, 4:12:03 PM (9 months ago)
Author:
Anne Philipp <anne.philipp@…>
Branches:
dev
Children:
763fcf6
Parents:
2ad8ea5
Message:

added fail and success test for the submit_job_to_ecserver function

Location:
python
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/pythontest/TestTools.py

    r2ad8ea5 r451bb19  
    1010import _config
    1111from tools import (init128, to_param_id, my_error, read_ecenv,
    12                    get_cmdline_arguments)
     12                   get_cmdline_arguments, submit_job_to_ecserver)
    1313
    1414
     
    7777            assert par in [130, 134, 142, 146]
    7878
    79     def test_error_notifcation(self):
     79    def test_my_error(self):
    8080        '''
    8181        '''
     
    109109        assert True
    110110
    111 
    112111    def test_get_list_as_string(self):
    113112        assert True
     
    118117    def test_put_file_to_ecserver(self):
    119118        assert True
     119        #assert subprocess.call(['ssh', host, 'test -e ' + pipes.quote(path)]) == 0
    120120
    121     def submit_job_to_ecserver(self):
    122         assert True
     121    def test_fail_submit_job_to_ecserver(self):
     122        with pytest.raises(SystemExit) as pytest_wrapped_e:
     123            submit_job_to_ecserver('${HOME}', 'ecgate', 'job.ksh')
     124        assert pytest_wrapped_e.type == SystemExit
     125        assert pytest_wrapped_e.value.code == '... ECACCESS-JOB-SUBMIT FAILED!'
     126
     127    def test_success_submit_job_to_ecserver(self):
     128
     129        result = submit_job_to_ecserver('TestData/testfile.txt',
     130                                        'ecgate', 'TestData/testfile.txt')
     131        assert result == 0
     132
     133
    123134
    124135if __name__ == "__main__":
  • python/tools.py

    r54a8a01 r451bb19  
    500500
    501501    @Return:
    502         <nothing>
     502        rcode: integer
     503            Resulting code of subprocess.check_call.
    503504    '''
    504505
    505506    try:
    506         subprocess.check_call(['ecaccess-job-submit',
    507                                '-queueName', target,
    508                                jobname])
     507        rcode = subprocess.check_call(['ecaccess-job-submit',
     508                                       '-queueName', target,
     509                                       jobname])
    509510    except subprocess.CalledProcessError as e:
    510511        print '... ERROR CODE: ', e.returncode
    511512        sys.exit('... ECACCESS-JOB-SUBMIT FAILED!')
    512513
    513     return
     514    return rcode
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG