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_add_sample_expand_schema(self):
      dataset_name = self.test_add_sample_expand_schema.__name__
  
      def create_dataset():
          dataset = fo.Dataset(dataset_name)
  
      create_dataset()
  
      # add sample with custom field
  
      def add_sample_expand_schema():
          dataset = fo.load_dataset(dataset_name)
          sample = fo.Sample(filepath="test.png", test_field=True)
          return dataset.add_sample(sample)
  
      def check_add_sample_expand_schema(sample_id):
          dataset = fo.load_dataset(dataset_name)
  
          fields = dataset.get_field_schema()
          self.assertIn("test_field", fields)
          self.assertIsInstance(fields["test_field"], fo.BooleanField)
  
          sample = dataset[sample_id]
          self.assertEqual(sample["test_field"], True)
  
      sample_id = add_sample_expand_schema()
      check_add_sample_expand_schema(sample_id)
  
      # add multiple samples with custom fields
  
      def add_samples_expand_schema():
          dataset = fo.load_dataset(dataset_name)
          sample1 = fo.Sample(filepath="test1.png", test_field_1=51)
          sample2 = fo.Sample(
              filepath="test2.png", test_field_2="fiftyone"
          )
          return dataset.add_samples([sample1, sample2])
  
      def check_add_samples_expand_schema(sample_ids):
          dataset = fo.load_dataset(dataset_name)
  
          fields = dataset.get_field_schema()
          self.assertIn("test_field_1", fields)
          self.assertIsInstance(fields["test_field_1"], fo.IntField)
          self.assertIn("test_field_2", fields)
          self.assertIsInstance(fields["test_field_2"], fo.StringField)
  
          sample1 = dataset[sample_ids[0]]
          self.assertEqual(sample1["test_field_1"], 51)
  
          sample2 = dataset[sample_ids[1]]
          self.assertEqual(sample2["test_field_2"], "fiftyone")
  
      sample_ids = add_samples_expand_schema()
      check_add_samples_expand_schema(sample_ids)
  
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 3 for calling the ScopedObjectsSynchronizationTests obj's underlying member method code with example usage: obj.test_add_sample_expand_schema() and returns: dataset, dataset