53
53
def test_remote_from_unit(self):
54
54
env = JujuData("an-env", {"type": "nonlocal"})
55
55
client = EnvJujuClient(env, None, None)
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)
59
59
remote = remote_from_unit(client, unit)
62
"<SSHRemote env='an-env' unit='a-application/0'>")
62
"<SSHRemote env='an-env' unit='a-service/0'>")
63
63
self.assertIs(False, remote.is_windows())
65
65
def test_remote_from_unit_with_series(self):
66
66
env = JujuData("an-env", {"type": "nonlocal"})
67
67
client = EnvJujuClient(env, None, None)
68
unit = "a-application/0"
69
69
remote = remote_from_unit(client, unit, series="trusty")
72
"<SSHRemote env='an-env' unit='a-application/0'>")
72
"<SSHRemote env='an-env' unit='a-service/0'>")
73
73
self.assertIs(False, remote.is_windows())
75
75
def test_remote_from_unit_with_status(self):
76
76
env = JujuData("an-env", {"type": "nonlocal"})
77
77
client = EnvJujuClient(env, None, None)
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)
83
"<WinRmRemote env='an-env' unit='a-application/0'"
84
" addr='10.55.60.2'>")
83
"<WinRmRemote env='an-env' unit='a-service/0' addr='10.55.60.2'>")
85
84
self.assertIs(True, remote.is_windows())
87
86
def test_remote_from_address(self):
102
101
def test_run_with_unit(self):
103
102
env = JujuData("an-env", {"type": "nonlocal"})
104
103
client = EnvJujuClient(env, None, None)
105
unit = "a-application/0"
106
105
remote = remote_from_unit(client, unit, series="trusty")
107
106
with patch.object(client, "get_juju_output") as mock_cmd:
108
107
mock_cmd.return_value = "contents of /a/file"
114
113
def test_run_with_unit_fallback(self):
115
114
env = JujuData("an-env", {"type": "nonlocal"})
116
115
client = EnvJujuClient(env, None, None)
117
unit = "a-application/0"
118
117
with patch.object(client, "get_status") as st:
119
118
st.return_value = Status.from_text(self.precise_status_output)
120
119
remote = remote_from_unit(client, unit)
139
138
self.assertRegexpMatches(
140
139
self.log_stream.getvalue(),
141
"(?m)^WARNING juju ssh to 'a-application/0' failed, .*")
140
"(?m)^WARNING juju ssh to 'a-service/0' failed, .*")
143
142
def test_run_with_address(self):
144
143
remote = remote_from_address("10.55.60.1")
173
172
def test_cat_on_windows(self):
174
173
env = JujuData("an-env", {"type": "nonlocal"})
175
174
client = EnvJujuClient(env, None, None)
176
unit = "a-application/0"
177
176
with patch.object(client, "get_status", autospec=True) as st:
178
177
st.return_value = Status.from_text(self.win2012hvr2_status_output)
179
178
response = winrm.Response(("contents of /a/file", "", 0))
205
204
def test_copy_on_windows(self):
206
205
env = JujuData("an-env", {"type": "nonlocal"})
207
206
client = EnvJujuClient(env, None, None)
208
unit = "a-application/0"
209
208
dest = "/local/path"
210
209
with patch.object(client, "get_status", autospec=True) as st:
211
210
st.return_value = Status.from_text(self.win2012hvr2_status_output)
244
243
def test_run_cmd(self):
245
244
env = JujuData("an-env", {"type": "nonlocal"})
246
245
client = EnvJujuClient(env, None, None)
247
unit = "a-application/0"
248
247
with patch.object(client, "get_status", autospec=True) as st:
249
248
st.return_value = Status.from_text(self.win2012hvr2_status_output)
250
249
response = winrm.Response(("some out", "some err", 0))