|
22 | 22 | # api_key for account: '786r5mecv0' |
23 | 23 |
|
24 | 24 |
|
25 | | -def compare_with_raw(obj, raw_obj, parents=None): |
26 | | - if isinstance(obj, dict): |
27 | | - for key in raw_obj: |
28 | | - if key not in obj: |
29 | | - if not is_trivial(raw_obj[key]): |
30 | | - msg = "" |
31 | | - if parents is not None: |
32 | | - msg += "->".join(parents) + "->" |
33 | | - msg += key + " not in obj\n" |
34 | | - print(msg) |
35 | | - elif isinstance(raw_obj[key], (dict, list)) and len(raw_obj[key]): |
36 | | - if parents is None: |
37 | | - compare_with_raw(obj[key], |
38 | | - raw_obj[key], |
39 | | - parents=[key]) |
40 | | - else: |
41 | | - compare_with_raw(obj[key], |
42 | | - raw_obj[key], |
43 | | - parents=parents + [key]) |
44 | | - |
45 | | - else: |
46 | | - if raw_obj[key] != obj[key]: |
47 | | - msg = "" |
48 | | - if parents is not None: |
49 | | - msg += "->".join(parents) + "->" |
50 | | - msg += key + " not equal!\n" |
51 | | - msg += " raw: {0} != obj: {1}\n".format(raw_obj[key], |
52 | | - obj[key]) |
53 | | - print(msg) |
54 | | - elif isinstance(obj, list): |
55 | | - for entry, entry_raw in zip(obj, raw_obj): |
56 | | - if isinstance(entry, (dict, list)): |
57 | | - try: |
58 | | - coll_name = ( |
59 | | - graph_objs.NAME_TO_KEY[entry.__class__.__name__] |
60 | | - ) |
61 | | - except KeyError: |
62 | | - coll_name = entry.__class__.__name__ |
63 | | - if parents is None: |
64 | | - compare_with_raw(entry, |
65 | | - entry_raw, |
66 | | - parents=[coll_name]) |
67 | | - else: |
68 | | - compare_with_raw(entry, |
69 | | - entry_raw, |
70 | | - parents=parents + [coll_name]) |
71 | | - else: |
72 | | - if entry != entry_raw: |
73 | | - msg = "" |
74 | | - if parents is not None: |
75 | | - msg += "->".join(parents) + "->" |
76 | | - msg += "->[]->\n" |
77 | | - msg += " obj: {0} != raw_obj: {1}\n".format(entry, |
78 | | - entry_raw) |
79 | | - print(msg) |
80 | | - |
81 | | - |
82 | 25 | def is_trivial(obj): |
83 | 26 | if isinstance(obj, (dict, list)): |
84 | 27 | if len(obj): |
@@ -166,45 +109,6 @@ def test_get_figure_raw(): |
166 | 109 | fig = py.get_figure('PlotlyImageTest', str(file_id), raw=True) |
167 | 110 |
|
168 | 111 |
|
169 | | -@attr('slow') |
170 | | -def test_all(): |
171 | | - un = 'PlotlyImageTest' |
172 | | - ak = '786r5mecv0' |
173 | | - run_test = False |
174 | | - end_file = 2 |
175 | | - polar_plots = [], # [6, 7, 8] |
176 | | - skip = list(range(0)) |
177 | | - if run_test: |
178 | | - py.sign_in(un, ak) |
179 | | - file_id = 0 |
180 | | - while True: |
181 | | - fig, fig_raw = None, None |
182 | | - while (file_id in polar_plots) or (file_id in skip): |
183 | | - print(" skipping: https://plot.ly/~{0}/{1}".format( |
184 | | - un, file_id)) |
185 | | - file_id += 1 |
186 | | - print("\n") |
187 | | - try: |
188 | | - print("testing: https://plot.ly/~{0}/{1}".format(un, file_id)) |
189 | | - print("###########################################\n\n") |
190 | | - fig = py.get_figure('PlotlyImageTest', str(file_id)) |
191 | | - fig_raw = py.get_figure('PlotlyImageTest', |
192 | | - str(file_id), |
193 | | - raw=True) |
194 | | - except exceptions.PlotlyError: |
195 | | - pass |
196 | | - if (fig is None) and (fig_raw is None): |
197 | | - print(" couldn't find: https://plot.ly/{0}/{1}".format( |
198 | | - un, file_id)) |
199 | | - else: |
200 | | - compare_with_raw(fig, fig_raw, parents=['figure']) |
201 | | - file_id += 1 |
202 | | - if file_id > end_file: |
203 | | - break |
204 | | - raise exceptions.PlotlyError("This error was generated so that the " |
205 | | - "following output is produced...") |
206 | | - |
207 | | - |
208 | 112 | @attr('slow') |
209 | 113 | class TestBytesVStrings(TestCase): |
210 | 114 |
|
|
0 commit comments