def test_embedded_prompt(self): self.cache = None def custom_input(prompt): self.cache = prompt return 37 self.assertEqual(clip.prompt('?', default=42, input_function=custom_input), 37) self.assertEqual(self.cache, '? [42]: ')
def test_embedded_prompt(self): self.cache = None def custom_input(prompt): self.cache = prompt return 37 self.assertEqual( clip.prompt('?', default=42, input_function=custom_input), 37) self.assertEqual(self.cache, '? [42]: ')
def run(): config = LambdaConfig().load_from_cwd() clip.echo(PROMPT) user_input = { 'FunctionName': clip.prompt('Function name: ', skip=True), 'Handler': clip.prompt('Handler: ', skip=True), 'Description': clip.prompt('Description: ', skip=True), 'Runtime': clip.prompt('Runtime', default='nodejs'), 'Timeout': clip.prompt('Timeout: ', type=int, skip=True), 'MemorySize': clip.prompt('Memory size: ', type=int, skip=True) } config.update_config({k: v for k, v in utils.iteritems(user_input) if v}) install_task = clip.prompt('Install task: ', skip=True) if install_task is not None: config.update({'install': install_task}) config.dump_to_cwd()
def run(): config = LambdaConfig().load_from_cwd() clip.echo(PROMPT) user_input = { 'FunctionName': clip.prompt('Function name: ', skip=True), 'Handler': clip.prompt('Handler: ', skip=True), 'Description': clip.prompt('Description: ', skip=True), 'Runtime': clip.prompt('Runtime', default='nodejs'), 'Timeout': clip.prompt('Timeout: ', type=int, skip=True), 'MemorySize': clip.prompt('Memory size: ', type=int, skip=True) } config.update_config({k: v for k, v in utils.iteritems(user_input) if v}) install_task = clip.prompt('Install task: ', skip=True) if install_task is not None: config.update({ 'install': install_task }) config.dump_to_cwd()
def test_prompt(self): # Standard with confirm with mock_clip_input(['7', '7']): self.assertEqual(clip.prompt('?', type=int, confirm=True), 7) # Bad input _, out, _ = self.embed() with mock_clip_input(['', 'hehehe', '42']): self.assertEqual(clip.prompt('?', type=int), 42) self.assertEqual(len(out._writes), 2) # Interrupt def cause_interrupt(): raise KeyboardInterrupt with mock_clip_input(['']): with self.assertRaises(clip.ClipExit): clip.prompt('?', default=cause_interrupt) # Skip with mock_clip_input(['', '']): self.assertIsNone(clip.prompt('?', skip=True)) self.assertIsNone(clip.prompt('?', confirm=True, skip=True))