# Path: rl_teacher/tests/video_render_test.py
# TEST_RENDER_DIR = '/tmp/rl_teacher_media_test'
# 
# Path: rl_teacher/video.py
# def upload_to_gcs(local_path, gcs_path):
#     assert osp.isfile(local_path), "%s must be a file" % local_path
#     assert gcs_path.startswith("gs://"), "%s must start with gs://" % gcs_path
# 
#     print("Copying media to %s in a background process" % gcs_path)
#     subprocess.check_call(['gsutil', 'cp', local_path, gcs_path])


import os
import os.path as osp
from rl_teacher.tests.video_render_test import TEST_RENDER_DIR
from rl_teacher.video import upload_to_gcs


def test_upload():
    bucket = os.environ.get('RL_TEACHER_GCS_BUCKET')
    assert bucket and bucket.startswith("gs://"), "env variable RL_TEACHER_GCS_BUCKET must be set and start with gs://"

    gcs_path = 'test_obs_75.mp4'
    dest_path = osp.join(bucket, gcs_path)

# Path: rl_teacher/tests/video_render_test.py
# TEST_RENDER_DIR = '/tmp/rl_teacher_media_test'
# 
# Path: rl_teacher/video.py
# def upload_to_gcs(local_path, gcs_path):
#     assert osp.isfile(local_path), "%s must be a file" % local_path
#     assert gcs_path.startswith("gs://"), "%s must start with gs://" % gcs_path
# 
#     print("Copying media to %s in a background process" % gcs_path)
#     subprocess.check_call(['gsutil', 'cp', local_path, gcs_path])


# Path: rl_teacher/tests/video_upload_test.py
import os
import os.path as osp
from rl_teacher.tests.video_render_test import TEST_RENDER_DIR
from rl_teacher.video import upload_to_gcs



def test_upload():
    bucket = os.environ.get('RL_TEACHER_GCS_BUCKET')
    assert bucket and bucket.startswith("gs://"), "env variable RL_TEACHER_GCS_BUCKET must be set and start with gs://"

    gcs_path = 'test_obs_75.mp4'
    dest_path = osp.join(bucket, gcs_path)

    upload_to_gcs(osp.join(TEST_RENDER_DIR, 'test-0.mp4'), dest_path)