|  | 
|  | 1 | +from sphinx_external_toc.api import Document, FileItem, SiteMap, TocTree | 
|  | 2 | + | 
|  | 3 | + | 
|  | 4 | +def test_sitemap_get_changed_identical(): | 
|  | 5 | +    """Test for identical sitemaps.""" | 
|  | 6 | +    root1 = Document("root") | 
|  | 7 | +    root1.subtrees = [TocTree([])] | 
|  | 8 | +    sitemap1 = SiteMap(root1) | 
|  | 9 | +    root2 = Document("root") | 
|  | 10 | +    root2.subtrees = [TocTree([])] | 
|  | 11 | +    sitemap2 = SiteMap(root2) | 
|  | 12 | +    assert sitemap1.get_changed(sitemap2) == set() | 
|  | 13 | + | 
|  | 14 | + | 
|  | 15 | +def test_sitemap_get_changed_root(): | 
|  | 16 | +    """Test for sitemaps with changed root.""" | 
|  | 17 | +    doc1 = Document("doc1") | 
|  | 18 | +    doc2 = Document("doc2") | 
|  | 19 | +    sitemap1 = SiteMap(doc1) | 
|  | 20 | +    sitemap1["doc2"] = doc2 | 
|  | 21 | +    sitemap2 = SiteMap(doc2) | 
|  | 22 | +    sitemap1["doc1"] = doc1 | 
|  | 23 | +    assert sitemap1.get_changed(sitemap2) == {"doc1"} | 
|  | 24 | + | 
|  | 25 | + | 
|  | 26 | +def test_sitemap_get_changed_title(): | 
|  | 27 | +    """Test for sitemaps with changed title.""" | 
|  | 28 | +    root1 = Document("root") | 
|  | 29 | +    root1.title = "a" | 
|  | 30 | +    sitemap1 = SiteMap(root1) | 
|  | 31 | +    root2 = Document("root") | 
|  | 32 | +    root2.title = "b" | 
|  | 33 | +    sitemap2 = SiteMap(root2) | 
|  | 34 | +    assert sitemap1.get_changed(sitemap2) == {"root"} | 
|  | 35 | + | 
|  | 36 | + | 
|  | 37 | +def test_sitemap_get_changed_subtrees(): | 
|  | 38 | +    """Test for sitemaps with changed subtrees.""" | 
|  | 39 | +    root1 = Document("root") | 
|  | 40 | +    root1.subtrees = [TocTree([])] | 
|  | 41 | +    sitemap1 = SiteMap(root1) | 
|  | 42 | +    root2 = Document("root") | 
|  | 43 | +    root2.subtrees = [TocTree([FileItem("a")])] | 
|  | 44 | +    sitemap2 = SiteMap(root2) | 
|  | 45 | +    assert sitemap1.get_changed(sitemap2) == {"root"} | 
|  | 46 | + | 
|  | 47 | + | 
|  | 48 | +def test_sitemap_get_changed_subtrees_numbered(): | 
|  | 49 | +    """Test for sitemaps with changed numbered option.""" | 
|  | 50 | +    root1 = Document("root") | 
|  | 51 | +    root1.subtrees = [TocTree([], numbered=False)] | 
|  | 52 | +    sitemap1 = SiteMap(root1) | 
|  | 53 | +    root2 = Document("root") | 
|  | 54 | +    root2.subtrees = [TocTree([], numbered=True)] | 
|  | 55 | +    sitemap2 = SiteMap(root2) | 
|  | 56 | +    assert sitemap1.get_changed(sitemap2) == {"root"} | 
0 commit comments