Completed
Push — stable ( ce9d65...6568cb )
by Sydney
02:01 queued 01:19
created

TestFunSuite.testCalcValidEqu()   A

Complexity

Conditions 1

Size

Total Lines 6

Duplication

Lines 6
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 6
loc 6
rs 9.4285
cc 1
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 View Code Duplication
#    You may obtain a copy of the License at
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
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 calc
18
19
import asyncio
20
21
class TestCalcSuite(unittest.TestCase):
22
23
    def test_calc_import(self):
24
        result = calc.onInit(__import__('api.plugin'))
25
        self.assertEqual(type(result), plugin.Plugin)
26
27
    def test_calc_empty_equ(self):
28
        msg = message.Message(body="")
29
        msg.command = "calc"
30
        result = yield from calc.onCommand(msg)
31
        self.assertEqual(type(result), type(msg))
32
33
    def test_calc_inval_equ(self):
34
        msg = message.Message(body="banana")
35
        msg.command = "calc"
36
        result = yield from calc.onCommand(msg)
37
        self.assertEqual(type(result), type(msg))
38
39
    def test_calc_valid_equ(self):
40
        msg = message.Message(body="3+4")
41
        msg.command = "calc"
42
        result = yield from calc.onCommand(msg)
43
        self.assertEqual(type(result), type(msg))
44
        self.assertEqual(result.body, "`3+4` = `7.0`")