Example #1
0
    def test_hotel_contract_creation_success(self, mock_raw_input, mock_write,
                                             mock_api):
        """ Test a basic hotel creation workflow """
        # Build the expected output
        expected_lines = ConsoleRunUnitTest.get_banner_lines()
        expected_lines.append('Hotel Information:')
        expected_lines.append(
            'Hotel Contract Created: 0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae'
        )
        expected_lines.extend(ConsoleRunUnitTest.get_bye_lines())

        # Build the expected prompts
        expected_prompts = []
        expected_prompts.append('WT>')
        expected_prompts.append('WT hotel>')
        expected_prompts.append('Hotel Name? ')
        expected_prompts.append('Hotel Description? ')
        expected_prompts.append(
            'Gas fee: 0.05wei, deploy on blockchain (yes/no)? ')
        expected_prompts.append('WT hotel>')
        expected_prompts.append('WT>')

        # Run the console
        my_console = Console()
        my_console.run()

        # Use the console check tool
        ConsoleRunUnitTest.check_console_sequence(self, expected_lines,
                                                  expected_prompts, mock_write,
                                                  mock_raw_input)
Example #2
0
 def test_init_override_server_ip(self):
     """ Initialize with remote host using DNS Name """
     args = {}
     args = {'host': '127.0.0.1', 'port': 98765}
     console = Console(args)
     self.assertEqual(console.server_host, '127.0.0.1')
     self.assertEqual(console.server_port, 98765)
Example #3
0
    def test_enter_exit(self, mock_raw_input, mock_write):
        """ We can enter and exit using the exit command """
        # Build the expected output
        expected_lines = ConsoleRunUnitTest.get_banner_lines()
        expected_lines.extend(ConsoleRunUnitTest.get_bye_lines())

        # Build the expected prompts
        expected_prompts = []
        expected_prompts.append('WT>')

        # Run the console
        my_console = Console()
        my_console.run()

        # Use the console check tool
        ConsoleRunUnitTest.check_console_sequence(self, expected_lines,
                                                  expected_prompts, mock_write,
                                                  mock_raw_input)
Example #4
0
    def test_keyboard_interrupt(self, mock_raw_input, mock_write):
        """ A keyboard interrupt should exit nicely """
        # Build the expected output
        expected_lines = ConsoleRunUnitTest.get_banner_lines()
        expected_lines.append('')
        expected_lines.extend(ConsoleRunUnitTest.get_bye_lines())

        # Build the expected prompts
        expected_prompts = []
        expected_prompts.append('WT>')

        # Run the console
        my_console = Console()
        my_console.run()

        # Use the console check tool
        ConsoleRunUnitTest.check_console_sequence(self, expected_lines,
                                                  expected_prompts, mock_write,
                                                  mock_raw_input)
Example #5
0
 def test_init_override_server_name(self):
     """ Initialize with remote host using DNS Name """
     args = {'host': 'wt.example.net', 'port': 12345}
     console = Console(args)
     self.assertEqual(console.server_host, 'wt.example.net')
     self.assertEqual(console.server_port, 12345)
Example #6
0
 def test_init_no_arguments(self):
     """ Test a basic initialization """
     console = Console()
     self.assertEqual(console.server_host, 'localhost')
     self.assertEqual(console.server_port, 8456)
Example #7
0
"""
Define the startup script
"""
from client.console import Console

if __name__ == "__main__":
    Console().run()