PipelineTests   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A fileWithLocationAndParents() 0 6 1
A setUp() 0 2 1
A test_asFilenameTree() 0 10 1
A test_Determines_roots_on_creation() 0 9 1
1
import os
2
from mock import Mock, patch, call
3
from tests.ditest import DependencyInjectionTestBase
4
5
6
class PipelineTests(DependencyInjectionTestBase):
7
8
    def setUp(self):
9
        super(PipelineTests, self).setUp()
10
11
    def test_asFilenameTree(self):
12
        from niprov.pipeline import Pipeline
13
        a = self.fileWithLocationAndParents('a:/p/a.f',[])
14
        b = self.fileWithLocationAndParents('a:/p/c.f',['a:/p/a.f'])
15
        c = self.fileWithLocationAndParents('b:/c/d/d.f',['a:/p/a.f'])
16
        d = self.fileWithLocationAndParents('b:/c/d/e.f',['a:/p/c.f'])
17
        pipelineFiles = [a,b,c,d]
18
        pipeline = Pipeline(pipelineFiles)
19
        tree = pipeline.asFilenameTree()
20
        self.assertEqual({'a.f':{'c.f':{'e.f':{}},'d.f':{}}}, tree)
21
22
    def test_Determines_roots_on_creation(self):
23
        from niprov.pipeline import Pipeline
24
        b = self.fileWithLocationAndParents('b',['r1','a'])
25
        r1 = self.fileWithLocationAndParents('r1',[])
26
        a = self.fileWithLocationAndParents('a',['r2'])
27
        r2 = self.fileWithLocationAndParents('r2',[])
28
        pipelineFiles = [a,b,r1,r2]
29
        pipeline = Pipeline(pipelineFiles)
30
        self.assertEqual(set([r1,r2]), pipeline.roots)
31
32
    def fileWithLocationAndParents(self, loc, parents):
33
        f = Mock()
34
        f.location.toString.return_value = loc
35
        f.provenance = {'parents':parents}
36
        f.parents = parents
37
        return f
38
39
40
41