Exemple #1
0
    def it_can_get_a_style_of_type_by_id(self, _get_by_id_, style_):
        style_id, style_type = 42, 7
        _get_by_id_.return_value = style_
        styles = Styles(None)

        style = styles.get_by_id(style_id, style_type)

        _get_by_id_.assert_called_once_with(styles, style_id, style_type)
        assert style is style_
Exemple #2
0
    def but_it_returns_the_default_style_for_style_id_None(
            self, default_, style_):
        style_type = 17
        default_.return_value = style_
        styles = Styles(None)

        style = styles.get_by_id(None, style_type)

        default_.assert_called_once_with(styles, style_type)
        assert style is style_
Exemple #3
0
    def it_can_get_a_style_id_from_a_style(self, _get_style_id_from_style_):
        style = BaseStyle(None)
        style_type = 22
        _get_style_id_from_style_.return_value = "StyleId"
        styles = Styles(None)

        style_id = styles.get_style_id(style, style_type)

        _get_style_id_from_style_.assert_called_once_with(
            styles, style, style_type)
        assert style_id == "StyleId"
Exemple #4
0
    def and_it_can_get_a_style_id_from_a_style_name(self,
                                                    _get_style_id_from_name_):
        style_type = 22
        _get_style_id_from_name_.return_value = "StyleId"
        styles = Styles(None)

        style_id = styles.get_style_id("Style Name", style_type)

        _get_style_id_from_name_.assert_called_once_with(
            styles, "Style Name", style_type)
        assert style_id == "StyleId"
Exemple #5
0
    def it_gets_a_style_id_from_a_name_to_help(self, _getitem_,
                                               _get_style_id_from_style_,
                                               style_):
        style_name, style_type, style_id_ = 'Foo Bar', 1, 'FooBar'
        _getitem_.return_value = style_
        _get_style_id_from_style_.return_value = style_id_
        styles = Styles(None)

        style_id = styles._get_style_id_from_name(style_name, style_type)

        styles.__getitem__.assert_called_once_with(styles, style_name)
        _get_style_id_from_style_.assert_called_once_with(
            styles, style_, style_type)
        assert style_id is style_id_
Exemple #6
0
 def iter_fixture(self, request, StyleFactory_, style_):
     styles_cxml, expected_count = request.param
     styles_elm = element(styles_cxml)
     styles = Styles(styles_elm)
     expected_calls = [call(style_elm) for style_elm in styles_elm]
     StyleFactory_.return_value = style_
     return styles, expected_count, style_, StyleFactory_, expected_calls
Exemple #7
0
 def id_style_fixture(self, request, default_, style_):
     style_is_default = request.param
     styles = Styles(None)
     style_id, style_type = 'FooBar', 1
     default_.return_value = style_ if style_is_default else None
     style_.style_id, style_.type = style_id, style_type
     expected_value = None if style_is_default else style_id
     return styles, style_, style_type, expected_value
Exemple #8
0
 def default_fixture(self, request, StyleFactory_, style_):
     styles_cxml, is_defined, style_type = request.param
     styles_elm = element(styles_cxml)
     styles = Styles(styles_elm)
     StyleFactory_calls = [call(styles_elm[-1])] if is_defined else []
     StyleFactory_.return_value = style_
     expected_value = style_ if is_defined else None
     return (styles, style_type, StyleFactory_, StyleFactory_calls,
             expected_value)
Exemple #9
0
 def add_fixture(self, request, styles_elm_, _getitem_, style_elm_,
                 StyleFactory_, style_):
     name, name_, style_type, builtin = request.param
     styles = Styles(styles_elm_)
     _getitem_.return_value = None
     styles_elm_.add_style_of_type.return_value = style_elm_
     StyleFactory_.return_value = style_
     return (styles, name, style_type, builtin, name_, StyleFactory_,
             style_elm_, style_)
Exemple #10
0
 def _get_by_id_fixture(self, request, default_, StyleFactory_, style_):
     styles_cxml, style_id, style_type = request.param
     styles_elm = element(styles_cxml)
     style_elm = styles_elm[0]
     styles = Styles(styles_elm)
     default_calls = [] if style_id == 'Foo' else [call(styles, style_type)]
     StyleFactory_calls = [call(style_elm)] if style_id == 'Foo' else []
     default_.return_value = StyleFactory_.return_value = style_
     return (styles, style_id, style_type, default_calls, StyleFactory_,
             StyleFactory_calls, style_)
Exemple #11
0
 def getitem_id_fixture(self, request):
     styles_cxml_tmpl, style_idx = request.param
     styles_cxml = styles_cxml_tmpl % 'w:type=paragraph'
     styles = Styles(element(styles_cxml))
     expected_element = styles._element[style_idx]
     return styles, 'Foobar', expected_element
Exemple #12
0
 def len_fixture(self, request):
     styles_cxml, expected_value = request.param
     styles = Styles(element(styles_cxml))
     return styles, expected_value
Exemple #13
0
 def latent_styles_fixture(self, LatentStyles_, latent_styles_):
     styles = Styles(element('w:styles/w:latentStyles'))
     return styles, LatentStyles_, latent_styles_
Exemple #14
0
 def id_style_raises_fixture(self, style_):
     styles = Styles(None)
     style_.type = 1
     style_type = 2
     return styles, style_, style_type
Exemple #15
0
 def get_raises_fixture(self, request):
     styles_cxml = request.param
     styles = Styles(element(styles_cxml))
     return styles, 'bar'
Exemple #16
0
    def but_it_returns_None_for_a_style_or_name_of_None(self):
        styles = Styles(None)

        style_id = styles.get_style_id(None, style_type=22)

        assert style_id is None
Exemple #17
0
 def add_raises_fixture(self, _getitem_):
     styles = Styles(element('w:styles/w:style/w:name{w:val=heading 1}'))
     name = 'Heading 1'
     return styles, name
Exemple #18
0
 def getitem_name_fixture(self, request):
     styles_cxml_tmpl, key, style_idx = request.param
     styles_cxml = styles_cxml_tmpl % '{w:type=character}'
     styles = Styles(element(styles_cxml))
     expected_element = styles._element[style_idx]
     return styles, key, expected_element
 def styles(self):
     """
     The |_Styles| instance containing the styles (<w:style> element
     proxies) for this styles part.
     """
     return Styles(self.element)