def test_metadata_collection_update_locally_forwards_to_all_products(): p1 = Mock() p2 = Mock() arg = Mock() m = MetadataCollection([p1, p2]) m.update_locally(arg) p1.metadata.update_locally.assert_called_once_with(arg) p2.metadata.update_locally.assert_called_once_with(arg)
def test_metadata_collection_to_dict(d1, d2, expected, should_warn): p1, p2 = Mock(), Mock() p1.metadata = FakeMetadata(**d1) p2.metadata = FakeMetadata(**d2) m = MetadataCollection([p1, p2]) m = MetadataCollection([p1, p2]) with pytest.warns(None) as record: d = m.to_dict() assert bool(record) is should_warn assert d == expected
def __init__(self, products): container = ProductsContainer(products) self.products = container self.metadata = MetadataCollection(container) self.clients = ClientContainer(container) self._repr = Repr()
def test_metadata_collection_forwards_calls_to_all_products(method): p1 = Mock() p2 = Mock() m = MetadataCollection([p1, p2]) getattr(m, method)() getattr(p1.metadata, method).assert_called_once() getattr(p1.metadata, method).assert_called_once()
def test_metadata_collection_stored_source_code(c1, c2, expected, should_warn): p1 = Mock() p1.metadata.stored_source_code = c1 p2 = Mock() p2.metadata.stored_source_code = c2 m = MetadataCollection([p1, p2]) with pytest.warns(None) as record: code = m.stored_source_code assert bool(record) is should_warn assert code == expected
def test_metadata_collection_timestamp(t1, t2, expected, should_warn): p1 = Mock() p1.metadata.timestamp = t1 p2 = Mock() p2.metadata.timestamp = t2 m = MetadataCollection([p1, p2]) with pytest.warns(None) as record: ts = m.timestamp assert bool(record) is should_warn assert ts == expected