示例#1
0
def test_metadata_generation(tag_parsing_notebook):
    result = [{
        'block_names': ['imports'],
        'in': [],
        'out': []
    }, {
        'block_names': ['sum'],
        'in': [],
        'out': []
    }, {
        'block_names': ['cumsum'],
        'in': [],
        'out': [],
        'previous_blocks': ['sum']
    }, {
        'block_names': [],
        'in': [],
        'out': []
    }, {
        'block_names': ['imports'],
        'in': [],
        'out': []
    }, {
        'block_names': ['os'],
        'in': [],
        'out': [],
        'previous_blocks': ['sum', 'cumsum']
    }]

    parsed_tags = list()
    for c in tag_parsing_notebook.cells:
        # parse only source code cells
        if c.cell_type != "code":
            continue

        tags = Kale.parse_metadata(c.metadata)
        parsed_tags.append(tags)
    pairs = zip(result, parsed_tags)
    assert all(x == y for x, y in pairs)
示例#2
0
def test_tag_block_error():
    tag = {'metadata': {'tags': ["block:processing:dataset"]}}

    with pytest.raises(ValueError):
        Kale.parse_metadata(tag['metadata'])
示例#3
0
def test_tag_block():
    tag = {'metadata': {'tags': ["block:processing"]}}
    target = {'block_names': ["processing"], 'in': [], 'out': []}

    res = Kale.parse_metadata(tag['metadata'])
    assert target == res
示例#4
0
def test_tag_skip():
    tag = {'metadata': {'tags': ['skip']}}
    target = None

    res = Kale.parse_metadata(tag['metadata'])
    assert target == res
示例#5
0
def test_empty_tag():
    tag = {'metadata': {}}
    target = {'block_names': [], 'in': [], 'out': []}

    res = Kale.parse_metadata(tag['metadata'])
    assert target == res