def test_annotations(self): annotations = [Mock(spec=Annotation), Mock(spec=Annotation)] binary_annotations = [Mock(spec=BinaryAnnotation), Mock(spec=BinaryAnnotation)] store = ThreadLocalDataStore() store.clear() store.set(ZipkinData(sampled=True)) for annotation in annotations + binary_annotations: store.record(annotation) self.assertListEqual(annotations, store.get_annotations()) self.assertListEqual(binary_annotations, store.get_binary_annotations())
def test_clear(self): annotations = [Mock(spec=Annotation), Mock(spec=Annotation)] binary_annotations = [Mock(spec=BinaryAnnotation), Mock(spec=BinaryAnnotation)] store = ThreadLocalDataStore() store.set(ZipkinData(sampled=True, trace_id=Mock())) store.set_rpc_name(Mock()) for annotation in annotations + binary_annotations: store.record(annotation) store.clear() self.assertListEqual([], store.get_annotations()) self.assertListEqual([], store.get_binary_annotations()) self.assertZipkinDataEquals(ZipkinData(), store.get()) self.assertIsNone(store.get_rpc_name())
def test_annotations(self): annotations = [Mock(spec=Annotation), Mock(spec=Annotation)] binary_annotations = [ Mock(spec=BinaryAnnotation), Mock(spec=BinaryAnnotation) ] store = ThreadLocalDataStore() store.clear() store.set(ZipkinData(sampled=True)) for annotation in annotations + binary_annotations: store.record(annotation) self.assertListEqual(annotations, store.get_annotations()) self.assertListEqual(binary_annotations, store.get_binary_annotations())
def test_clear(self): annotations = [Mock(spec=Annotation), Mock(spec=Annotation)] binary_annotations = [ Mock(spec=BinaryAnnotation), Mock(spec=BinaryAnnotation) ] store = ThreadLocalDataStore() store.set(ZipkinData(sampled=True, trace_id=Mock())) store.set_rpc_name(Mock()) for annotation in annotations + binary_annotations: store.record(annotation) store.clear() self.assertListEqual([], store.get_annotations()) self.assertListEqual([], store.get_binary_annotations()) self.assertZipkinDataEquals(ZipkinData(), store.get()) self.assertIsNone(store.get_rpc_name())