示例#1
0
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)
示例#2
0
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
示例#3
0
    def __init__(self, products):
        container = ProductsContainer(products)

        self.products = container
        self.metadata = MetadataCollection(container)
        self.clients = ClientContainer(container)

        self._repr = Repr()
示例#4
0
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()
示例#5
0
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
示例#6
0
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