<commit_before>from concurrent.futures import Future
from unittest import mock

from taiga_ncurses.config import Configuration
from taiga_ncurses.core import TaigaCore, StateMachine
from taiga_ncurses import controllers

from . import factories


def test_if_client_is_not_authenticated_the_login_view_is_shown_on_startup():
    executor = factories.patched_executor()
    configuration = Configuration()
    core = TaigaCore(executor, configuration, authenticated=False)
    assert isinstance(core.controller, controllers.auth.LoginController)
    assert core.state_machine.state == StateMachine.LOGIN

def test_if_client_is_authenticated_the_projects_view_is_shown_on_startup():
    executor = factories.patched_executor()
    configuration = Configuration()
    core = TaigaCore(executor, configuration, authenticated=True, draw=False)
    assert isinstance(core.controller, controllers.projects.ProjectsController)
    assert core.state_machine.state == StateMachine.PROJECTS

def test_transitioning_from_projects_to_project_detail_and_project_backlog():
    projects = factories.projects()
    project = factories.project()
    project_f = Future()
    us = Future()
    stats = Future()
    executor = factories.patched_executor(project_detail=project_f,
                                          unassigned_user_stories=us,
                                          project_stats=stats,)
    configuration = Configuration()
    core = TaigaCore(executor, configuration, authenticated=True, draw=False)
    assert isinstance(core.controller, controllers.projects.ProjectsController)
    assert core.state_machine.state == StateMachine.PROJECTS
    core.state_machine.project_detail(project)
    project_f.set_result(project)
    us.set_result([])
    stats.set_result(factories.project_stats())
    assert isinstance(core.controller, controllers.projects.ProjectDetailController)
    assert core.state_machine.state == StateMachine.PROJECT_BACKLOG
<commit_msg>Fix core tests<commit_after>from concurrent.futures import Future
from unittest import mock

from taiga_ncurses.config import settings
from taiga_ncurses.core import TaigaCore, StateMachine
from taiga_ncurses import controllers

from . import factories


def test_if_client_is_not_authenticated_the_login_view_is_shown_on_startup():
    executor = factories.patched_executor()
    core = TaigaCore(executor, settings, authenticated=False)
    assert isinstance(core.controller, controllers.auth.LoginController)
    assert core.state_machine.state == StateMachine.LOGIN

def test_if_client_is_authenticated_the_projects_view_is_shown_on_startup():
    executor = factories.patched_executor()
    core = TaigaCore(executor, settings, authenticated=True, draw=False)
    assert isinstance(core.controller, controllers.projects.ProjectsController)
    assert core.state_machine.state == StateMachine.PROJECTS

def test_transitioning_from_projects_to_project_detail_and_project_backlog():
    projects = factories.projects()
    project = factories.project()
    project_f = Future()
    us = Future()
    stats = Future()
    executor = factories.patched_executor(project_detail=project_f,
                                          unassigned_user_stories=us,
                                          project_stats=stats,)
    core = TaigaCore(executor, settings, authenticated=True, draw=False)
    assert isinstance(core.controller, controllers.projects.ProjectsController)
    assert core.state_machine.state == StateMachine.PROJECTS
    core.state_machine.project_detail(project)
    project_f.set_result(project)
    us.set_result([])
    stats.set_result(factories.project_stats())
    assert isinstance(core.controller, controllers.projects.ProjectDetailController)
    assert core.state_machine.state == StateMachine.PROJECT_BACKLOG

{'fraction_non_alphanumeric': 0.07385019710906701, 'fraction_numerical': 0.0, 'mean_word_length': 4.613569321533923, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3261920', 'n_tokens_mistral': 1071, 'n_tokens_neox': 1028, 'n_words': 188}