Exemplo n.º 1
0
    def test_update_metadata_with_cloud_dataset(self):
        """Test the `update_metadata` method with a cloud dataset."""
        dataset_path = self._create_nested_cloud_dataset()
        dataset = Dataset(path=dataset_path)

        # Update the instance metadata but don't update the cloud stored metadata.
        dataset.tags["hello"] = "world"

        # Check the instance metadata hasn't been stored in the cloud.
        self.assertEqual(Dataset(path=dataset.path).tags, {})

        # Update the cloud stored metadata and check it.
        dataset.update_metadata()
        self.assertEqual(Dataset(path=dataset.path).tags, {"hello": "world"})
Exemplo n.º 2
0
    def test_update_metadata_with_local_dataset(self):
        """Test the `update_metadata` method with a local dataset."""
        with tempfile.TemporaryDirectory() as temporary_directory:
            dataset = Dataset(path=temporary_directory)

            # Update the instance metadata but don't update the local stored metadata.
            dataset.tags["hello"] = "world"

            # Check the instance metadata hasn't been stored locally.
            self.assertEqual(Dataset(path=temporary_directory).tags, {})

            # Update the local stored metadata and check it.
            dataset.update_metadata()
            self.assertEqual(
                Dataset(path=temporary_directory).tags, {"hello": "world"})