~tribaal/charms/trusty/sane-storage/trunk

« back to all changes in this revision

Viewing changes to hooks/tests/test_providers_common.py

  • Committer: Christopher Glass
  • Date: 2014-11-14 08:41:27 UTC
  • Revision ID: christopher.glass@canonical.com-20141114084127-0ijv0xh8btj6ekah
Fixed rogue __init__ file (the hooks directory should not be a python package).

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
import shutil
5
5
 
6
6
from mock import patch
7
 
from hooks.providers_common import BaseProvider, MOUNTPOINT_DATA_FILE
 
7
from providers_common import BaseProvider, MOUNTPOINT_DATA_FILE
8
8
 
9
9
 
10
10
class BaseProviderTestCase(unittest.TestCase):
15
15
        result = base.install()
16
16
        self.assertIsNone(result)
17
17
 
18
 
    @patch("hooks.charmhelpers.core.hookenv.relation_ids")
 
18
    @patch("charmhelpers.core.hookenv.relation_ids")
19
19
    @patch("os.makedirs")
20
 
    @patch("hooks.charmhelpers.core.hookenv.relation_set")
21
 
    @patch("hooks.charmhelpers.core.hookenv.log")
22
 
    @patch("hooks.charmhelpers.core.hookenv.relation_get")
 
20
    @patch("charmhelpers.core.hookenv.relation_set")
 
21
    @patch("charmhelpers.core.hookenv.log")
 
22
    @patch("charmhelpers.core.hookenv.relation_get")
23
23
    def test_data_relation_changed(self, mock_relation_get, mock_log,
24
24
                                   mock_relation_set, mock_makedirs,
25
25
                                   mock_relation_ids):
34
34
 
35
35
        base.data_relation_changed()
36
36
 
37
 
    @patch("hooks.charmhelpers.core.hookenv.relation_ids")
 
37
    @patch("charmhelpers.core.hookenv.relation_ids")
38
38
    @patch("os.makedirs")
39
 
    @patch("hooks.charmhelpers.core.hookenv.relation_set")
40
 
    @patch("hooks.charmhelpers.core.hookenv.log")
41
 
    @patch("hooks.charmhelpers.core.hookenv.relation_get")
 
39
    @patch("charmhelpers.core.hookenv.relation_set")
 
40
    @patch("charmhelpers.core.hookenv.log")
 
41
    @patch("charmhelpers.core.hookenv.relation_get")
42
42
    def test_data_relation_changed_raises_nontimplemented(
43
43
            self, mock_relation_get, mock_log, mock_relation_set,
44
44
            mock_makedirs, mock_relation_ids):
51
51
        with self.assertRaises(Exception):
52
52
            base.data_relation_changed()
53
53
 
54
 
    @patch("hooks.charmhelpers.core.hookenv.charm_dir")
 
54
    @patch("charmhelpers.core.hookenv.charm_dir")
55
55
    def test_persist_mountpoint(self, mock_charm_dir):
56
56
        tmp_dir =  tempfile.mkdtemp()
57
57
        mock_charm_dir.return_value = tmp_dir
69
69
        self.assertEqual(mountpoint, contents)
70
70
        shutil.rmtree(tmp_dir)  # Don't leak test files
71
71
 
72
 
    @patch("hooks.charmhelpers.core.hookenv.charm_dir")
 
72
    @patch("charmhelpers.core.hookenv.charm_dir")
73
73
    def test_get_persisted_mountpoint(self, mock_charm_dir):
74
74
        tmp_dir =  tempfile.mkdtemp()
75
75
        mock_charm_dir.return_value = tmp_dir
86
86
        self.assertEqual(mountpoint, result)
87
87
        shutil.rmtree(tmp_dir)  # Don't leak test files
88
88
 
89
 
    @patch("hooks.charmhelpers.core.hookenv.charm_dir")
 
89
    @patch("charmhelpers.core.hookenv.charm_dir")
90
90
    def test_persisting_mountpoint_is_reversible(self, mock_charm_dir):
91
91
        tmp_dir =  tempfile.mkdtemp()
92
92
        mock_charm_dir.return_value = tmp_dir