# Path: hamster_gtk/helpers.py
# def _u(string):
#     """
#     Return passed string as a text instance.
# 
#     This helper is particularly useful to wrap Gtk 'string return values' as
#     they depend on the used python version. On python 2 Gtk will return utf-8
#     encoded bytestrings while on python 3 it will return 'unicode strings'.
# 
#     The reason we have to use this and not ``six.u`` is that six does not make
#     assumptions about the encoding and hence can not be used to safely decode
#     non ascii bytestrings into unicode.
# 
#     Args:
#         string (str): A string instance. On ``py2`` this will be a bytestring,
#             on ``py3`` a 'unicode string'.
# 
#     Returns:
#         text_type: Returns a 'unicode text type'. Under ``py2`` that means a
#         ``unicode`` instance, under ``py3`` this will be a ``str`` instance.
#     """
#     if six.PY2:
#         return string.decode('utf-8')
#     else:
#         return string
# 
# Path: hamster_gtk/tracking/screens.py
# class TrackingScreen(Gtk.Stack):
# class CurrentFactBox(Gtk.Box):
# class StartTrackingBox(Gtk.Box):
#     def __init__(self, app, *args, **kwargs):
#     def update(self, evt=None):
#     def __init__(self, controller):
#     def update(self, fact=None):
#     def _get_fact_label(self, fact):
#     def _get_cancel_button(self):
#     def _get_save_button(self):
#     def _get_invalid_label(self):
#     def _on_cancel_button(self, button):
#     def _on_save_button(self, button):
#     def __init__(self, app, *args, **kwargs):
#     def _start_ongoing_fact(self):
#         def complete_tmp_fact(fact):
#     def reset(self):
#     def _on_start_tracking_button(self, button):
#     def _on_raw_fact_entry_activate(self, evt):


import pytest
from gi.repository import Gtk
from six import text_type
from hamster_gtk.helpers import _u
from hamster_gtk.tracking import screens
        start_tracking_box._on_start_tracking_button(None)
        assert start_tracking_box._app.controller.store.facts.save.called

    def test__reset(self, start_tracking_box):
        """Make sure all relevant widgets are reset."""
        start_tracking_box.raw_fact_entry.props.text = 'foobar'
        start_tracking_box.reset()
        assert start_tracking_box.raw_fact_entry.props.text == ''


class TestCurrentFactBox(object):
    """Unittests for CurrentFactBox."""

    def test_init(self, app):
        result = screens.CurrentFactBox(app.controller)
        assert isinstance(result, screens.CurrentFactBox)

    def test_update_initial_fact(self, current_fact_box, fact):
        """Make sure update re-creates as widgets as expected."""
        assert not current_fact_box.content.get_children()
        current_fact_box.update(fact)
        assert len(current_fact_box.content.get_children()) == 3
        label = current_fact_box.content.get_children()[0]
        expectation = '{activity.name}@{activity.category}'.format(activity=fact.activity)
        assert expectation in _u(label.get_text())

    def test__get_fact_label(self, current_fact_box, fact):
        """Make sure that the label matches expectations."""
        result = current_fact_box._get_fact_label(fact)
        assert isinstance(result, Gtk.Label)

# Path: hamster_gtk/helpers.py
# def _u(string):
#     """
#     Return passed string as a text instance.
# 
#     This helper is particularly useful to wrap Gtk 'string return values' as
#     they depend on the used python version. On python 2 Gtk will return utf-8
#     encoded bytestrings while on python 3 it will return 'unicode strings'.
# 
#     The reason we have to use this and not ``six.u`` is that six does not make
#     assumptions about the encoding and hence can not be used to safely decode
#     non ascii bytestrings into unicode.
# 
#     Args:
#         string (str): A string instance. On ``py2`` this will be a bytestring,
#             on ``py3`` a 'unicode string'.
# 
#     Returns:
#         text_type: Returns a 'unicode text type'. Under ``py2`` that means a
#         ``unicode`` instance, under ``py3`` this will be a ``str`` instance.
#     """
#     if six.PY2:
#         return string.decode('utf-8')
#     else:
#         return string
# 
# Path: hamster_gtk/tracking/screens.py
# class TrackingScreen(Gtk.Stack):
# class CurrentFactBox(Gtk.Box):
# class StartTrackingBox(Gtk.Box):
#     def __init__(self, app, *args, **kwargs):
#     def update(self, evt=None):
#     def __init__(self, controller):
#     def update(self, fact=None):
#     def _get_fact_label(self, fact):
#     def _get_cancel_button(self):
#     def _get_save_button(self):
#     def _get_invalid_label(self):
#     def _on_cancel_button(self, button):
#     def _on_save_button(self, button):
#     def __init__(self, app, *args, **kwargs):
#     def _start_ongoing_fact(self):
#         def complete_tmp_fact(fact):
#     def reset(self):
#     def _on_start_tracking_button(self, button):
#     def _on_raw_fact_entry_activate(self, evt):


# Path: tests/tracking/test_screens.py
import pytest
from gi.repository import Gtk
from six import text_type
from hamster_gtk.helpers import _u
from hamster_gtk.tracking import screens

        start_tracking_box._on_start_tracking_button(None)
        assert start_tracking_box._app.controller.store.facts.save.called

    def test__reset(self, start_tracking_box):
        """Make sure all relevant widgets are reset."""
        start_tracking_box.raw_fact_entry.props.text = 'foobar'
        start_tracking_box.reset()
        assert start_tracking_box.raw_fact_entry.props.text == ''


class TestCurrentFactBox(object):
    """Unittests for CurrentFactBox."""

    def test_init(self, app):
        result = screens.CurrentFactBox(app.controller)
        assert isinstance(result, screens.CurrentFactBox)

    def test_update_initial_fact(self, current_fact_box, fact):
        """Make sure update re-creates as widgets as expected."""
        assert not current_fact_box.content.get_children()
        current_fact_box.update(fact)
        assert len(current_fact_box.content.get_children()) == 3
        label = current_fact_box.content.get_children()[0]
        expectation = '{activity.name}@{activity.category}'.format(activity=fact.activity)
        assert expectation in _u(label.get_text())

    def test__get_fact_label(self, current_fact_box, fact):
        """Make sure that the label matches expectations."""
        result = current_fact_box._get_fact_label(fact)
        assert isinstance(result, Gtk.Label)

        assert _u(result.get_text()) == text_type(fact)