<s> import unittest <EOL> from . mock import MagicMock , Mock <EOL> from . util import TrelloElementMock , CommandMock , OperationMock <EOL> from operations import * <EOL> class BaseOperationTests ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . base_operation , self . trello_element = OperationMock . create ( BaseOperation ) <EOL> self . class_mock , self . instance_mock = OperationMock . instance ( self . base_operation ) <EOL> self . collection = TrelloElementMock . collection ( ) <EOL> self . base_operation . collection = TrelloCollection ( self . collection ) <EOL> def test_items_sets_the_collection ( self ) : <EOL> self . base_operation . set_collection = MagicMock ( ) <EOL> self . base_operation . items ( ) <EOL> self . base_operation . set_collection . assert_called_with ( ) <EOL> def test_items_returns_every_name_from_the_collection_with_the_added_options ( self ) : <EOL> self . base_operation . set_collection = MagicMock ( ) <EOL> self . assertEqual ( self . base_operation . items ( ) , [ "<STR_LIT:..>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> def test_callback_uses_find_to_instantiate_the_operation_if_the_index_is_in_the_collection ( self ) : <EOL> self . base_operation . callback ( <NUM_LIT:3> ) <EOL> self . class_mock . assert_called_with ( self . collection [ <NUM_LIT:0> ] , self . base_operation ) <EOL> def test_callback_calls_execute_on_the_operation ( self ) : <EOL> self . base_operation . callback ( <NUM_LIT:3> ) <EOL> self . instance_mock . execute . assert_called_with ( self . base_operation . command ) <EOL> def test_callback_doesnt_call_find_if_the_index_is_bigger_than_the_collection_length ( self ) : <EOL> big_index = <NUM_LIT> <EOL> self . base_operation . callback ( big_index ) <EOL> assert not self . class_mock . called <EOL> def test_callback_calls_execute_on_the_previous_operation_if_index_is_0 ( self ) : <EOL> self . base_operation . callback ( <NUM_LIT:0> ) <EOL> self . base_operation . previous_operation . execute . assert_called_with ( ) <EOL> def test_callback_calls_the_input_method_on_the_command_with_deferred_add_as_callback_if_index_is_1 ( self ) : <EOL> self . base_operation . command . input = MagicMock ( ) <EOL> self . base_operation . callback ( <NUM_LIT:2> ) <EOL> self . base_operation . command . input . assert_called_with ( "<STR_LIT:Name>" , self . base_operation . deferred_add ) <EOL> def test_base_add_calls_add_with_the_text_and_cleans_the_cache_for_the_element ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . base_operation . add = MagicMock ( ) <EOL> self . base_operation . trello_element . reload = MagicMock ( ) <EOL> self . base_operation . base_add ( text ) <EOL> self . base_operation . add . assert_called_with ( text ) <EOL> self . trello_element . reload . assert_called_with ( ) <EOL> def test_base_add_calls_add_and_execute_if_renavigate_is_true ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . base_operation . command . renavigate = True <EOL> self . base_operation . execute = MagicMock ( ) <EOL> self . base_operation . base_add ( text ) <EOL> self . base_operation . execute . assert_called_with ( ) <EOL> class BoardOperationTests ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . operation , self . trello_element = OperationMock . create ( BoardOperation ) <EOL> self . operation . collection = TrelloCollection ( TrelloElementMock . collection ( ) ) <EOL> def test_items_returns_every_name_from_the_collection_without_goback ( self ) : <EOL> self . operation . set_collection = MagicMock ( ) <EOL> self . assertEqual ( self . operation . items ( ) , [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> def test_trello_element_property ( self ) : <EOL> self . assertEqual ( self . operation . trello_element_property ( ) , "<STR_LIT>" ) <EOL> def test_callback_calls_execute_command_with_the_index ( self ) : <EOL> self . operation . execute_command = MagicMock ( ) <EOL> self . operation . callback ( <NUM_LIT:5> ) <EOL> self . operation . execute_command . assert_called_with ( <NUM_LIT:3> ) <EOL> def test_callback_calls_the_input_method_on_the_command_with_deferred_add_as_callback_if_index_is_1 ( self ) : <EOL> self . operation . command . input = MagicMock ( ) <EOL> self . operation . callback ( <NUM_LIT:1> ) <EOL> self . operation . command . input . assert_called_with ( "<STR_LIT:Name>" , self . operation . deferred_add ) <EOL> def test_next_operation_class ( self ) : <EOL> self . assertEqual ( self . operation . next_operation_class ( ) , ListOperation ) <EOL> def test_add_creates_a_board_with_the_text ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . trello_element . add_board = MagicMock ( ) <EOL> self . operation . add ( text ) <EOL> self . trello_element . add_board . assert_called_with ( text ) <EOL> class ListOperationTests ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . operation , self . trello_element = OperationMock . create ( ListOperation ) <EOL> def test_trello_element_property ( self ) : <EOL> self . assertEqual ( self . operation . trello_element_property ( ) , "<STR_LIT>" ) <EOL> def test_next_operation_class ( self ) : <EOL> self . assertEqual ( self . operation . next_operation_class ( ) , CardOperation ) <EOL> def test_add_creates_a_list_with_the_text ( self ) : <EOL> text = "<STR_LIT>" <EOL> self . trello_element . add_list = MagicMock ( ) <EOL> self . operation . add ( text ) <EOL> self . trello_element . add_list . assert_called_with ( text ) <EOL> class CardOperationTests ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . operation , self . trello_element = OperationMock . create ( CardOperation ) <EOL> def test_items_returns_every_name_from_the_collection_with_custom_actions ( self ) : <EOL> self . operation . set_collection = MagicMock ( ) <EOL> self . operation . collection = TrelloCollection ( TrelloElementMock . collection ( ) ) <EOL> self . assertEqual ( self . operation . items ( ) , [ '<STR_LIT:..>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> def test_trello_element_property ( self ) : <EOL> self . assertEqual ( self . operation . trello_element_property ( ) , "<STR_LIT>" ) <EOL> def test_next_operation_class ( self ) : <EOL> self . assertEqual ( self . operation . next_operation_class ( ) , CardOptions ) <EOL> def test_add_creates_a_card_with_the_text_and_description ( self ) : <EOL> name = "<STR_LIT>" <EOL> desc = "<STR_LIT>" <EOL> self . trello_element . add_card = MagicMock ( ) <EOL> self . operation . add ( name , desc ) <EOL> self . trello_element . add_card . assert_called_with ( name , desc ) <EOL> def test_split_card_contents_returns_the_name_and_description_splitted_by_new_lines ( self ) : <EOL> content = "<STR_LIT>" <EOL> name , desc = self . operation . split_card_contents ( content ) <EOL> self . assertEqual ( name , "<STR_LIT>" ) <EOL> self . assertEqual ( desc , "<STR_LIT>" ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
