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