def test_issues_controller_submit_the_filters_popup():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    project_view.issues.notifier = mock.Mock()
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(project_view, executor, _)
    project_detail_controller.handle(config.ProjectKeys.ISSUES)
    project_detail_controller.handle(config.ProjectIssuesKeys.FILTERS)
    filters_popup = project_detail_controller.view.issues.filters_popup
    project_view.issues.notifier.reset_mock()
    executor.issues.reset_mock()

    assert project_view.issues.notifier.info_msg.call_count == 0
    assert executor.issues.call_count == 0
    filters_popup._issue_types_group[0].set_state(True)
    filters_popup._issue_statuses_group[0].set_state(True)
    filters_popup._priorities_group[0].set_state(True)
    filters_popup._severities_group[0].set_state(True)
    filters_popup._assigned_to_group[0].set_state(True)
    filters_popup._created_by_group[0].set_state(True)
    #filters_popup._tags_group[0].set_state(True)
    signals.emit(filters_popup.filter_button, "click")
    assert project_view.issues.notifier.info_msg.call_count == 1
    assert executor.issues.call_count == 1
    assert len(filters_popup._filters) == 7
    assert len(executor.issues.call_args.call_list()[0][1]["filters"]["type"]) == 1
    assert len(executor.issues.call_args.call_list()[0][1]["filters"]["status"]) == 1
    assert len(executor.issues.call_args.call_list()[0][1]["filters"]["severity"]) == 1
    assert len(executor.issues.call_args.call_list()[0][1]["filters"]["priority"]) == 1
    assert len(executor.issues.call_args.call_list()[0][1]["filters"]["assigned_to"]) == 1
    assert len(executor.issues.call_args.call_list()[0][1]["filters"]["owner"]) == 1
def test_sprint_controller_submit_edit_task_form_successfully():
    task_subject = "Update a task"
    task_user_story = 12
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    project_view.sprint.notifier = mock.Mock()
    executor = factories.patched_executor(update_task_response=factories.future(
                           factories.successful_update_task_response(task_subject, task_user_story)))
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(project_view, executor, _)
    project_detail_controller.handle(settings.data.main.keys.milestone)
    project_detail_controller.sprint.view.taskboard.widget.set_focus(1)
    project_detail_controller.handle(settings.data.milestone.keys.edit)
    form = project_detail_controller.sprint.view.task_form
    project_view.sprint.notifier.reset_mock()

    form._subject_edit.set_edit_text(task_subject)
    form._user_story_combo.get_selected().value = task_user_story

    signals.emit(form.save_button, "click")
    assert project_view.sprint.notifier.info_msg.call_count == 1
    assert (executor.update_task.call_args.call_list()[0][0][0]["id"] == form.task["id"])
    assert executor.update_task.call_args.call_list()[0][0][1]["subject"] == task_subject
    assert (executor.update_task.call_args.call_list()[0][0][1]["milestone"] ==
            project_detail_controller.sprint.view._milestone["id"])
    assert executor.update_task.call_args.call_list()[0][0][1]["user_story"] == task_user_story
    assert executor.update_task.call_count == 1
    assert executor.update_task.return_value.result()["subject"] == task_subject
    assert (executor.update_task.return_value.result()["milestone"] ==
            project_detail_controller.sprint.view._milestone["id"])
    assert executor.update_task.return_value.result()["user_story"] == task_user_story
Exemple #3
0
def test_sprint_controller_submit_edit_user_story_form_successfully():
    us_subject = "Update a user story"
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    project_view.sprint.notifier = mock.Mock()
    executor = factories.patched_executor(
        update_user_story_response=factories.future(
            factories.successful_update_user_story_response(us_subject)))
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(
        project_view, executor, _)
    project_detail_controller.handle(settings.data.main.keys.milestone)
    project_detail_controller.handle(settings.data.milestone.keys.edit)
    form = project_detail_controller.sprint.view.user_story_form
    project_view.sprint.notifier.reset_mock()

    form._subject_edit.set_edit_text(us_subject)

    signals.emit(form.save_button, "click")
    assert project_view.sprint.notifier.info_msg.call_count == 1
    assert (executor.update_user_story.call_args.call_list()[0][0][0]["id"] ==
            form.user_story["id"])
    assert executor.update_user_story.call_args.call_list(
    )[0][0][1]["subject"] == us_subject
    assert executor.update_user_story.call_count == 1
    assert executor.update_user_story.return_value.result(
    )["subject"] == us_subject
def test_sprint_controller_change_to_another_milestone():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    project_view.sprint.notifier = mock.Mock()
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(project_view, executor, _)
    project_detail_controller.handle(settings.data.main.keys.milestone)
    project_detail_controller.handle(settings.data.milestone.keys.change_to_milestone)
    milestone_selector_popup = project_detail_controller.view.sprint.milestone_selector_popup
    project_view.sprint.notifier.reset_mock()
    executor.milestone.reset_mock()
    executor.milestone_stats.reset_mock()
    executor.user_stories.reset_mock()
    executor.tasks.reset_mock()

    assert project_view.sprint.notifier.info_msg.call_count == 0
    assert executor.milestone.call_count == 0
    assert executor.milestone_stats.call_count == 0
    assert executor.user_stories.call_count == 0
    assert executor.tasks.call_count == 0
    signals.emit(milestone_selector_popup.options[2], "click")
    assert project_view.sprint.notifier.info_msg.call_count == 1
    assert executor.milestone.call_count == 1
    assert executor.milestone_stats.call_count == 1
    assert executor.user_stories.call_count == 1
    assert executor.tasks.call_count == 1
    assert (project_detail_controller.sprint.view._milestone["id"] ==
            milestone_selector_popup.project["list_of_milestones"][-1]["id"])
Exemple #5
0
def test_sprint_controller_change_to_another_milestone():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    project_view.sprint.notifier = mock.Mock()
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(
        project_view, executor, _)
    project_detail_controller.handle(settings.data.main.keys.milestone)
    project_detail_controller.handle(
        settings.data.milestone.keys.change_to_milestone)
    milestone_selector_popup = project_detail_controller.view.sprint.milestone_selector_popup
    project_view.sprint.notifier.reset_mock()
    executor.milestone.reset_mock()
    executor.milestone_stats.reset_mock()
    executor.user_stories.reset_mock()
    executor.tasks.reset_mock()

    assert project_view.sprint.notifier.info_msg.call_count == 0
    assert executor.milestone.call_count == 0
    assert executor.milestone_stats.call_count == 0
    assert executor.user_stories.call_count == 0
    assert executor.tasks.call_count == 0
    signals.emit(milestone_selector_popup.options[2], "click")
    assert project_view.sprint.notifier.info_msg.call_count == 1
    assert executor.milestone.call_count == 1
    assert executor.milestone_stats.call_count == 1
    assert executor.user_stories.call_count == 1
    assert executor.tasks.call_count == 1
    assert (project_detail_controller.sprint.view._milestone["id"] ==
            milestone_selector_popup.project["list_of_milestones"][-1]["id"])
def test_project_detail_controller_fetches_user_stories_and_transitions_to_backlog():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    state_machine = StateMachine(mock.Mock(), StateMachine.PROJECTS)
    project_detail_controller = controllers.projects.ProjectDetailController(project_view, executor,
                                                                             state_machine)

    assert state_machine.state == state_machine.PROJECT_BACKLOG
def test_project_detail_controller_fetches_user_stories_and_transitions_to_backlog():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    state_machine = StateMachine(mock.Mock(), StateMachine.PROJECTS)
    project_detail_controller = controllers.projects.ProjectDetailController(project_view, executor,
                                                                             state_machine)

    assert state_machine.state == state_machine.PROJECT_BACKLOG
def test_backlog_controller_show_the_new_user_story_form():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(project_view, executor, _)

    assert not hasattr(project_detail_controller.view.backlog, "user_story_form")
    project_detail_controller.handle(config.ProjectBacklogKeys.CREATE_USER_STORY)
    assert hasattr(project_detail_controller.view.backlog, "user_story_form")
def test_backlog_controller_show_the_milestone_selector_popup():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(project_view, executor, _)

    assert not hasattr(project_detail_controller.view.backlog, "milestone_selector_popup")
    project_detail_controller.handle(config.ProjectBacklogKeys.MOVE_US_TO_MILESTONE)
    assert hasattr(project_detail_controller.view.backlog, "milestone_selector_popup")
def test_backlog_controller_update_user_stories_order_with_errors():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    project_view.backlog.notifier = mock.Mock()
    executor = factories.patched_executor(update_user_stories_order_response=factories.future(None))
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(project_view, executor, _)

    project_detail_controller.handle(config.ProjectBacklogKeys.UPDATE_USER_STORIES_ORDER)
    assert project_view.backlog.notifier.error_msg.call_count == 1
def test_backlog_controller_update_user_stories_order_with_errors():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    project_view.backlog.notifier = mock.Mock()
    executor = factories.patched_executor(update_user_stories_order_response=factories.future(None))
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(project_view, executor, _)

    project_detail_controller.handle(settings.data.backlog.keys.update_order)
    assert project_view.backlog.notifier.error_msg.call_count == 1
def test_backlog_controller_show_the_help_popup():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(project_view, executor, _)

    assert not hasattr(project_detail_controller.view.backlog, "help_popup")
    project_detail_controller.handle(config.ProjectBacklogKeys.HELP)
    assert hasattr(project_detail_controller.view.backlog, "help_popup")
def test_backlog_controller_show_the_milestone_selector_popup():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(project_view, executor, _)

    assert not hasattr(project_detail_controller.view.backlog, "milestone_selector_popup")
    project_detail_controller.handle(settings.data.backlog.keys.move_to_milestone)
    assert hasattr(project_detail_controller.view.backlog, "milestone_selector_popup")
def test_login_controller_prints_an_error_message_on_unsuccessful_login():
    login_view = factories.login_view("admin", "123123")
    login_view.notifier = mock.Mock()
    executor = factories.patched_executor(login_response=factories.future(None))
    _ = mock.Mock()
    login_controller = controllers.auth.LoginController(login_view, executor, _)

    signals.emit(login_view.login_button, "click")

    assert login_view.notifier.error_msg.call_count == 1
def test_projects_controller_click_on_project_requests_the_project_detail():
    projects = factories.projects()
    projects_view = views.projects.ProjectsView()
    executor = factories.patched_executor()
    _ = mock.Mock()
    projects_controller = controllers.projects.ProjectsController(projects_view, executor, _)

    signals.emit(projects_view.project_buttons[0], "click")

    executor.project_detail.assert_called_with(projects[0])
def test_login_controller_prints_an_error_message_on_unsuccessful_login():
    login_view = factories.login_view("admin", "123123")
    login_view.notifier = mock.Mock()
    executor = factories.patched_executor(login_response=factories.future(None))
    _ = mock.Mock()
    login_controller = controllers.auth.LoginController(login_view, executor, _)

    signals.emit(login_view.login_button, "click")

    assert login_view.notifier.error_msg.call_count == 1
def test_backlog_controller_show_the_new_user_story_form():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(project_view, executor, _)

    assert not hasattr(project_detail_controller.view.backlog, "user_story_form")
    project_detail_controller.handle(settings.data.backlog.keys.create)
    assert hasattr(project_detail_controller.view.backlog, "user_story_form")
def test_projects_controller_click_on_project_requests_the_project_detail():
    projects = factories.projects()
    projects_view = views.projects.ProjectsView()
    executor = factories.patched_executor()
    _ = mock.Mock()
    projects_controller = controllers.projects.ProjectsController(projects_view, executor, _)

    signals.emit(projects_view.project_buttons[0], "click")

    executor.project_detail.assert_called_with(projects[0])
def test_projects_controller_click_on_project_when_project_is_fetched_transitions_to_project_detail():
    projects = factories.projects()
    fetched_project = projects[0]
    projects_view = views.projects.ProjectsView()
    executor = factories.patched_executor(project_detail=factories.future(fetched_project))
    state_machine = mock.Mock()
    projects_controller = controllers.projects.ProjectsController(projects_view, executor, state_machine)

    signals.emit(projects_view.project_buttons[0], "click")

    state_machine.project_detail.assert_called_with(fetched_project)
def test_projects_controller_when_requesting_a_project_info_message_is_shown():
    projects = factories.projects()
    projects_view = views.projects.ProjectsView()
    projects_view.notifier = mock.Mock()
    executor = factories.patched_executor()
    _ = mock.Mock()
    projects_controller = controllers.projects.ProjectsController(projects_view, executor, _)

    signals.emit(projects_view.project_buttons[0], "click")

    assert projects_view.notifier.info_msg.call_count == 1
def test_project_detail_controller_fetches_wiki_pages_and_transitions_to_wiki():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    state_machine = StateMachine(mock.Mock(), StateMachine.PROJECTS)
    project_detail_controller = controllers.projects.ProjectDetailController(project_view, executor,
                                                                             state_machine)
    assert state_machine.state == state_machine.PROJECT_BACKLOG

    project_detail_controller.handle(settings.data.main.keys.wiki)
    assert state_machine.state == state_machine.PROJECT_WIKI
def test_project_detail_controller_fetches_task_and_transitions_to_sprint_taskboard():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    state_machine = StateMachine(mock.Mock(), StateMachine.PROJECTS)
    project_detail_controller = controllers.projects.ProjectDetailController(project_view, executor,
                                                                             state_machine)
    assert state_machine.state == state_machine.PROJECT_BACKLOG

    project_detail_controller.handle(settings.data.main.keys.milestone)
    assert state_machine.state == state_machine.PROJECT_MILESTONES
def test_issues_controller_show_the_new_issue_form():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(project_view, executor, _)
    project_detail_controller.handle(config.ProjectKeys.ISSUES)

    assert not hasattr(project_detail_controller.view.issues, "issue_form")
    project_detail_controller.handle(config.ProjectIssuesKeys.CREATE_ISSUE)
    assert hasattr(project_detail_controller.view.issues, "issue_form")
def test_project_detail_controller_fetches_issues_and_transitions_to_issues():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    state_machine = StateMachine(mock.Mock(), StateMachine.PROJECTS)
    project_detail_controller = controllers.projects.ProjectDetailController(project_view, executor,
                                                                             state_machine)
    assert state_machine.state == state_machine.PROJECT_BACKLOG

    project_detail_controller.handle(config.ProjectKeys.ISSUES)
    assert state_machine.state == state_machine.PROJECT_ISSUES
def test_sprints_controller_show_the_help_popup():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(project_view, executor, _)
    project_detail_controller.handle(config.ProjectKeys.MILESTONES)

    assert not hasattr(project_detail_controller.view.sprint, "help_popup")
    project_detail_controller.handle(config.ProjectMilestoneKeys.HELP)
    assert hasattr(project_detail_controller.view.sprint, "help_popup")
def test_backlog_controller_update_user_stories_order_with_success():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    project_view.backlog.notifier = mock.Mock()
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(project_view, executor, _)
    project_view.backlog.notifier.reset_mock()

    project_detail_controller.handle(settings.data.backlog.keys.update_order)
    assert project_view.backlog.notifier.info_msg.call_count == 1
def test_issues_controller_show_the_filters_popup():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(project_view, executor, _)
    project_detail_controller.handle(config.ProjectKeys.ISSUES)

    assert not hasattr(project_detail_controller.view.issues, "filters_popup")
    project_detail_controller.handle(config.ProjectIssuesKeys.FILTERS)
    assert hasattr(project_detail_controller.view.issues, "filters_popup")
def test_project_detail_controller_fetches_task_and_transitions_to_sprint_taskboard():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    state_machine = StateMachine(mock.Mock(), StateMachine.PROJECTS)
    project_detail_controller = controllers.projects.ProjectDetailController(project_view, executor,
                                                                             state_machine)
    assert state_machine.state == state_machine.PROJECT_BACKLOG

    project_detail_controller.handle(settings.data.main.keys.milestone)
    assert state_machine.state == state_machine.PROJECT_MILESTONES
def test_projects_controller_click_on_project_when_project_is_fetched_transitions_to_project_detail():
    projects = factories.projects()
    fetched_project = projects[0]
    projects_view = views.projects.ProjectsView()
    executor = factories.patched_executor(project_detail=factories.future(fetched_project))
    state_machine = mock.Mock()
    projects_controller = controllers.projects.ProjectsController(projects_view, executor, state_machine)

    signals.emit(projects_view.project_buttons[0], "click")

    state_machine.project_detail.assert_called_with(fetched_project)
def test_project_detail_controller_fetches_wiki_pages_and_transitions_to_wiki():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    state_machine = StateMachine(mock.Mock(), StateMachine.PROJECTS)
    project_detail_controller = controllers.projects.ProjectDetailController(project_view, executor,
                                                                             state_machine)
    assert state_machine.state == state_machine.PROJECT_BACKLOG

    project_detail_controller.handle(settings.data.main.keys.wiki)
    assert state_machine.state == state_machine.PROJECT_WIKI
def test_projects_controller_when_requesting_a_project_info_message_is_shown():
    projects = factories.projects()
    projects_view = views.projects.ProjectsView()
    projects_view.notifier = mock.Mock()
    executor = factories.patched_executor()
    _ = mock.Mock()
    projects_controller = controllers.projects.ProjectsController(projects_view, executor, _)

    signals.emit(projects_view.project_buttons[0], "click")

    assert projects_view.notifier.info_msg.call_count == 1
def test_sprints_controller_show_the_help_popup():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(project_view, executor, _)
    project_detail_controller.handle(settings.data.main.keys.milestone)

    assert not hasattr(project_detail_controller.view.sprint, "help_popup")
    project_detail_controller.handle(settings.data.milestone.keys.help)
    assert hasattr(project_detail_controller.view.sprint, "help_popup")
Exemple #33
0
def test_backlog_controller_show_the_help_popup():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(
        project_view, executor, _)

    assert not hasattr(project_detail_controller.view.backlog, "help_popup")
    project_detail_controller.handle(settings.data.backlog.keys.help)
    assert hasattr(project_detail_controller.view.backlog, "help_popup")
def test_issues_controller_show_the_filters_popup():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(project_view, executor, _)
    project_detail_controller.handle(settings.data.main.keys.issues)

    assert not hasattr(project_detail_controller.view.issues, "filters_popup")
    project_detail_controller.handle(settings.data.issues.keys.filters)
    assert hasattr(project_detail_controller.view.issues, "filters_popup")
Exemple #35
0
def test_backlog_controller_show_the_new_user_story_form():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(
        project_view, executor, _)

    assert not hasattr(project_detail_controller.view.backlog,
                       "user_story_form")
    project_detail_controller.handle(settings.data.backlog.keys.create)
    assert hasattr(project_detail_controller.view.backlog, "user_story_form")
Exemple #36
0
def test_backlog_controller_update_user_stories_order_with_success():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    project_view.backlog.notifier = mock.Mock()
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(
        project_view, executor, _)
    project_view.backlog.notifier.reset_mock()

    project_detail_controller.handle(settings.data.backlog.keys.update_order)
    assert project_view.backlog.notifier.info_msg.call_count == 1
Exemple #37
0
def test_backlog_controller_update_user_stories_order_with_errors():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    project_view.backlog.notifier = mock.Mock()
    executor = factories.patched_executor(
        update_user_stories_order_response=factories.future(None))
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(
        project_view, executor, _)

    project_detail_controller.handle(settings.data.backlog.keys.update_order)
    assert project_view.backlog.notifier.error_msg.call_count == 1
def test_projects_controller_when_project_fetching_fails_a_error_message_is_shown():
    projects = factories.projects()
    fetched_project = projects[0]
    projects_view = views.projects.ProjectsView()
    projects_view.notifier = mock.Mock()
    executor = factories.patched_executor(project_detail=factories.future(None))
    _ = mock.Mock()
    projects_controller = controllers.projects.ProjectsController(projects_view, executor, _)

    signals.emit(projects_view.project_buttons[0], "click")

    assert projects_view.notifier.error_msg.call_count == 1
def test_backlog_controller_submit_new_user_story_form_with_errors():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    project_view.backlog.notifier = mock.Mock()
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(project_view, executor, _)
    project_detail_controller.handle(settings.data.backlog.keys.create)
    form = project_detail_controller.view.backlog.user_story_form

    signals.emit(form.save_button, "click")
    assert project_view.backlog.notifier.error_msg.call_count == 1
def test_backlog_controller_cancel_the_new_user_story_form():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(project_view, executor, _)
    project_detail_controller.handle(settings.data.backlog.keys.create)

    assert hasattr(project_detail_controller.view.backlog, "user_story_form")
    form = project_detail_controller.view.backlog.user_story_form
    signals.emit(form.cancel_button, "click")
    assert not hasattr(project_detail_controller.view.backlog, "user_story_form")
def test_sprint_controller_show_the_new_task_form():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(project_view, executor, _)
    project_detail_controller.handle(settings.data.main.keys.milestone)
    project_detail_controller.sprint.view.taskboard.widget.set_focus(1)

    assert not hasattr(project_detail_controller.sprint.view, "task_form")
    project_detail_controller.handle(settings.data.milestone.keys.create_task)
    assert hasattr(project_detail_controller.sprint.view, "task_form")
def test_sprint_controller_show_the_new_task_form():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(project_view, executor, _)
    project_detail_controller.handle(config.ProjectKeys.MILESTONES)
    project_detail_controller.sprint.view.taskboard.widget.set_focus(1)

    assert not hasattr(project_detail_controller.sprint.view, "task_form")
    project_detail_controller.handle(config.ProjectMilestoneKeys.CREATE_TASK)
    assert hasattr(project_detail_controller.sprint.view, "task_form")
def test_issues_controller_show_the_new_issue_form():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(
        project_view, executor, _)
    project_detail_controller.handle(settings.data.main.keys.issues)

    assert not hasattr(project_detail_controller.view.issues, "issue_form")
    project_detail_controller.handle(settings.data.issues.keys.create)
    assert hasattr(project_detail_controller.view.issues, "issue_form")
def test_projects_controller_when_project_fetching_fails_a_error_message_is_shown():
    projects = factories.projects()
    fetched_project = projects[0]
    projects_view = views.projects.ProjectsView()
    projects_view.notifier = mock.Mock()
    executor = factories.patched_executor(project_detail=factories.future(None))
    _ = mock.Mock()
    projects_controller = controllers.projects.ProjectsController(projects_view, executor, _)

    signals.emit(projects_view.project_buttons[0], "click")

    assert projects_view.notifier.error_msg.call_count == 1
def test_backlog_controller_close_the_milestone_selector_popup():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(project_view, executor, _)
    project_detail_controller.handle(settings.data.backlog.keys.move_to_milestone)

    assert hasattr(project_detail_controller.view.backlog, "milestone_selector_popup")
    milestone_selector_popup = project_detail_controller.view.backlog.milestone_selector_popup
    signals.emit(milestone_selector_popup.cancel_button, "click")
    assert not hasattr(project_detail_controller.view.backlog, "milestone_selector_popup")
Exemple #46
0
def test_backlog_controller_submit_new_user_story_form_with_errors():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    project_view.backlog.notifier = mock.Mock()
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(
        project_view, executor, _)
    project_detail_controller.handle(settings.data.backlog.keys.create)
    form = project_detail_controller.view.backlog.user_story_form

    signals.emit(form.save_button, "click")
    assert project_view.backlog.notifier.error_msg.call_count == 1
Exemple #47
0
def test_sprint_controller_show_the_new_task_form():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(
        project_view, executor, _)
    project_detail_controller.handle(settings.data.main.keys.milestone)
    project_detail_controller.sprint.view.taskboard.widget.set_focus(1)

    assert not hasattr(project_detail_controller.sprint.view, "task_form")
    project_detail_controller.handle(settings.data.milestone.keys.create_task)
    assert hasattr(project_detail_controller.sprint.view, "task_form")
Exemple #48
0
def test_backlog_controller_close_the_help_popup():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(
        project_view, executor, _)
    project_detail_controller.handle(settings.data.backlog.keys.help)

    assert hasattr(project_detail_controller.view.backlog, "help_popup")
    help_popup = project_detail_controller.view.backlog.help_popup
    signals.emit(help_popup.close_button, "click")
    assert not hasattr(project_detail_controller.view.backlog, "help_popup")
def test_issues_controller_cancel_the_filters_popup():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(
        project_view, executor, _)
    project_detail_controller.handle(settings.data.main.keys.issues)
    project_detail_controller.handle(settings.data.issues.keys.filters)

    assert hasattr(project_detail_controller.view.issues, "filters_popup")
    filters_popup = project_detail_controller.view.issues.filters_popup
    signals.emit(filters_popup.cancel_button, "click")
    assert not hasattr(project_detail_controller.view.issues, "filters_popup")
Exemple #50
0
def test_backlog_controller_cancel_the_new_user_story_form():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(
        project_view, executor, _)
    project_detail_controller.handle(settings.data.backlog.keys.create)

    assert hasattr(project_detail_controller.view.backlog, "user_story_form")
    form = project_detail_controller.view.backlog.user_story_form
    signals.emit(form.cancel_button, "click")
    assert not hasattr(project_detail_controller.view.backlog,
                       "user_story_form")
Exemple #51
0
def test_backlog_controller_delete_user_story_with_success():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    project_view.backlog.notifier = mock.Mock()
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(
        project_view, executor, _)
    project_view.backlog.notifier.reset_mock()

    project_detail_controller.handle(settings.data.backlog.keys.delete)
    assert project_view.backlog.notifier.info_msg.call_count == 1
    assert (executor.delete_user_story.call_args.call_list()[0][0][0]["id"] ==
            project_detail_controller.backlog.user_stories[0]["id"])
Exemple #52
0
def test_sprint_controller_delete_user_story_with_errors():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    project_view.sprint.notifier = mock.Mock()
    executor = factories.patched_executor(
        delete_user_story_response=factories.future(None))
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(
        project_view, executor, _)
    project_detail_controller.handle(settings.data.main.keys.milestone)

    project_detail_controller.handle(settings.data.milestone.keys.delete)
    assert project_view.sprint.notifier.error_msg.call_count == 1
    assert (executor.delete_user_story.call_args.call_list()[0][0][0]["id"] ==
            project_detail_controller.sprint.view._user_stories[0]["id"])
Exemple #53
0
def test_sprint_controller_cancel_the_edit_task_form():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(
        project_view, executor, _)
    project_detail_controller.handle(settings.data.main.keys.milestone)
    project_detail_controller.sprint.view.taskboard.widget.set_focus(1)
    project_detail_controller.handle(settings.data.milestone.keys.edit)

    assert hasattr(project_detail_controller.sprint.view, "task_form")
    form = project_detail_controller.sprint.view.task_form
    signals.emit(form.cancel_button, "click")
    assert not hasattr(project_detail_controller.sprint.view, "task_form")
Exemple #54
0
def test_sprint_controller_submit_the_edit_user_story_form_with_errors():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    project_view.sprint.notifier = mock.Mock()
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(
        project_view, executor, _)
    project_detail_controller.handle(settings.data.main.keys.milestone)
    project_detail_controller.handle(settings.data.milestone.keys.edit)
    form = project_detail_controller.sprint.view.user_story_form

    form._subject_edit.set_edit_text("")
    signals.emit(form.save_button, "click")
    assert project_view.sprint.notifier.error_msg.call_count == 1
def test_issues_controller_show_the_edit_issue_form():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(
        project_view, executor, _)
    project_detail_controller.handle(settings.data.main.keys.issues)

    assert not hasattr(project_detail_controller.view.issues, "issue_form")
    project_detail_controller.handle(settings.data.issues.keys.edit)
    assert hasattr(project_detail_controller.view.issues, "issue_form")
    assert (project_detail_controller.view.issues.issue_form.issue ==
            project_detail_controller.view.issues.issues.list_walker.get_focus(
            )[0].issue)
Exemple #56
0
def test_backlog_controller_reload():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(
        project_view, executor, _)
    executor.project_stats.reset_mock()
    executor.unassigned_user_stories.reset_mock()

    assert executor.project_stats.call_count == 0
    assert executor.unassigned_user_stories.call_count == 0
    project_detail_controller.handle(settings.data.backlog.keys.reload)
    assert executor.project_stats.call_count == 1
    assert executor.unassigned_user_stories.call_count == 1
Exemple #57
0
def test_sprint_controller_show_the_milestone_selector_popup():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(
        project_view, executor, _)
    project_detail_controller.handle(settings.data.main.keys.milestone)

    assert not hasattr(project_detail_controller.view.sprint,
                       "milestone_selector_popup")
    project_detail_controller.handle(
        settings.data.milestone.keys.change_to_milestone)
    assert hasattr(project_detail_controller.view.sprint,
                   "milestone_selector_popup")
Exemple #58
0
def test_backlog_controller_show_the_edit_user_story_form():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(
        project_view, executor, _)

    assert not hasattr(project_detail_controller.view.backlog,
                       "user_story_form")
    project_detail_controller.handle(settings.data.backlog.keys.edit)
    assert hasattr(project_detail_controller.view.backlog, "user_story_form")
    assert (project_detail_controller.view.backlog.user_story_form.user_story
            == project_detail_controller.view.backlog.user_stories.widget.
            get_focus().user_story)
Exemple #59
0
def test_sprint_controller_show_the_new_user_story_form():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(
        project_view, executor, _)
    project_detail_controller.handle(settings.data.main.keys.milestone)

    assert not hasattr(project_detail_controller.sprint.view,
                       "user_story_form")
    project_detail_controller.handle(
        settings.data.milestone.keys.create_user_story)
    assert hasattr(project_detail_controller.sprint.view, "user_story_form")
    assert (project_detail_controller.sprint.view.user_story_form.user_story[
        "milestone"] == project_detail_controller.sprint.view._milestone["id"])
Exemple #60
0
def test_sprint_controller_delete_task_with_success():
    project = factories.project()
    project_view = views.projects.ProjectDetailView(project)
    project_view.sprint.notifier = mock.Mock()
    executor = factories.patched_executor()
    _ = mock.Mock()
    project_detail_controller = controllers.projects.ProjectDetailController(
        project_view, executor, _)
    project_detail_controller.handle(settings.data.main.keys.milestone)
    project_view.sprint.notifier.reset_mock()

    project_view.sprint.taskboard.list_walker.set_focus(2)
    project_detail_controller.handle(settings.data.milestone.keys.delete)
    assert project_view.sprint.notifier.info_msg.call_count == 1
    assert (executor.delete_task.call_args.call_list()[0][0][0]["id"] ==
            project_detail_controller.sprint.view._tasks[1]["id"])