-
Notifications
You must be signed in to change notification settings - Fork 47
/
test_ggplot.py
29 lines (24 loc) · 1.12 KB
/
test_ggplot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#
# Copyright (c) 2019. JetBrains s.r.o.
# Use of this source code is governed by the MIT license that can be found in the LICENSE file.
#
import pytest
import lets_plot as gg
data = {'a': [1, 2], 'b': [3, 4]}
mapping_empty = gg.aes()
mapping_x = gg.aes('X')
result_empty = {'kind': 'plot', 'mapping': {}, 'data_meta': {}, 'layers': [], 'scales': []}
result_data = {'data': data, 'kind': 'plot', 'mapping': {}, 'data_meta': {}, 'layers': [], 'scales': []}
result_data_mapping_empty = {'data': data, 'kind': 'plot', 'mapping': {}, 'data_meta': {}, 'layers': [], 'scales': []}
result_data_mapping_x = {'data': data, 'mapping': {'x': 'X'}, 'data_meta': {}, 'kind': 'plot', 'layers': [], 'scales': []}
result_mapping_x = {'mapping': {'x': 'X'}, 'data_meta': {}, 'kind': 'plot', 'layers': [], 'scales': []}
@pytest.mark.parametrize('args,expected', [
([], result_empty),
([data], result_data),
([data, mapping_empty], result_data_mapping_empty),
([data, mapping_x], result_data_mapping_x),
([None, mapping_x], result_mapping_x),
])
def test_ggplot(args, expected):
spec = gg.ggplot(*args)
assert spec.as_dict() == expected