1
|
|
|
# Copyright 2017 Starbot Discord Project |
2
|
|
|
# |
3
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
4
|
|
|
# you may not use this file except in compliance with the License. |
5
|
|
|
# You may obtain a copy of the License at |
6
|
|
|
# |
7
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0 |
8
|
|
|
# |
9
|
|
|
# Unless required by applicable law or agreed to in writing, software |
10
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, |
11
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12
|
|
|
# See the License for the specific language governing permissions and |
13
|
|
|
# limitations under the License. |
14
|
|
|
|
15
|
|
|
import unittest |
16
|
|
|
|
17
|
|
|
from api import command, plugin |
18
|
|
|
|
19
|
|
|
|
20
|
|
|
class TestCommandSuite(unittest.TestCase): |
21
|
|
|
|
22
|
|
|
def test_plugin_basic_args(self): |
23
|
|
|
cmd_test = command.Command(unittest, 'TestCommand') |
24
|
|
|
plugin_test = plugin.Plugin(unittest, 'TestPlugin', [cmd_test]) |
25
|
|
|
self.assertEqual(plugin_test.plugin, unittest) |
26
|
|
|
self.assertEqual(plugin_test.name, 'TestPlugin') |
27
|
|
|
self.assertEqual(plugin_test.commands, [cmd_test]) |
28
|
|
|
|
29
|
|
|
def test_plugin_overwrite(self): |
30
|
|
|
cmd_test = command.Command(unittest, 'TestCommand') |
31
|
|
|
plugin_test = plugin.Plugin(unittest, 'TestPlugin', [cmd_test]) |
32
|
|
|
self.assertEqual(plugin_test.plugin, unittest) |
33
|
|
|
self.assertEqual(plugin_test.name, 'TestPlugin') |
34
|
|
|
self.assertEqual(plugin_test.commands, [cmd_test]) |
35
|
|
|
|
36
|
|
|
cmd_test2 = command.Command(unittest, 'TestCommand', shortdesc='Description!') |
37
|
|
|
plugin_test = plugin.Plugin(unittest, 'TestPlugin', [cmd_test2]) |
38
|
|
|
self.assertEqual(plugin_test.plugin, unittest) |
39
|
|
|
self.assertEqual(plugin_test.name, 'TestPlugin') |
40
|
|
|
self.assertEqual(plugin_test.commands, [cmd_test2]) |
41
|
|
|
self.assertEqual(plugin_test.commands[0].shortdesc, 'Description!') |
42
|
|
|
|