Beispiel #1
0
def test_load_entities_fail_invalid_json_unknown_entity(use_testdb):
    pd = PonyDump(testdb)

    with pytest.raises(ValueError) as excinfo:
        for _ in pd.load_entities(io.StringIO('{"_entity": "wat"}')):
            pass

    assert str(excinfo.value) == 'Unknown entity "wat" on line 1'
Beispiel #2
0
def test_load_entities_fail_invalid_json_nonstr_entity(use_testdb):
    pd = PonyDump(testdb)

    with pytest.raises(ValueError) as excinfo:
        for _ in pd.load_entities(io.StringIO('{"_entity": 7}')):
            pass

    assert str(excinfo.value) == 'Invalid dump format on line 1'
Beispiel #3
0
def test_load_entities_fail_invalid_json_syntax(use_testdb):
    pd = PonyDump(testdb)

    with pytest.raises(ValueError) as excinfo:
        for _ in pd.load_entities(io.StringIO('}')):
            pass

    assert str(excinfo.value).startswith('Invalid JSON on line 1: ')
def test_load_entities_fail_invalid_json_unknown_entity(use_testdb):
    pd = PonyDump(testdb)

    with pytest.raises(ValueError) as excinfo:
        for _ in pd.load_entities(io.StringIO('{"_entity": "wat"}')):
            pass

    assert str(excinfo.value) =='Unknown entity "wat" on line 1'
def test_load_entities_fail_invalid_json_nonstr_entity(use_testdb):
    pd = PonyDump(testdb)

    with pytest.raises(ValueError) as excinfo:
        for _ in pd.load_entities(io.StringIO('{"_entity": 7}')):
            pass

    assert str(excinfo.value) =='Invalid dump format on line 1'
def test_load_entities_fail_invalid_json_syntax(use_testdb):
    pd = PonyDump(testdb)

    with pytest.raises(ValueError) as excinfo:
        for _ in pd.load_entities(io.StringIO('}')):
            pass

    assert str(excinfo.value).startswith('Invalid JSON on line 1: ')