Completed
Pull Request — master (#127)
by Jasper
01:07
created

tests.SimpleFormatTests   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %
Metric Value
dl 0
loc 33
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A SimpleFormatTests.test_Statistics() 0 6 1
A SimpleFormatTests.aFile() 0 4 1
A SimpleFormatTests.test_Pipeline() 0 13 1
A SimpleFormatTests.test_SerializeSingle() 0 5 1
1
from unittest import TestCase
2
from mock import Mock, sentinel, patch
3
4
5
class SimpleFormatTests(TestCase):
6
7
    def test_Statistics(self):
8
        from niprov.formatsimple import SimpleFormat
9
        exporter = SimpleFormat()
10
        out = exporter.serializeStatistics({'count':123,'totalsize':678})
11
        self.assertIn(' Number of files: 123', out)
12
        self.assertIn(' Total file size: 678', out)
13
14
    def test_Pipeline(self):
15
        from niprov.formatsimple import SimpleFormat
16
        pipeline = Mock()
17
        tree = {'raw.f':{'1a.f':{'2.f':{}},'1b.f':{}}}
18
        exp = ''
19
        exp += '+---raw.f\n'
20
        exp += '|   +---1a.f\n'
21
        exp += '|   |   +---2.f\n'
22
        exp += '|   +---1b.f\n'
23
        pipeline.asFilenameTree.return_value = tree
24
        exporter = SimpleFormat()
25
        out = exporter.serializePipeline(pipeline)
26
        self.assertEqual(exp, out)
27
28
    def test_SerializeSingle(self):
29
        from niprov.formatsimple import SimpleFormat
30
        exporter = SimpleFormat()
31
        out = exporter.serializeSingle(self.aFile())
32
        self.assertIn('a:                       b\n', out)
33
34
    def aFile(self):
35
        somefile = Mock()
36
        somefile.provenance = {'a':'b'}
37
        return somefile
38
39