from nose.tools import istest, assert_equal

from mammoth import style_reader
from mammoth.options import read_options, _default_style_map


@istest
def default_style_map_is_used_if_style_map_is_not_set():
    assert_equal(_default_style_map, read_options({})["style_map"])


@istest
def custom_style_mappings_are_prepended_to_default_style_mappings():
    style_map = read_options({
        "style_map": "p.SectionTitle => h2"
    })["style_map"]
    assert_equal(style_reader.read_style("p.SectionTitle => h2"), style_map[0])
    assert_equal(_default_style_map, style_map[1:])


@istest
def default_style_mappings_are_ignored_if_include_default_style_map_is_false():
    style_map = read_options({
        "style_map": "p.SectionTitle => h2",
        "include_default_style_map": False
    })["style_map"]
    assert_equal([style_reader.read_style("p.SectionTitle => h2")], style_map)

@@ -881,8 +881,323 @@
 le_map)%0A
+%0A%0A@istest%0Adef lines_starting_with_hash_in_custom_style_map_are_ignored():%0A    style_map = read_options(%7B%0A        %22style_map%22: %22#p.SectionTitle =%3E h3%5Cnp.SectionTitle =%3E h2%22,%0A        %22include_default_style_map%22: False%0A    %7D)%5B%22style_map%22%5D%0A    assert_equal(%5Bstyle_reader.read_style(%22p.SectionTitle =%3E h2%22)%5D, style_map)%0A

Add test to ensure that style map lines beginning with hash are ignored