Пример #1
0
def test_simple_metadata_with_spaces(
    text='python string = "value" number = 1.0 array = ["a",  "b"]',
    value=("python", {"string": "value", "number": 1.0, "array": ["a", "b"]}),
):
    compare(text_to_metadata(text), value)
    assert (
        metadata_to_text(*value) == 'python string="value" number=1.0 array=["a", "b"]'
    )
Пример #2
0
def test_title_and_json_dict(
    text='cell title {"string": "value", "number": 1.0, "array": ["a", "b"]}',
    value=("cell title", {"string": "value", "number": 1.0, "array": ["a", "b"]}),
):
    compare(text_to_metadata(text, allow_title=True), value)
    assert (
        metadata_to_text(*value)
        == 'cell title string="value" number=1.0 array=["a", "b"]'
    )
Пример #3
0
def test_title_and_relax_json(
    text="cell title string='value' number=1.0 array=['a', \"b\"]",
    value=("cell title", {"string": "value", "number": 1.0, "array": ["a", "b"]}),
):
    compare(text_to_metadata(text, allow_title=True), value)
    assert (
        metadata_to_text(*value)
        == 'cell title string="value" number=1.0 array=["a", "b"]'
    )
Пример #4
0
def test_simple_metadata(
    text='python string="value" number=1.0 array=["a", "b"]',
    value=('python', {
        'string': 'value',
        'number': 1.0,
        'array': ['a', 'b']
    })):
    compare(text_to_metadata(text), value)
    assert metadata_to_text(*value) == text
Пример #5
0
def test_title_and_json_dict(
    text='cell title {"string": "value", "number": 1.0, "array": ["a", "b"]}',
    value=('cell title', {
        'string': 'value',
        'number': 1.0,
        'array': ['a', 'b']
    })):
    compare(text_to_metadata(text, allow_title=True), value)
    assert metadata_to_text(
        *value) == 'cell title string="value" number=1.0 array=["a", "b"]'
Пример #6
0
def test_title_and_relax_json(
    text="cell title string='value' number=1.0 array=['a', \"b\"]",
    value=('cell title', {
        'string': 'value',
        'number': 1.0,
        'array': ['a', 'b']
    })):
    compare(text_to_metadata(text, allow_title=True), value)
    assert metadata_to_text(
        *value) == 'cell title string="value" number=1.0 array=["a", "b"]'
Пример #7
0
def test_language_and_attribute(text="python .class",
                                value=("python", {
                                    ".class": None
                                })):
    compare(text_to_metadata(text), value)
    assert metadata_to_text(*value) == text
Пример #8
0
def test_attribute(allow_title):
    text = ".class"
    value = ("", {".class": None})
    compare(text_to_metadata(text, allow_title), value)
    assert metadata_to_text(*value) == text
Пример #9
0
def test_title_no_metadata(text="title", value=("title", {})):
    compare(text_to_metadata(text, allow_title=True), value)
    assert metadata_to_text(*value) == text.strip()
Пример #10
0
def test_language_metadata_no_space(text='python{"a":1}',
                                    value=("python", {
                                        "a": 1
                                    })):
    compare(text_to_metadata(text), value)
    assert metadata_to_text(*value) == "python a=1"
Пример #11
0
def test_no_language(text=".class", value=("", {".class": None})):
    compare(text_to_metadata(text), value)
    assert metadata_to_text(*value) == text
Пример #12
0
def test_no_language(text='.class', value=('', {'.class': None})):
    compare(text_to_metadata(text), value)
    assert metadata_to_text(*value) == text
Пример #13
0
def test_incorrectly_encoded(text="this is an incorrect expression d={{4 b=3"):
    value = text_to_metadata(text, allow_title=True)
    assert metadata_to_text(*value) == text
Пример #14
0
def test_values_with_equal_signs_inside(text='python string="value=5"',
                                        value=('python', {
                                            'string': 'value=5'
                                        })):
    compare(text_to_metadata(text), value)
    assert metadata_to_text(*value) == text
Пример #15
0
def test_title_and_attribute(text="This is my title. .class",
                             value=("This is my title.", {
                                 ".class": None
                             })):
    compare(text_to_metadata(text, allow_title=True), value)
    assert metadata_to_text(*value) == text
Пример #16
0
def test_language_no_metadata(text="python", value=("python", {})):
    compare(text_to_metadata(text), value)
    assert metadata_to_text(*value) == text.strip()
Пример #17
0
def test_values_with_equal_signs_inside(text='python string="value=5"',
                                        value=("python", {
                                            "string": "value=5"
                                        })):
    compare(text_to_metadata(text), value)
    assert metadata_to_text(*value) == text
Пример #18
0
def test_only_metadata_2(text='key="value"', value=("", {"key": "value"})):
    compare(text_to_metadata(text, allow_title=True), value)
    assert metadata_to_text(*value) == text
Пример #19
0
def test_incorrectly_encoded_json(
        text='this is an incorrect expression {"d": "}'):
    value = text_to_metadata(text, allow_title=True)
    assert metadata_to_text(*value) == text
Пример #20
0
def test_only_metadata_2(text='key="value"', value=('', {'key': 'value'})):
    compare(text_to_metadata(text, allow_title=True), value)
    assert metadata_to_text(*value) == text