class BaseDataStoreTestCase(TestCase):
    def setUp(self):
        self.store = BaseDataStore()
        self.store._record_annotation = Mock()
        self.store._record_binary_annotation = Mock()

    def test_record_noop_if_not_sampled(self):
        self.store.get = lambda: ZipkinData(sampled=False)
        self.store._record_annotation = Mock()
        self.store._record_binary_annotation = Mock()
        self.store.record(Mock())
        self.assertFalse(self.store._record_annotation.called)
        self.assertFalse(self.store._record_binary_annotation.called)

    def test_record_delegates_if_sampled(self):
        self.store.get = lambda: ZipkinData(sampled=True)
        annotation = Mock(spec=Annotation)
        binary_annotation = Mock(spec=BinaryAnnotation)
        self.store.record(annotation)
        self.store.record(binary_annotation)
        self.store._record_annotation.assert_called_once_with(annotation)
        self.store._record_binary_annotation.assert_called_once_with(binary_annotation)
class BaseDataStoreTestCase(TestCase):
    def setUp(self):
        self.store = BaseDataStore()
        self.store._record_annotation = Mock()
        self.store._record_binary_annotation = Mock()

    def test_record_noop_if_not_sampled(self):
        self.store.get = lambda: ZipkinData(sampled=False)
        self.store._record_annotation = Mock()
        self.store._record_binary_annotation = Mock()
        self.store.record(Mock())
        self.assertFalse(self.store._record_annotation.called)
        self.assertFalse(self.store._record_binary_annotation.called)

    def test_record_delegates_if_sampled(self):
        self.store.get = lambda: ZipkinData(sampled=True)
        annotation = Mock(spec=Annotation)
        binary_annotation = Mock(spec=BinaryAnnotation)
        self.store.record(annotation)
        self.store.record(binary_annotation)
        self.store._record_annotation.assert_called_once_with(annotation)
        self.store._record_binary_annotation.assert_called_once_with(
            binary_annotation)
 def setUp(self):
     self.store = BaseDataStore()
     self.store._record_annotation = Mock()
     self.store._record_binary_annotation = Mock()
 def setUp(self):
     self.store = BaseDataStore()
     self.store._record_annotation = Mock()
     self.store._record_binary_annotation = Mock()