"""
This script creates a test that fails when
metarl.tf.baselines failed to initialize.
"""
import tensorflow as tf

from metarl.envs import MetaRLEnv
from metarl.tf.baselines import ContinuousMLPBaseline
from metarl.tf.baselines import GaussianMLPBaseline
from tests.fixtures import TfGraphTestCase
from tests.fixtures.envs.dummy import DummyBoxEnv


class TestTfBaselines(TfGraphTestCase):

    def test_baseline(self):
        """Test the baseline initialization."""
        box_env = MetaRLEnv(DummyBoxEnv())
        deterministic_mlp_baseline = ContinuousMLPBaseline(env_spec=box_env)
        gaussian_mlp_baseline = GaussianMLPBaseline(env_spec=box_env)

        self.sess.run(tf.compat.v1.global_variables_initializer())
        deterministic_mlp_baseline.get_param_values()
        gaussian_mlp_baseline.get_param_values()

        box_env.close()

[(19, 'metarl.tf.baselines.ContinuousMLPBaseline', 'ContinuousMLPBaseline', False, 'from metarl.tf.baselines import ContinuousMLPBaseline\n'), (20, 'metarl.tf.baselines.GaussianMLPBaseline', 'GaussianMLPBaseline', False, 'from metarl.tf.baselines import GaussianMLPBaseline\n'), (18, 'tests.fixtures.envs.dummy.DummyBoxEnv', 'DummyBoxEnv', False, 'from tests.fixtures.envs.dummy import DummyBoxEnv\n'), (22, 'tensorflow.compat.v1.global_variables_initializer', 'tf.compat.v1.global_variables_initializer', True, 'import tensorflow as tf\n')]