UtilitiesTestCase   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
dl 0
loc 10
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A test_nearest_after_last() 0 2 1
A test_nearest_before_first() 0 2 1
A test_nearest_in_the_middle() 0 3 1
1
# coding: utf8
2
3
# Copyright 2013-2018 Vincent Jacques <[email protected]>
4
5
from __future__ import division, absolute_import, print_function
6
7
import unittest
8
9
from ActionTree import *
10
from . import *
11
12
13
class UtilitiesTestCase(unittest.TestCase):
14
    def test_nearest_before_first(self):
15
        self.assertEqual(GanttChart._GanttChart__nearest(2, [10, 20, 30]), 10)
16
17
    def test_nearest_after_last(self):
18
        self.assertEqual(GanttChart._GanttChart__nearest(35, [10, 20, 30]), 30)
19
20
    def test_nearest_in_the_middle(self):
21
        self.assertEqual(GanttChart._GanttChart__nearest(18, [10, 20, 30]), 20)
22
        self.assertEqual(GanttChart._GanttChart__nearest(22, [10, 20, 30]), 20)
23
24
25
class GanttChartTestCase(ActionTreeTestCase):
26
    def test(self):
27
        a = self._action("a")
28
        b = self._action("b")
29
        c = self._action("c")
30
        c.add_dependency(a)
31
        c.add_dependency(b)
32
33
        chart = GanttChart(execute(c, cpu_cores=2))
34
        ax = unittest.mock.Mock()
35
        chart.plot_on_mpl_axes(ax)
36