コード例 #1
0
def test_complete_dictionary_subcmd():
    sot = complete.CompleteDictionary()
    sot.add_command("image delete".split(), [mock.Mock(option_strings=["1"])])
    sot.add_command("image list".split(), [mock.Mock(option_strings=["2"])])
    sot.add_command("image list better".split(),
                    [mock.Mock(option_strings=["3"])])
    assert "image" == sot.get_commands()
    result = sot.get_data()
    assert "image" == result[0][0]
    assert "delete list list_better" == result[0][1]
    assert "image_delete" == result[1][0]
    assert "1" == result[1][1]
    assert "image_list" == result[2][0]
    assert "2 better" == result[2][1]
    assert "image_list_better" == result[3][0]
    assert "3" == result[3][1]
コード例 #2
0
 def test_complete_dictionary_subcmd(self):
     sot = complete.CompleteDictionary()
     sot.add_command("image delete".split(),
                     [mock.Mock(option_strings=["1"])])
     sot.add_command("image list".split(),
                     [mock.Mock(option_strings=["2"])])
     sot.add_command("image list better".split(),
                     [mock.Mock(option_strings=["3"])])
     self.assertEqual("image", sot.get_commands())
     result = sot.get_data()
     self.assertEqual("image", result[0][0])
     self.assertEqual("delete list list_better", result[0][1])
     self.assertEqual("image_delete", result[1][0])
     self.assertEqual("1", result[1][1])
     self.assertEqual("image_list", result[2][0])
     self.assertEqual("2 better", result[2][1])
     self.assertEqual("image_list_better", result[3][0])
     self.assertEqual("3", result[3][1])
コード例 #3
0
def test_complete_dictionary():
    sot = complete.CompleteDictionary()
    sot.add_command("image delete".split(), [mock.Mock(option_strings=["1"])])
    sot.add_command("image list".split(), [mock.Mock(option_strings=["2"])])
    sot.add_command("image create".split(), [mock.Mock(option_strings=["3"])])
    sot.add_command("volume type create".split(),
                    [mock.Mock(option_strings=["4"])])
    sot.add_command("volume type delete".split(),
                    [mock.Mock(option_strings=["5"])])
    assert "image volume" == sot.get_commands()
    result = sot.get_data()
    assert "image" == result[0][0]
    assert "create delete list" == result[0][1]
    assert "image_create" == result[1][0]
    assert "3" == result[1][1]
    assert "image_delete" == result[2][0]
    assert "1" == result[2][1]
    assert "image_list" == result[3][0]
    assert "2" == result[3][1]
コード例 #4
0
 def test_dictionary(self):
     sot = complete.CompleteDictionary()
     sot.add_command("image delete".split(),
                     [mock.Mock(option_strings=["1"])])
     sot.add_command("image list".split(),
                     [mock.Mock(option_strings=["2"])])
     sot.add_command("image create".split(),
                     [mock.Mock(option_strings=["3"])])
     sot.add_command("volume type create".split(),
                     [mock.Mock(option_strings=["4"])])
     sot.add_command("volume type delete".split(),
                     [mock.Mock(option_strings=["5"])])
     self.assertEqual("image volume", sot.get_commands())
     result = sot.get_data()
     self.assertEqual("image", result[0][0])
     self.assertEqual("create delete list", result[0][1])
     self.assertEqual("image_create", result[1][0])
     self.assertEqual("3", result[1][1])
     self.assertEqual("image_delete", result[2][0])
     self.assertEqual("1", result[2][1])
     self.assertEqual("image_list", result[3][0])
     self.assertEqual("2", result[3][1])