Пример #1
0
def test_valid_data():
    c = Cell(int, 1)
    assert c.value == 1
    assert c.type == int

    c = Cell(str, 'a')
    assert c.value == 'a'
    assert c.type == str
Пример #2
0
def test_valid_data():
    c = Cell(int, 1)
    assert c.value == 1
    assert c.type == int

    c = Cell(str, 'a')
    assert c.value == 'a'
    assert c.type == str

    longnumber = sys.maxsize + 1
    c = Cell(long, longnumber)
    assert c.value == longnumber
    assert c.type == long
Пример #3
0
def test_dictionary_interface():
    c = Cell(int, 1, "Number", {'foo': 'bar'})
    expected = dict(v=1, f="Number", p={'foo': 'bar'})
    assert dict(c) == expected
Пример #4
0
def test_options():
    c = Cell(int, 1)
    c.options = dict(foo='bar')
    assert c.options == {'foo': 'bar'}
Пример #5
0
def test_invalid_options():
    c = Cell(int, 1)
    with pytest.raises(ValueError):
        c.options = 1
    with pytest.raises(ValueError):
        c.options = [1, 2, 3]
Пример #6
0
def test_label():
    c = Cell(int, 1)
    assert c.label is None
    c = Cell(int, 1, "Birthday")
    assert c.label == "Birthday"
Пример #7
0
def test_invalid_data():
    c = Cell(int, 1)
    with pytest.raises(ValueError):
        c.validate("a")
Пример #8
0
def test_empty_cell():
    c = Cell(int, None)
    assert c.value is None
Пример #9
0
def test_options():
    c = Cell(int, 1)
    c.options = dict(foo='bar')
    assert c.options == {'foo':'bar'}
Пример #10
0
def test_invalid_options():
    c = Cell(int, 1)
    with pytest.raises(ValueError):
        c.options = 1
    with pytest.raises(ValueError):
        c.options = [1, 2, 3]
Пример #11
0
def test_invalid_data():
    c = Cell(int, 1)
    with pytest.raises(ValueError):
        c.validate("a")
Пример #12
0
def test_encode_cell():
    from gviz_data_table.cell import Cell
    c = Cell(int, 1)
    js = encode(c)
    python = json.loads(js)
    assert python == {"v": 1}