~ankatare/juju-ci-tools/juju-aws-add-credential

« back to all changes in this revision

Viewing changes to tests/test_remote.py

  • Committer: ankatare at hotmail
  • Date: 2017-01-31 03:53:09 UTC
  • mfrom: (1837.1.30 trunk)
  • Revision ID: ankatare@hotmail.com-20170131035309-8dmn8d86opr9yorl
merge trunck

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
import winrm
9
9
 
10
10
from jujupy import (
11
 
    EnvJujuClient,
12
 
    get_timeout_path,
 
11
    ModelClient,
13
12
    JujuData,
14
13
    Status,
15
14
)
20
19
)
21
20
import tests
22
21
from utility import (
 
22
    get_timeout_path,
23
23
    temp_dir,
24
24
)
25
25
 
52
52
 
53
53
    def test_remote_from_unit(self):
54
54
        env = JujuData("an-env", {"type": "nonlocal"})
55
 
        client = EnvJujuClient(env, None, None)
 
55
        client = ModelClient(env, None, None)
56
56
        unit = "a-application/0"
57
57
        with patch.object(client, "get_status", autospec=True) as st:
58
58
            st.return_value = Status.from_text(self.precise_status_output)
64
64
 
65
65
    def test_remote_from_unit_with_series(self):
66
66
        env = JujuData("an-env", {"type": "nonlocal"})
67
 
        client = EnvJujuClient(env, None, None)
 
67
        client = ModelClient(env, None, None)
68
68
        unit = "a-application/0"
69
69
        remote = remote_from_unit(client, unit, series="trusty")
70
70
        self.assertEqual(
74
74
 
75
75
    def test_remote_from_unit_with_status(self):
76
76
        env = JujuData("an-env", {"type": "nonlocal"})
77
 
        client = EnvJujuClient(env, None, None)
 
77
        client = ModelClient(env, None, None)
78
78
        unit = "a-application/0"
79
79
        status = Status.from_text(self.win2012hvr2_status_output)
80
80
        remote = remote_from_unit(client, unit, status=status)
101
101
 
102
102
    def test_run_with_unit(self):
103
103
        env = JujuData("an-env", {"type": "nonlocal"})
104
 
        client = EnvJujuClient(env, None, None)
 
104
        client = ModelClient(env, None, None)
105
105
        unit = "a-application/0"
106
106
        remote = remote_from_unit(client, unit, series="trusty")
107
107
        with patch.object(client, "get_juju_output") as mock_cmd:
113
113
 
114
114
    def test_run_with_unit_fallback(self):
115
115
        env = JujuData("an-env", {"type": "nonlocal"})
116
 
        client = EnvJujuClient(env, None, None)
 
116
        client = ModelClient(env, None, None)
117
117
        unit = "a-application/0"
118
118
        with patch.object(client, "get_status") as st:
119
119
            st.return_value = Status.from_text(self.precise_status_output)
142
142
 
143
143
    def test_run_default_command_error_fallback(self):
144
144
        env = JujuData("an-env", {"type": "nonlocal"})
145
 
        client = EnvJujuClient(env, None, None)
 
145
        client = ModelClient(env, None, None)
146
146
        unit = "a-application/0"
147
147
        error = subprocess.CalledProcessError(1, "ssh", output="bad command")
148
148
        with patch.object(client, "get_status") as st:
161
161
 
162
162
    def test_run_no_platform_fallback(self):
163
163
        env = JujuData("an-env", {"type": "nonlocal"})
164
 
        client = EnvJujuClient(env, None, None)
 
164
        client = ModelClient(env, None, None)
165
165
        unit = "a-application/0"
166
166
        error = subprocess.CalledProcessError(255, "ssh", output="")
167
167
        with patch.object(client, "get_status") as st:
213
213
 
214
214
    def test_cat_on_windows(self):
215
215
        env = JujuData("an-env", {"type": "nonlocal"})
216
 
        client = EnvJujuClient(env, None, None)
 
216
        client = ModelClient(env, None, None)
217
217
        unit = "a-application/0"
218
218
        with patch.object(client, "get_status", autospec=True) as st:
219
219
            st.return_value = Status.from_text(self.win2012hvr2_status_output)
245
245
 
246
246
    def test_copy_on_windows(self):
247
247
        env = JujuData("an-env", {"type": "nonlocal"})
248
 
        client = EnvJujuClient(env, None, None)
 
248
        client = ModelClient(env, None, None)
249
249
        unit = "a-application/0"
250
250
        dest = "/local/path"
251
251
        with patch.object(client, "get_status", autospec=True) as st:
284
284
 
285
285
    def test_run_cmd(self):
286
286
        env = JujuData("an-env", {"type": "nonlocal"})
287
 
        client = EnvJujuClient(env, None, None)
 
287
        client = ModelClient(env, None, None)
288
288
        unit = "a-application/0"
289
289
        with patch.object(client, "get_status", autospec=True) as st:
290
290
            st.return_value = Status.from_text(self.win2012hvr2_status_output)