# Copyright 2022 DeepMind Technologies Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# 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.

"""Tests for dm_nevis.benchmarker.datasets.builders.tfds_builder."""


from absl.testing import absltest
from absl.testing import parameterized
from dm_nevis.benchmarker.datasets.builders import tfds_builder
import tensorflow_datasets as tfds


class TFDSBuilderTest(parameterized.TestCase):

  # We can include any dataset that has a fixture writer.
  @parameterized.parameters(tfds_builder.SUPPORTED_DATASETS)
  def test_build_dataset(self, dataset_name):
    with tfds.testing.mock_data(num_examples=10):
      dataset = tfds_builder.get_dataset(dataset_name, split="train")
      ds = dataset.builder_fn(shuffle=False, end=10)
      self.assertLen(list(ds), 10)


if __name__ == "__main__":
  absltest.main()
