<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import , print_function <EOL> import pytest <EOL> from pptx . chart . series import ( <EOL> BarSeries , _BaseSeries , LineSeries , PieSeries , SeriesCollection , <EOL> _SeriesFactory <EOL> ) <EOL> from pptx . dml . fill import FillFormat <EOL> from pptx . dml . line import LineFormat <EOL> from . . unitutil . cxml import element , xml <EOL> from . . unitutil . mock import class_mock , function_mock , instance_mock <EOL> class Describe_BaseSeries ( object ) : <EOL> def it_knows_its_name ( self , name_fixture ) : <EOL> series , expected_value = name_fixture <EOL> assert series . name == expected_value <EOL> def it_knows_its_position_in_the_series_sequence ( self , index_fixture ) : <EOL> series , expected_value = index_fixture <EOL> assert series . index == expected_value <EOL> def it_knows_its_values ( self , values_get_fixture ) : <EOL> series , expected_value = values_get_fixture <EOL> assert series . values == expected_value <EOL> @ pytest . fixture <EOL> def index_fixture ( self ) : <EOL> ser_cxml , expected_value = '<STR_LIT>' , <NUM_LIT> <EOL> series = _BaseSeries ( element ( ser_cxml ) ) <EOL> return series , expected_value <EOL> @ pytest . fixture ( params = [ <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] ) <EOL> def name_fixture ( self , request ) : <EOL> ser_cxml , expected_value = request . param <EOL> series = _BaseSeries ( element ( ser_cxml ) ) <EOL> return series , expected_value <EOL> @ pytest . fixture ( params = [ <EOL> ( '<STR_LIT>' , ( ) ) , <EOL> ( '<STR_LIT>' , ( ) ) , <EOL> ( '<STR_LIT>' , ( ) ) , <EOL> ( '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ) , <EOL> ( '<STR_LIT>' , ( ) ) , <EOL> ( '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ) , <EOL> ] ) <EOL> def values_get_fixture ( self , request ) : <EOL> ser_cxml , expected_value = request . param <EOL> series = _BaseSeries ( element ( ser_cxml ) ) <EOL> return series , expected_value <EOL> class DescribeBarSeries ( object ) : <EOL> def it_provides_access_to_the_series_fill_format ( self , fill_fixture ) : <EOL> bar_series , FillFormat_ , spPr , fill_ = fill_fixture <EOL> fill = bar_series . fill <EOL> FillFormat_ . from_fill_parent . assert_called_once_with ( spPr ) <EOL> assert fill is fill_ <EOL> def it_provides_access_to_the_series_line_format ( self , line_fixture ) : <EOL> bar_series , LineFormat_ , line_ = line_fixture <EOL> line = bar_series . line <EOL> LineFormat_ . assert_called_once_with ( bar_series ) <EOL> assert line is line_ <EOL> def it_can_get_the_width_of_its_line ( self , line_width_get_fixture ) : <EOL> """<STR_LIT>""" <EOL> bar_series , expected_width = line_width_get_fixture <EOL> assert bar_series . line . width == expected_width <EOL> def it_can_change_the_width_of_its_line ( self , line_width_set_fixture ) : <EOL> """<STR_LIT>""" <EOL> bar_series , width , expected_xml = line_width_set_fixture <EOL> bar_series . line . width = width <EOL> assert bar_series . _element . xml == expected_xml <EOL> def it_knows_whether_it_should_invert_if_negative ( <EOL> self , invert_if_negative_get_fixture ) : <EOL> bar_series , expected_value = invert_if_negative_get_fixture <EOL> assert bar_series . invert_if_negative == expected_value <EOL> def it_can_change_whether_it_inverts_if_negative ( <EOL> self , invert_if_negative_set_fixture ) : <EOL> bar_series , new_value , expected_xml = invert_if_negative_set_fixture <EOL> bar_series . invert_if_negative = new_value <EOL> assert bar_series . _element . xml == expected_xml <EOL> @ pytest . fixture <EOL> def fill_fixture ( self , FillFormat_ , fill_ ) : <EOL> ser = element ( '<STR_LIT>' ) <EOL> spPr = ser . spPr <EOL> bar_series = BarSeries ( ser ) <EOL> return bar_series , FillFormat_ , spPr , fill_ <EOL> @ pytest . fixture ( params = [ <EOL> ( '<STR_LIT>' , True ) , <EOL> ( '<STR_LIT>' , True ) , <EOL> ( '<STR_LIT>' , True ) , <EOL> ( '<STR_LIT>' , False ) , <EOL> ] ) <EOL> def invert_if_negative_get_fixture ( self , request ) : <EOL> ser_cxml , expected_value = request . param <EOL> bar_series = BarSeries ( element ( ser_cxml ) ) <EOL> return bar_series , expected_value <EOL> @ pytest . fixture ( params = [ <EOL> ( '<STR_LIT>' , True , <EOL> '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , False , <EOL> '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , True , <EOL> '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , False , <EOL> '<STR_LIT>' ) , <EOL> ] ) <EOL> def invert_if_negative_set_fixture ( self , request ) : <EOL> ser_cxml , new_value , expected_ser_cxml = request . param <EOL> bar_series = BarSeries ( element ( ser_cxml ) ) <EOL> expected_xml = xml ( expected_ser_cxml ) <EOL> return bar_series , new_value , expected_xml <EOL> @ pytest . fixture <EOL> def line_fixture ( self , LineFormat_ , line_ ) : <EOL> bar_series = BarSeries ( element ( '<STR_LIT>' ) ) <EOL> return bar_series , LineFormat_ , line_ <EOL> @ pytest . fixture ( params = [ <EOL> ( '<STR_LIT>' , <NUM_LIT:0> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT:0> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT> ) , <EOL> ] ) <EOL> def line_width_get_fixture ( self , request ) : <EOL> ser_cxml , expected_width = request . param <EOL> bar_series = BarSeries ( element ( ser_cxml ) ) <EOL> return bar_series , expected_width <EOL> @ pytest . fixture <EOL> def line_width_set_fixture ( self ) : <EOL> ser_cxml = '<STR_LIT>' <EOL> bar_series = BarSeries ( element ( ser_cxml ) ) <EOL> width = <NUM_LIT> <EOL> expected_xml = xml ( '<STR_LIT>' ) <EOL> return bar_series , width , expected_xml <EOL> @ pytest . fixture <EOL> def FillFormat_ ( self , request , fill_ ) : <EOL> FillFormat_ = class_mock ( request , '<STR_LIT>' ) <EOL> FillFormat_ . from_fill_parent . return_value = fill_ <EOL> return FillFormat_ <EOL> @ pytest . fixture <EOL> def fill_ ( self , request ) : <EOL> return instance_mock ( request , FillFormat ) <EOL> @ pytest . fixture <EOL> def LineFormat_ ( self , request , line_ ) : <EOL> return class_mock ( <EOL> request , '<STR_LIT>' , return_value = line_ <EOL> ) <EOL> @ pytest . fixture <EOL> def line_ ( self , request ) : <EOL> return instance_mock ( request , LineFormat ) <EOL> class DescribeLineSeries ( object ) : <EOL> def it_knows_whether_it_should_use_curve_smoothing ( <EOL> self , smooth_get_fixture ) : <EOL> series , expected_value = smooth_get_fixture <EOL> assert series . smooth == expected_value <EOL> def it_can_change_whether_it_uses_curve_smoothing ( <EOL> self , smooth_set_fixture ) : <EOL> series , new_value , expected_xml = smooth_set_fixture <EOL> series . smooth = new_value <EOL> assert series . _element . xml == expected_xml <EOL> @ pytest . fixture ( params = [ <EOL> ( '<STR_LIT>' , True ) , <EOL> ( '<STR_LIT>' , True ) , <EOL> ( '<STR_LIT>' , True ) , <EOL> ( '<STR_LIT>' , False ) , <EOL> ] ) <EOL> def smooth_get_fixture ( self , request ) : <EOL> ser_cxml , expected_value = request . param <EOL> series = LineSeries ( element ( ser_cxml ) ) <EOL> return series , expected_value <EOL> @ pytest . fixture ( params = [ <EOL> ( '<STR_LIT>' , True , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , False , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , True , '<STR_LIT>' ) , <EOL> ] ) <EOL> def smooth_set_fixture ( self , request ) : <EOL> ser_cxml , new_value , expected_ser_cxml = request . param <EOL> series = LineSeries ( element ( ser_cxml ) ) <EOL> expected_xml = xml ( expected_ser_cxml ) <EOL> return series , new_value , expected_xml <EOL> class DescribeSeriesCollection ( object ) : <EOL> def it_supports_indexed_access ( self , getitem_fixture ) : <EOL> series_collection , idx , _SeriesFactory_ , ser , series_ = ( <EOL> getitem_fixture <EOL> ) <EOL> series = series_collection [ idx ] <EOL> _SeriesFactory_ . assert_called_once_with ( ser ) <EOL> assert series is series_ <EOL> def it_supports_len ( self , len_fixture ) : <EOL> series_collection , expected_len = len_fixture <EOL> assert len ( series_collection ) == expected_len <EOL> @ pytest . fixture ( params = [ <EOL> ( '<STR_LIT>' , <NUM_LIT:0> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT:2> ) , <EOL> ( '<STR_LIT>' <EOL> '<STR_LIT>' , <NUM_LIT:2> ) , <EOL> ] ) <EOL> def getitem_fixture ( self , request , _SeriesFactory_ , series_ ) : <EOL> cxml , idx = request . param <EOL> parent_elm = element ( cxml ) <EOL> ser = parent_elm . xpath ( '<STR_LIT>' ) [ idx ] <EOL> series_collection = SeriesCollection ( parent_elm ) <EOL> return series_collection , idx , _SeriesFactory_ , ser , series_ <EOL> @ pytest . fixture ( params = [ <EOL> ( '<STR_LIT>' , <NUM_LIT:0> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT:1> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT:2> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT:1> ) , <EOL> ( '<STR_LIT>' <EOL> '<STR_LIT>' , <NUM_LIT:3> ) , <EOL> ] ) <EOL> def len_fixture ( self , request ) : <EOL> xChart_cxml , expected_len = request . param <EOL> series_collection = SeriesCollection ( element ( xChart_cxml ) ) <EOL> return series_collection , expected_len <EOL> @ pytest . fixture <EOL> def _SeriesFactory_ ( self , request , series_ ) : <EOL> return function_mock ( <EOL> request , '<STR_LIT>' , return_value = series_ <EOL> ) <EOL> @ pytest . fixture <EOL> def series_ ( self , request ) : <EOL> return instance_mock ( request , _BaseSeries ) <EOL> class Describe_SeriesFactory ( object ) : <EOL> def it_contructs_a_series_object_from_a_plot_element ( self , call_fixture ) : <EOL> ser , SeriesCls_ , series_ = call_fixture <EOL> series = _SeriesFactory ( ser ) <EOL> SeriesCls_ . assert_called_once_with ( ser ) <EOL> assert series is series_ <EOL> @ pytest . fixture ( params = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ] ) <EOL> def call_fixture ( <EOL> self , request , BarSeries_ , bar_series_ , LineSeries_ , <EOL> line_series_ , PieSeries_ , pie_series_ ) : <EOL> xChart_cxml , SeriesCls_ , series_ = { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , BarSeries_ , bar_series_ ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , LineSeries_ , line_series_ ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , PieSeries_ , pie_series_ ) , <EOL> } [ request . param ] <EOL> ser = element ( xChart_cxml ) . ser_lst [ <NUM_LIT:0> ] <EOL> return ser , SeriesCls_ , series_ <EOL> @ pytest . fixture <EOL> def BarSeries_ ( self , request , bar_series_ ) : <EOL> return class_mock ( <EOL> request , '<STR_LIT>' , <EOL> return_value = bar_series_ <EOL> ) <EOL> @ pytest . fixture <EOL> def bar_series_ ( self , request ) : <EOL> return instance_mock ( request , BarSeries ) <EOL> @ pytest . fixture <EOL> def LineSeries_ ( self , request , line_series_ ) : <EOL> return class_mock ( <EOL> request , '<STR_LIT>' , <EOL> return_value = line_series_ <EOL> ) <EOL> @ pytest . fixture <EOL> def line_series_ ( self , request ) : <EOL> return instance_mock ( request , LineSeries ) <EOL> @ pytest . fixture <EOL> def PieSeries_ ( self , request , pie_series_ ) : <EOL> return class_mock ( <EOL> request , '<STR_LIT>' , <EOL> return_value = pie_series_ <EOL> ) <EOL> @ pytest . fixture <EOL> def pie_series_ ( self , request ) : <EOL> return instance_mock ( request , PieSeries ) </s>
