<commit_before>import unittest
from mock import patch
import keybinder
import azulejo_screen
import gtk

class AzulejoTest(unittest.TestCase):

    @patch.object(keybinder, 'bind')
    def test_left_side(self, mock_my_method):
        """ Test the left side moving of windows """  
        
        keybinding_obj = KeyBinderDummy()

        # Defined sideeffect for the key bind operation
        def side_effect(key, dispatcher, dispatcher_params):
            keybinding_obj.bind(key, dispatcher, dispatcher_params)
        mock_my_method.side_effect = side_effect

        # Definition of the screen mock for this test
        class SingleTestScreenMock(AzulejoScreenMock):
            def __init__(self):
               
                self.monitor_geometry = [
                   gtk.gdk.Rectangle(x=0, y=0, width=1000, height=1000),
                ]

                self.windows = [
                   {
                       'geometry': [ 0, 0, 10, 10 ],
                       'active': True,
                       'monitor': 0,
                   },
                   {
                       'geometry': [ 200, 0, 5, 5 ],
                       'active': False,
                       'monitor': 0,
                   },
                ]
            


        # Monkey patch
        azulejo_screen.AzulejoScreen = SingleTestScreenMock

        # Import and run the code under test
        import azulejo
        azulejo.run(True)

        # Trigger a keypress
        keybinding_obj.action_key('<Super>h')

        self.assertEqual(
            keybinding_obj.get_screen().get_active_window()['geometry'],
            [0, 0, 500, 1000]
        )
        
        # Trigger another keypress
        keybinding_obj.action_key('<Super>h')

        self.assertEqual(
            keybinding_obj.get_screen().get_active_window()['geometry'],
            [0, 0, 300, 1000]
        )
        
        # Trigger another keypress
        keybinding_obj.action_key('<Super>h')

        self.assertEqual(
            keybinding_obj.get_screen().get_active_window()['geometry'],
            [0, 0, 700, 1000]
        )



class KeyBinderDummy:
    """ Class this is used to allow keybindings to be caught and to be actioned """

    bindings = []
    saved_obj = None

    def __init__(self):

        pass

    def bind(self, action, dispatcher, dispatcher_params):
        """ Bind a key press """
<commit_msg>Move attr creation to initialiser<commit_after>import unittest
from mock import patch
import keybinder
import azulejo_screen
import gtk

class AzulejoTest(unittest.TestCase):

    @patch.object(keybinder, 'bind')
    def test_left_side(self, mock_my_method):
        """ Test the left side moving of windows """  
        
        keybinding_obj = KeyBinderDummy()

        # Defined sideeffect for the key bind operation
        def side_effect(key, dispatcher, dispatcher_params):
            keybinding_obj.bind(key, dispatcher, dispatcher_params)
        mock_my_method.side_effect = side_effect

        # Definition of the screen mock for this test
        class SingleTestScreenMock(AzulejoScreenMock):
            def __init__(self):
               
                self.monitor_geometry = [
                   gtk.gdk.Rectangle(x=0, y=0, width=1000, height=1000),
                ]

                self.windows = [
                   {
                       'geometry': [ 0, 0, 10, 10 ],
                       'active': True,
                       'monitor': 0,
                   },
                   {
                       'geometry': [ 200, 0, 5, 5 ],
                       'active': False,
                       'monitor': 0,
                   },
                ]
            


        # Monkey patch
        azulejo_screen.AzulejoScreen = SingleTestScreenMock

        # Import and run the code under test
        import azulejo
        azulejo.run(True)

        # Trigger a keypress
        keybinding_obj.action_key('<Super>h')

        self.assertEqual(
            keybinding_obj.get_screen().get_active_window()['geometry'],
            [0, 0, 500, 1000]
        )
        
        # Trigger another keypress
        keybinding_obj.action_key('<Super>h')

        self.assertEqual(
            keybinding_obj.get_screen().get_active_window()['geometry'],
            [0, 0, 300, 1000]
        )
        
        # Trigger another keypress
        keybinding_obj.action_key('<Super>h')

        self.assertEqual(
            keybinding_obj.get_screen().get_active_window()['geometry'],
            [0, 0, 700, 1000]
        )

    @patch.object(keybinder, 'bind')
    def test_maximise(self, mock_my_method):
        """ Test the maximising of active window """  
        
        keybinding_obj = KeyBinderDummy()

        # Defined sideeffect for the key bind operation
        def side_effect(key, dispatcher, dispatcher_params):
            keybinding_obj.bind(key, dispatcher, dispatcher_params)
        mock_my_method.side_effect = side_effect

        # Monkey patch
        azulejo_screen.AzulejoScreen = SingleTestScreenMock

        # Import and run the code under test
        import azulejo
        azulejo.run(True)

        # Trigger a keypress
        keybinding_obj.action_key('<Super>1')

        self.assertEqual(
            keybinding_obj.get_screen().get_active_window()['geometry'],
            [0, 0, 1000, 1000]
        )
        

class KeyBinderDummy:
    """ Class this is used to allow keybindings to be caught and to be actioned """

    def __init__(self):
    
        self.bindings = []
        self.saved_obj = None


    def bind(self, action, dispatcher, dispatcher_params):
        """ Bind a key press """

{'fraction_non_alphanumeric': 0.08977512297962052, 'fraction_numerical': 0.019852424455375967, 'mean_word_length': 1.710952380952381, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '72299', 'n_tokens_mistral': 1696, 'n_tokens_neox': 1531, 'n_words': 366}