class_docstr: Tests ensuring that when a dataset or samples in a dataset are modified,
  those changes are passed on the the database and can be seen in different
  scopes (or processes!).
class_docstr_tok: ["Tests","ensuring","that","when","a","dataset","or","samples","in","a","dataset","are","modified",",","those","changes","are","passed","on","the","the","database","and","can","be","seen","in","different","scopes","(","or","processes","!",")","."]
code: def test_dataset(self):
      dataset_name = self.test_dataset.__name__
  
      # Test Create
  
      def create_dataset():
          with self.assertRaises(ValueError):
              dataset = fo.load_dataset(dataset_name)
  
          dataset = fo.Dataset(dataset_name)
  
      create_dataset()
  
      def check_create_dataset():
          fo.load_dataset(dataset_name)
  
      def check_create_dataset_via_load():
          self.assertIn(dataset_name, fo.list_datasets())
          dataset = fo.load_dataset(dataset_name)
  
      check_create_dataset()
      check_create_dataset_via_load()
  
      # Test Delete Default Field
  
      def delete_default_field():
          dataset = fo.load_dataset(dataset_name)
          with self.assertRaises(ValueError):
              dataset.delete_sample_field("tags")
  
      delete_default_field()
  
      # Test Add New Field
  
      field_name = "test_field"
      ftype = fo.IntField
  
      def add_field():
          dataset = fo.load_dataset(dataset_name)
          dataset.add_sample_field(field_name, ftype)
  
      def check_add_field():
          dataset = fo.load_dataset(dataset_name)
          fields = dataset.get_field_schema()
          self.assertIn(field_name, fields)
          self.assertIsInstance(fields[field_name], ftype)
  
      add_field()
      check_add_field()
  
      # Test Delete Field
  
      def delete_field():
          dataset = fo.load_dataset(dataset_name)
          dataset.delete_sample_field(field_name)
  
      def check_delete_field():
          dataset = fo.load_dataset(dataset_name)
          fields = dataset.get_field_schema()
          with self.assertRaises(KeyError):
              fields[field_name]
  
          # this is checking backend implementation. if it changes this may
          # be N/A
          sample_fields = dataset._doc.sample_fields
          sample_field_names = [sf.name for sf in sample_fields]
          self.assertNotIn(field_name, sample_field_names)
  
      delete_field()
      check_delete_field()
  
      # Test Delete Dataset
  
      def delete_dataset():
          fo.delete_dataset(dataset_name)
  
      delete_dataset()
  
      def check_delete_dataset():
          with self.assertRaises(ValueError):
              fo.load_dataset(dataset_name)
  
      check_delete_dataset()
  
file_path: fiftyone/tests/unittests/synchronization_tests.py
imports: import os
  import unittest
  import fiftyone
  from decorators import drop_datasets
label_desc: Use image node_id 1 for calling the ScopedObjectsSynchronizationTests obj's underlying member method code with example usage: obj.test_dataset() without return types