Code Duplication    Length = 26-28 lines in 2 locations

tests/test_tinyurl.py 1 location

@@ 5-32 (lines=28) @@
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
from api import message, plugin
17
from plugins import tinyurl
18
19
class TestTinyurlSuite(unittest.TestCase):
20
21
    def test_tinyurl_import(self):
22
        result = tinyurl.onInit(__import__('api.plugin'))
23
        self.assertEqual(type(result), plugin.Plugin)
24
25
    def test_tinyurl_valid_url(self):
26
        msg = message.Message(body="https://www.google.com/")
27
        msg.command = "tinyurl"
28
        result = yield from tinyurl.onCommand(msg)
29
        self.assertEqual(type(result), type(msg))
30
        self.assertEqual(result.body, "http://tinyurl.com/cqvga")
31
32
    def test_tinyurl_invalid_url(self):
33
        msg = message.Message(body="test")
34
        msg.command = "tinyurl"
35
        result = yield from tinyurl.onCommand(msg)

tests/test_urbandictionary.py 1 location

@@ 5-30 (lines=26) @@
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
from api import message, plugin
17
from plugins import urbandictionary
18
19
class TestUrbanDictionarySuite(unittest.TestCase):
20
21
    def test_ud_import(self):
22
        result = urbandictionary.onInit(__import__('api.plugin'))
23
        self.assertEqual(type(result), plugin.Plugin)
24
25
    def test_ud_define(self):
26
        empty_list = []
27
        msg = message.Message(body="test")
28
        msg.command = "define"
29
        result = yield from urbandictionary.onCommand(msg)
30
        self.assertEqual(type(result), type(empty_list))
31
32
    def test_ud_define_empty(self):
33
        msg = message.Message(body="")