예제 #1
0
    def test_arrayenumreader_ends_with_comma(self, prompt_mock):
        spec = {
            "items": {"enum": ["a", "b", "c", "d", "e"]},
            "description": "some description",
            "default": ["a", "b"],
        }
        Reader = interactive.ArrayEnumReader("some", spec)

        prompt_mock.return_value = "0,2,4,"
        result = Reader.read()

        self.assertEqual(result, ["a", "c", "e"])
        message = "some: \n 0 - a\n 1 - b\n 2 - c\n 3 - d\n 4 - e\nChoose from 0, 1, 2... [0, 1]: "
        self.assertPromptMessage(prompt_mock, message)
        self.assertPromptDescription(prompt_mock, "some description")
        self.assertPromptValidate(prompt_mock, "0,2,4,")
예제 #2
0
    def test_arrayenumreader_ends_with_comma(self, prompt_mock):
        spec = {
            'items': {
                'enum': ['a', 'b', 'c', 'd', 'e']
            },
            'description': 'some description',
            'default': ['a', 'b']
        }
        Reader = interactive.ArrayEnumReader('some', spec)

        prompt_mock.return_value = '0,2,4,'
        result = Reader.read()

        self.assertEqual(result, ['a', 'c', 'e'])
        message = 'some: \n 0 - a\n 1 - b\n 2 - c\n 3 - d\n 4 - e\nChoose from 0, 1, 2... [0, 1]: '
        self.assertPromptMessage(prompt_mock, message)
        self.assertPromptDescription(prompt_mock, 'some description')
        self.assertPromptValidate(prompt_mock, '0,2,4,')