Skip to content

Commit

Permalink
Tests: Remove unnecessary assertion: assert root_ti is not None
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfstr committed Aug 31, 2024
1 parent cdca052 commit 633aa07
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 32 deletions.
7 changes: 0 additions & 7 deletions src/crystal/tests/test_entitytree.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ async def test_rn_with_error_child_retains_child_when_new_entity_added() -> None
assert project is not None

root_ti = TreeItem.GetRootItem(mw.entity_tree.window)
assert root_ti is not None

RootResource(project, 'Domain 1', Resource(project, 'https://nosuchdomain1.com/'))
(rrn1_ti,) = root_ti.Children
Expand Down Expand Up @@ -401,7 +400,6 @@ async def test_given_rr_is_not_downloaded_and_project_is_read_only_when_expand_r
# Reopen project as read-only
async with (await OpenOrCreateDialog.wait_for()).open(project_dirpath, readonly=True) as mw:
root_ti = TreeItem.GetRootItem(mw.entity_tree.window)
assert root_ti is not None
(home_ti,) = root_ti.Children

# Expand RootResourceNode and ensure it has an _ErrorNode child
Expand Down Expand Up @@ -449,7 +447,6 @@ async def test_given_rr_is_downloaded_and_is_error_when_expand_rrn_then_shows_er
) == rr.error_dict

root_ti = TreeItem.GetRootItem(mw.entity_tree.window)
assert root_ti is not None
(home_ti,) = root_ti.Children

# Expand RootResourceNode and ensure it has an _ErrorNode child
Expand Down Expand Up @@ -491,7 +488,6 @@ async def test_given_rr_is_downloaded_but_revision_body_missing_when_expand_rrn_
assert project is not None

root_ti = TreeItem.GetRootItem(mw.entity_tree.window)
assert root_ti is not None
(home_ti,) = root_ti.Children

# Expand RootResourceNode and ensure it has an _ErrorNode child
Expand Down Expand Up @@ -526,7 +522,6 @@ async def test_given_rr_is_downloaded_but_revision_body_missing_when_expand_rrn_
assert project is not None

root_ti = TreeItem.GetRootItem(mw.entity_tree.window)
assert root_ti is not None
(home_ti,) = root_ti.Children

# Expand RootResourceNode and ensure it now lists the links in
Expand Down Expand Up @@ -607,7 +602,6 @@ async def test_given_more_node_selected_when_expand_more_node_then_first_newly_v
ResourceGroup(project, 'Comic', comic_pattern)

root_ti = TreeItem.GetRootItem(mw.entity_tree.window)
assert root_ti is not None

comic_group_ti = root_ti.GetFirstChild()
assert comic_group_ti is not None
Expand Down Expand Up @@ -689,7 +683,6 @@ async def test_given_more_node_with_large_item_count_then_displays_count_with_co
ResourceGroup(project, 'Comic', comic_pattern)

root_ti = TreeItem.GetRootItem(mw.entity_tree.window)
assert root_ti is not None

comic_group_ti = root_ti.GetFirstChild()
assert comic_group_ti is not None
Expand Down
5 changes: 0 additions & 5 deletions src/crystal/tests/test_load_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ async def test_given_project_database_not_on_ssd_when_expanding_first_resource_g
assert comic_group is not None

root_ti = TreeItem.GetRootItem(mw.entity_tree.window)
assert root_ti is not None

(comic_group_ti,) = [
child for child in root_ti.Children
Expand Down Expand Up @@ -78,7 +77,6 @@ async def test_given_project_database_not_on_ssd_given_resource_group_node_selec
feed_group = ResourceGroup(project, 'Feed', feed_pattern)

root_ti = TreeItem.GetRootItem(mw.entity_tree.window)
assert root_ti is not None

(feed_group_ti,) = [
child for child in root_ti.Children
Expand Down Expand Up @@ -144,7 +142,6 @@ async def test_given_project_database_on_ssd_when_expanding_any_resource_group_n
assert comic_group is not None

root_ti = TreeItem.GetRootItem(mw.entity_tree.window)
assert root_ti is not None

(comic_group_ti,) = [
child for child in root_ti.Children
Expand Down Expand Up @@ -188,7 +185,6 @@ async def test_given_project_database_on_ssd_given_resource_group_node_selected_
feed_group = ResourceGroup(project, 'Feed', feed_pattern)

root_ti = TreeItem.GetRootItem(mw.entity_tree.window)
assert root_ti is not None

(feed_group_ti,) = [
child for child in root_ti.Children
Expand Down Expand Up @@ -248,7 +244,6 @@ async def test_serve_url_never_requires_loading_urls(subtests: SubtestsContext)
assert project is not None

root_ti = TreeItem.GetRootItem(mw.entity_tree.window)
assert root_ti is not None

(home_ti,) = [
child for child in root_ti.Children
Expand Down
2 changes: 0 additions & 2 deletions src/crystal/tests/test_new_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ async def test_can_create_group_with_source(

async with (await OpenOrCreateDialog.wait_for()).create() as (mw, _):
root_ti = TreeItem.GetRootItem(mw.entity_tree.window)
assert root_ti is not None
() = root_ti.Children

# If will need a source later, create one now
Expand Down Expand Up @@ -187,7 +186,6 @@ async def test_given_resource_node_with_multiple_link_children_matching_url_patt
# Create home URL
if True:
root_ti = TreeItem.GetRootItem(mw.entity_tree.window)
assert root_ti is not None
() = root_ti.Children

assert mw.new_root_url_button.Enabled
Expand Down
2 changes: 0 additions & 2 deletions src/crystal/tests/test_new_root_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ async def test_can_create_root_url(
# Create root URL
if True:
root_ti = TreeItem.GetRootItem(mw.entity_tree.window)
assert root_ti is not None
() = root_ti.Children

assert mw.new_root_url_button.Enabled
Expand Down Expand Up @@ -149,7 +148,6 @@ async def test_given_resource_node_with_links_can_create_new_root_url_to_label_l
# Create home URL
if True:
root_ti = TreeItem.GetRootItem(mw.entity_tree.window)
assert root_ti is not None
() = root_ti.Children

assert mw.new_root_url_button.Enabled
Expand Down
2 changes: 0 additions & 2 deletions src/crystal/tests/test_open_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ async def test_given_on_ssd_when_resource_group_node_expanded_then_only_new_reso
assert comic_group is not None

root_ti = TreeItem.GetRootItem(mw.entity_tree.window)
assert root_ti is not None

(comic_group_ti,) = [
child for child in root_ti.Children
Expand Down Expand Up @@ -287,7 +286,6 @@ async def test_given_not_on_ssd_when_resource_group_node_expanded_then_all_proje
assert comic_group is not None

root_ti = TreeItem.GetRootItem(mw.entity_tree.window)
assert root_ti is not None

(comic_group_ti,) = [
child for child in root_ti.Children
Expand Down
2 changes: 0 additions & 2 deletions src/crystal/tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ async def test_given_default_serving_port_in_use_when_start_serving_project_then
# Create a URL
if True:
root_ti = TreeItem.GetRootItem(mw.entity_tree.window)
assert root_ti is not None
assert root_ti.GetFirstChild() is None # no entities

click_button(mw.new_root_url_button)
Expand Down Expand Up @@ -204,7 +203,6 @@ async def serve_and_fetch_xkcd_home_page(mw: MainWindow) -> Tuple[WebPage, str]:
with redirect_stdout(StringIO()) as captured_stdout:
# Start server
root_ti = TreeItem.GetRootItem(mw.entity_tree.window)
assert root_ti is not None
home_ti = root_ti.GetFirstChild()
assert home_ti is not None
assert f'{home_url} - Home' == home_ti.Text
Expand Down
11 changes: 0 additions & 11 deletions src/crystal/tests/test_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ async def test_can_download_and_serve_a_static_site() -> None:
# Test can create root resource
if True:
root_ti = TreeItem.GetRootItem(mw.entity_tree.window)
assert root_ti is not None
assert root_ti.GetFirstChild() is None # no entities

click_button(mw.new_root_url_button)
Expand Down Expand Up @@ -238,7 +237,6 @@ async def test_can_download_and_serve_a_static_site() -> None:
await _undownload_url([atom_feed_url, rss_feed_url], mw, project_dirpath)

root_ti = TreeItem.GetRootItem(mw.entity_tree.window)
assert root_ti is not None

# Create feed item group, with feed group as source
if True:
Expand Down Expand Up @@ -271,7 +269,6 @@ async def test_can_download_and_serve_a_static_site() -> None:
assert False == mw.readonly

root_ti = TreeItem.GetRootItem(mw.entity_tree.window)
assert root_ti is not None

# Start server
home_ti = root_ti.find_child(home_url)
Expand Down Expand Up @@ -316,7 +313,6 @@ async def test_can_download_and_serve_a_static_site() -> None:
assert True == mw.readonly

root_ti = TreeItem.GetRootItem(mw.entity_tree.window)
assert root_ti is not None

feed_group_ti = root_ti.find_child(feed_pattern)

Expand Down Expand Up @@ -381,7 +377,6 @@ async def test_can_download_and_serve_a_site_requiring_dynamic_url_discovery() -

async with (await OpenOrCreateDialog.wait_for()).create() as (mw, project_dirpath):
root_ti = TreeItem.GetRootItem(mw.entity_tree.window)
assert root_ti is not None
assert root_ti.GetFirstChild() is None # no entities

# Download home page
Expand Down Expand Up @@ -422,7 +417,6 @@ def start_server_again():
nonlocal home_ti

root_ti = TreeItem.GetRootItem(mw.entity_tree.window)
assert root_ti is not None
home_ti = root_ti.GetFirstChild()
assert home_ti is not None
home_ti.SelectItem()
Expand Down Expand Up @@ -584,7 +578,6 @@ async def test_can_download_and_serve_a_site_requiring_dynamic_link_rewriting()

async with (await OpenOrCreateDialog.wait_for()).create() as (mw, _):
root_ti = TreeItem.GetRootItem(mw.entity_tree.window)
assert root_ti is not None
assert root_ti.GetFirstChild() is None # no entities

# Download home page
Expand Down Expand Up @@ -699,7 +692,6 @@ async def test_cannot_download_anything_given_project_is_opened_as_readonly() ->
with tempfile.TemporaryDirectory(suffix='.crystalproj') as project_dirpath:
async with (await OpenOrCreateDialog.wait_for()).create(project_dirpath) as (mw, _):
root_ti = TreeItem.GetRootItem(mw.entity_tree.window)
assert root_ti is not None
assert root_ti.GetFirstChild() is None # no entities

# Download home page
Expand Down Expand Up @@ -747,7 +739,6 @@ async def test_cannot_download_anything_given_project_is_opened_as_readonly() ->
assert False == mw.new_group_button.Enabled

root_ti = TreeItem.GetRootItem(mw.entity_tree.window)
assert root_ti is not None

# Ensure "Forget" and "Download" are disabled when resource is selected
home_ti = root_ti.find_child(home_url)
Expand Down Expand Up @@ -829,7 +820,6 @@ async def test_can_update_downloaded_site_with_newer_page_revisions() -> None:
await nud.ok()

root_ti = TreeItem.GetRootItem(mw.entity_tree.window)
assert root_ti is not None
(home_ti, comic1_ti) = root_ti.Children

# Ensure resource status badge says URL is undownloaded
Expand Down Expand Up @@ -980,7 +970,6 @@ async def test_can_download_a_static_site_with_unnamed_root_urls_and_groups() ->
# 2. Ensure unnamed root resource at root of Entity Tree has OK title
if True:
root_ti = TreeItem.GetRootItem(mw.entity_tree.window)
assert root_ti is not None
assert root_ti.GetFirstChild() is None # no entities

click_button(mw.new_root_url_button)
Expand Down
1 change: 0 additions & 1 deletion src/crystal/tests/util/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ async def wait_for_download_to_start_and_finish(
def first_task_title_progression(task_tree: wx.TreeCtrl) -> Callable[[], Optional[str]]:
def first_task_title():
root_ti = TreeItem.GetRootItem(task_tree)
assert root_ti is not None
first_task_ti = root_ti.GetFirstChild()
if first_task_ti is None:
return None # done
Expand Down

0 comments on commit 633aa07

Please sign in to comment.