def test_jqpc_simple_bar_chart_ok2(): """ Tests: test_jqpc_simple_bar_chart_ok2 """ print('::: TEST: test_jqpc_simple_bar_chart_ok2()') scripts_bar_chart_path = path_join(SCRIPT_PATH, 'scripts_bar_chart_test_jqpc_simple_bar_chart_ok2') if path_exists(scripts_bar_chart_path): shutil_rmtree(scripts_bar_chart_path) js_css_resources_header, jqplotchart_script, html_chart_insert_tag = jqpc_simple_bar_chart( absolute_source_dir_path=scripts_bar_chart_path, script_src_tag_dir_path=path_relpath(scripts_bar_chart_path), chart_id='example_id', class_str='whatever', chart_title='JqPyCharts simple_bar_chart', chart_x_label='', chart_x_label_fontdict=None, chart_ticks_fontdict=None, chart_data_matrix=[ ('Fat', 200, '#EAA228', ''), ('Protein', 21, '#4bb2c5', ''), ('Carbohydrate', 10, '#c5b47f', '') ], highlighter_prefix='Gram', background='#fffdf6', horizontal=False, draw_grid_lines=False, width_px=550, height_px=300, margin_top_px=0, margin_bottom_px=0, margin_right_px=0, margin_left_px=0) for resource_name in [ 'jquery.min.js', 'jquery.jqplot.min.js', 'jqplot.canvasAxisLabelRenderer.min.js', 'jqplot.categoryAxisRenderer.min.js', 'jqplot.canvasTextRenderer.min.js', 'jqplot.barRenderer.min.js', 'jqplot.pointLabels.min.js', 'jquery.jqplot.min.css']: resource_dir_path__abspath = path_join(scripts_bar_chart_path, resource_name) resource_dir_path__relpath = path_relpath(resource_dir_path__abspath) if resource_dir_path__abspath[-2:] == 'js': check_line = '<script type="text/javascript" src="{}"></script>'.format(resource_dir_path__relpath) ok_(check_line in js_css_resources_header, msg=None) elif resource_dir_path__abspath[-3:] == 'css': check_line = '<link rel="stylesheet" type="text/css" href="{}">'.format(resource_dir_path__relpath) ok_(check_line in js_css_resources_header, msg=None) else: raise Err('test_jqpc_simple_bar_chart_ok2', [ '`resource_name`: <{}> must end with <.js> or <.css>'.format(resource_name) ]) if path_exists(scripts_bar_chart_path): shutil_rmtree(scripts_bar_chart_path)
def test_jqpc_simple_bar_horizontal_chart_ok2(): """ Tests: test_jqpc_simple_bar_horizontal_chart_ok2 """ print('::: TEST: test_jqpc_simple_bar_horizontal_chart_ok2()') scripts_bar_chart_path = path_join(SCRIPT_PATH, 'scripts_bar_chart_test_jqpc_simple_bar_horizontal_chart_ok2') if path_exists(scripts_bar_chart_path): shutil_rmtree(scripts_bar_chart_path) js_css_resources_header, jqplotchart_script, html_chart_insert_tag = jqpc_simple_bar_chart( absolute_source_dir_path=scripts_bar_chart_path, script_src_tag_dir_path=path_relpath(scripts_bar_chart_path), chart_id='example_id', class_str='whatever', chart_title='JqPyCharts simple_bar_chart', chart_x_label='', chart_x_label_fontdict=None, chart_ticks_fontdict=None, chart_data_matrix=[ ('Fat', 200, '#EAA228', ''), ('Protein', 21, '#4bb2c5', ''), ('Carbohydrate', 10, '#c5b47f', '') ], highlighter_prefix='Gram', background='#fffdf6', horizontal=True, draw_grid_lines=False, width_px=550, height_px=300, margin_top_px=0, margin_bottom_px=0, margin_right_px=0, margin_left_px=0) for resource_name in [ 'jquery.min.js', 'jquery.jqplot.min.js', 'jqplot.canvasAxisLabelRenderer.min.js', 'jqplot.categoryAxisRenderer.min.js', 'jqplot.canvasTextRenderer.min.js', 'jqplot.barRenderer.min.js', 'jqplot.pointLabels.min.js', 'jquery.jqplot.min.css']: resource_dir_path__abspath = path_join(scripts_bar_chart_path, resource_name) resource_dir_path__relpath = path_relpath(resource_dir_path__abspath) if resource_dir_path__abspath[-2:] == 'js': check_line = '<script type="text/javascript" src="{}"></script>'.format(resource_dir_path__relpath) ok_(check_line in js_css_resources_header, msg=None) elif resource_dir_path__abspath[-3:] == 'css': check_line = '<link rel="stylesheet" type="text/css" href="{}">'.format(resource_dir_path__relpath) ok_(check_line in js_css_resources_header, msg=None) else: raise Err('test_jqpc_simple_bar_horizontal_chart_ok2', [ '`resource_name`: <{}> must end with <.js> or <.css>'.format(resource_name) ]) if path_exists(scripts_bar_chart_path): shutil_rmtree(scripts_bar_chart_path)
def test_jqpc_simple_pie_chart__expect_failure1(): """ Tests: test_jqpc_simple_pie_chart__expect_failure1: chart_id with spaces """ print('::: TEST: test_jqpc_simple_pie_chart__expect_failure1()') scripts_pie_chart_path = path_join( SCRIPT_PATH, 'scripts_pie_chart_test_jqpc_simple_pie_chart__expect_failure1') if path_exists(scripts_pie_chart_path): shutil_rmtree(scripts_pie_chart_path) js_css_resources_header, jqplotchart_script, html_chart_insert_tag = jqpc_simple_pie_chart( absolute_source_dir_path=scripts_pie_chart_path, script_src_tag_dir_path=path_relpath(scripts_pie_chart_path), chart_id='example_id wrong can not have spaces', class_str='', chart_title='JqPyCharts simple_pie_chart', chart_data_matrix=[('Fat', 200, '#EAA228', 'Fat: 200 g'), ('Protein', 21, '#4bb2c5', None), ('Carbohydrate', 10, '#c5b47f', 'Carbohydrate: 10 g')], highlighter_prefix='', background='#fffdf6', legend_font_px=15, data_label_threshold=9.0, width_px=480, height_px=300, margin_top_px=0, margin_bottom_px=0, margin_right_px=0, margin_left_px=0) for resource_name in [ 'jquery.min.js', 'jquery.jqplot.min.js', 'jqplot.highlighter.min.js', 'jqplot.canvasTextRenderer.min.js', 'jqplot.pieRenderer.min.js', 'jquery.jqplot.min.css' ]: resource_dir_path__abspath = path_join(scripts_pie_chart_path, resource_name) resource_dir_path__relpath = path_relpath(resource_dir_path__abspath) if resource_dir_path__abspath[-2:] == 'js': check_line = '<script type="text/javascript" src="{}"></script>'.format( resource_dir_path__relpath) ok_(check_line in js_css_resources_header, msg=None) elif resource_dir_path__abspath[-3:] == 'css': check_line = '<link rel="stylesheet" type="text/css" href="{}">'.format( resource_dir_path__relpath) ok_(check_line in js_css_resources_header, msg=None) else: raise Err('test_jqpc_simple_pie_chart__expect_failure1', [ '`resource_name`: <{}> must end with <.js> or <.css>'.format( resource_name) ]) if path_exists(scripts_pie_chart_path): shutil_rmtree(scripts_pie_chart_path)
def relpath(): args = argv[1:] if 0 == len(args): usage() exit(1) for a in args: print path_relpath(a, ".") return 0
def do_vcs_install(manifest_in, versionfile_source_, ipy): # noinspection PyPep8Naming GITS = ['git'] files = [manifest_in, versionfile_source_, ipy] try: me = __file__ if me.endswith('.pyc') or me.endswith('.pyo'): me = path_splitext(me)[0] + '.py' versioneer_file = path_relpath(me) except NameError: versioneer_file = 'versioneer.py' files.append(versioneer_file) present = False try: f = open('.gitattributes', 'r') for line in f.readlines(): if line.strip().startswith(versionfile_source_): if 'export-subst' in line.strip().split()[1:]: present = True f.close() except EnvironmentError: pass if not present: f = open('.gitattributes', 'a+') f.write('{} export-subst\n'.format(versionfile_source_)) f.close() files.append('.gitattributes') run_command(GITS, ['add', '--'] + files)
def test_jqpc_simple_bar_chart__not_absolute_source_path_expect_failure(): """ Tests: test_jqpc_simple_bar_chart__not_absolute_source_path_expect_failure: """ print( '::: TEST: test_jqpc_simple_bar_chart__not_absolute_source_path_expect_failure()' ) scripts_bar_chart_path = 'scripts_pie_chart_test_jqpc_simple_bar_chart__not_absolute_source_path_expect_failure' if path_exists(scripts_bar_chart_path): shutil_rmtree(scripts_bar_chart_path) js_css_resources_header, jqplotchart_script, html_chart_insert_tag = jqpc_simple_bar_chart( absolute_source_dir_path=scripts_bar_chart_path, script_src_tag_dir_path=path_relpath(scripts_bar_chart_path), chart_id='example_id', class_str='', chart_title='JqPyCharts simple_bar_chart', chart_x_label={ 'fontFamily': 'Helvetica', 'fontSize': 14, 'textColor': '#000000' }, chart_x_label_fontdict=None, chart_ticks_fontdict={ 'fontFamily': 'Courier New', 'fontSize': 12, 'textColor': '#000000' }, chart_data_matrix=[('Fat', 200, '#EAA228', '200 g (57.7 %)'), ('Protein', 21, '#4bb2c5', '21 g (21.3 %)'), ('Carbohydrate', 10, '#c5b47f', '10 g (24.0 %)')], highlighter_prefix='Gram', background='#fffdf6', horizontal=False, draw_grid_lines=False, width_px=550, height_px=300, margin_top_px=0, margin_bottom_px=0, margin_right_px=0, margin_left_px=0) if path_exists(scripts_bar_chart_path): shutil_rmtree(scripts_bar_chart_path)
def test_jqpc_get_html_js_css_resources__expect_failure1(): """ Tests: test_jqpc_get_html_js_css_resources__expect_failure1 """ print('::: TEST: test_jqpc_get_html_js_css_resources__expect_failure1()') source_scripts_path = path_join(SCRIPT_PATH, 'source_scripts') # make sure we have the needed resources jqpc_write__resource_dict('jqplot_scripts', source_scripts_path, force=False) needed_resources = [ 'jquery.min.js', 'jquery.jqplot.min.css', 'wrong_resource_name', ] out_js_css_resources = jqpc_get_html_js_css_resources( needed_resources, source_scripts_path, path_relpath(source_scripts_path), indent=' ' )
def test_jqpc_get_html_js_css_resources__expect_failure1(): """ Tests: test_jqpc_get_html_js_css_resources__expect_failure1 """ print('::: TEST: test_jqpc_get_html_js_css_resources__expect_failure1()') source_scripts_path = path_join(SCRIPT_PATH, 'source_scripts') # make sure we have the needed resources jqpc_write__resource_dict('jqplot_scripts', source_scripts_path, force=False) needed_resources = [ 'jquery.min.js', 'jquery.jqplot.min.css', 'wrong_resource_name', ] out_js_css_resources = jqpc_get_html_js_css_resources( needed_resources, source_scripts_path, path_relpath(source_scripts_path), indent=' ')
def test_jqpc_simple_bar_chart__not_absolute_source_path_expect_failure(): """ Tests: test_jqpc_simple_bar_chart__not_absolute_source_path_expect_failure: """ print('::: TEST: test_jqpc_simple_bar_chart__not_absolute_source_path_expect_failure()') scripts_bar_chart_path = 'scripts_pie_chart_test_jqpc_simple_bar_chart__not_absolute_source_path_expect_failure' if path_exists(scripts_bar_chart_path): shutil_rmtree(scripts_bar_chart_path) js_css_resources_header, jqplotchart_script, html_chart_insert_tag = jqpc_simple_bar_chart( absolute_source_dir_path=scripts_bar_chart_path, script_src_tag_dir_path=path_relpath(scripts_bar_chart_path), chart_id='example_id', class_str='', chart_title='JqPyCharts simple_bar_chart', chart_x_label={'fontFamily': 'Helvetica', 'fontSize': 14, 'textColor': '#000000'}, chart_x_label_fontdict=None, chart_ticks_fontdict={'fontFamily': 'Courier New', 'fontSize': 12, 'textColor': '#000000'}, chart_data_matrix=[ ('Fat', 200, '#EAA228', '200 g (57.7 %)'), ('Protein', 21, '#4bb2c5', '21 g (21.3 %)'), ('Carbohydrate', 10, '#c5b47f', '10 g (24.0 %)') ], highlighter_prefix='Gram', background='#fffdf6', horizontal=False, draw_grid_lines=False, width_px=550, height_px=300, margin_top_px=0, margin_bottom_px=0, margin_right_px=0, margin_left_px=0) if path_exists(scripts_bar_chart_path): shutil_rmtree(scripts_bar_chart_path)