def test_event_logger_from_an_offline_run(self):
    settings.CLIENT_CONFIG.is_managed = False
    settings.CLIENT_CONFIG.is_offline = True
    os.environ[POLYAXON_KEYS_COLLECT_ARTIFACTS] = 'false'
    os.environ[POLYAXON_KEYS_COLLECT_RESOURCES] = 'false'
    with patch('polyaxon.tracking.run.Run._set_exit_handler') as exit_mock:
        run = Run(project='test.test', run_uuid='uid')
    assert (exit_mock.call_count == 1)
    artifacts_path = CONTEXT_OFFLINE_FORMAT.format('uid')
    assert (run.get_artifacts_path() == artifacts_path)
    assert (run.get_outputs_path() == CONTEXTS_OUTPUTS_SUBPATH_FORMAT.format(artifacts_path))
    assert (run._event_logger is None)
    os.environ[POLYAXON_KEYS_COLLECT_ARTIFACTS] = 'true'
    os.environ[POLYAXON_KEYS_COLLECT_RESOURCES] = 'true'
    with patch('polyaxon.tracking.run.Run.set_run_event_logger') as event_call:
        with patch('polyaxon.tracking.run.Run.set_run_resource_logger') as resource_call:
            with patch('polyaxon.tracking.run.Run._set_exit_handler') as exit_mock:
                Run(project='test.test', run_uuid='uid')
    assert (exit_mock.call_count == 1)
    assert (event_call.call_count == 1)
    assert (resource_call.call_count == 1)
def test_event_logger_from_an_offline_run(self):
    settings.CLIENT_CONFIG.is_managed = False
    settings.CLIENT_CONFIG.is_offline = True
    os.environ[POLYAXON_KEYS_COLLECT_ARTIFACTS] = 'false'
    os.environ[POLYAXON_KEYS_COLLECT_RESOURCES] = 'false'
    with patch('polyaxon.tracking.run.Run._set_exit_handler') as exit_mock:
        run = Run(project='test.test', run_uuid='uid')
    assert (exit_mock.call_count == 1)
    artifacts_path = CONTEXT_OFFLINE_FORMAT.format('uid')
    assert (run.get_artifacts_path() == artifacts_path)
    assert (run.get_outputs_path() == CONTEXTS_OUTPUTS_SUBPATH_FORMAT.format(artifacts_path))
    assert (run._event_logger is None)
    os.environ[POLYAXON_KEYS_COLLECT_ARTIFACTS] = 'true'
    os.environ[POLYAXON_KEYS_COLLECT_RESOURCES] = 'true'
    with patch('polyaxon.tracking.run.Run.set_run_event_logger') as event_call:
        with patch('polyaxon.tracking.run.Run.set_run_resource_logger') as resource_call:
            with patch('polyaxon.tracking.run.Run._set_exit_handler') as exit_mock:
                Run(project='test.test', run_uuid='uid')
    assert (exit_mock.call_count == 1)
    assert (event_call.call_count == 1)
    assert (resource_call.call_count == 1)