def test_get_all_jobs():
    js = JobSession('js-01')
    j_name = 'drmaa2python-%s' % int(random.uniform(0, 1000))
    j = js.run_job({
        'remote_command': '/bin/sleep',
        'args': ['10'],
        'job_name': j_name
    })
    print('\nSubmitted job: %s' % j)
    ji = j.get_info()
    j.wait_started()
    ms = MonitoringSession('ms-01')
    print('Opened monitoring session: %s' % ms.name)
    ji2 = JobInfo({'job_id': ji.job_id})
    print('Retrieving jobs matching job info %s' % ji2)
    j_list = ms.get_all_jobs(ji2)
    print('Got all jobs: %s' % j_list)
    assert (len(j_list) >= 1)
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
# See the License for the specific language governing permissions and
# limitations under the License.
#######################################################################################
# ___INFO__MARK_END__

import random
from drmaa2 import JobSession
from drmaa2 import JobInfo
from drmaa2 import MonitoringSession

if __name__ == '__main__':
    js = JobSession('js-01')
    print('Created job session: %s' % js.name)
    j_name = 'job-%s' % int(random.uniform(0, 1000))
    j = js.run_job({
        'remote_command': '/bin/sleep',
        'args': ['10'],
        'job_name': j_name
    })
    print('Submitted job: %s' % j)
    # ji = j.get_info()
    ji = JobInfo({'job_name': j_name})
    ms = MonitoringSession('ms-01')
    print('Opened monitoring session: %s' % ms.name)
    print('Retrieving jobs matching job info %s' % ji)
    j_list = ms.get_all_jobs(ji)
    print('Got all jobs: %s' % j_list)