Completed
Push — master ( 52f46a...fb72da )
by Jasper
10s
created

ContextTests.test_record()   A

Complexity

Conditions 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
1
import unittest
2
from mock import Mock, patch
3
from tests.ditest import DependencyInjectionTestBase
4
5
6
class ContextTests(DependencyInjectionTestBase):
7
8
    def setUp(self):
9
        super(ContextTests, self).setUp()
10
        patcher = patch('niprov.context.niprov')
11
        self.niprov = patcher.start()
12
        self.addCleanup(patcher.stop)
13
        from niprov import ProvenanceContext
14
        self.context = ProvenanceContext()
15
        self.context.deps = self.dependencies
16
17
    def test_get(self):
18
        self.assertEqual(self.context.get(), self.query)
19
20
    def test_add(self):
21
        self.context.add('file.p', True, {'c':3})
22
        self.niprov.adding.add.assert_called_with('file.p', True, {'c':3},
23
            self.dependencies)
24
25
    def test_log(self):
26
        self.context.log('new', 'trf', 'parents', 'code', 'logtext', False,
27
            'script', 'user', {'prov':1}, 'opts')
28
        self.niprov.logging.log.assert_called_with('new', 'trf', 'parents', 
29
            'code', 'logtext', False, 'script', 'user', {'prov':1}, 'opts',
30
            self.dependencies)
31
32
    def test_backup(self):
33
        self.context.backup()
34
        self.niprov.exporting.backup.assert_called_with(self.dependencies)
35
36
    def test_export(self):
37
        self.context.export('prov', 'medium', 'form')
38
        self.niprov.exporting.export.assert_called_with('prov', 'medium',
39
            'form', False, self.dependencies)
40
41
    def test_import(self):
42
        self.context.importp('fpath')
43
        self.niprov.importing.importp.assert_called_with('fpath',
44
            self.dependencies)
45
46
    def test_print(self):
47
        self.context.print_('images')
48
        self.niprov.exporting.print_.assert_called_with('images', False, 
49
            self.dependencies)
50
51
    def test_record(self):
52
        self.context.record('cmd', 'new', 'parents', True, 'args', 'kwargs', 
53
            'user', 'opts')
54
        self.niprov.recording.record.assert_called_with('cmd', 'new', 
55
            'parents', True, 'args', 'kwargs', 'user', 'opts',
56
            self.dependencies)
57
58
    def test_view(self):
59
        self.context.view('images', pipeline=True)
60
        self.niprov.exporting.view.assert_called_with('images', True, 
61
            self.dependencies)
62
63
64
65