| Adam Israel | dcdf82b | 2017-08-15 15:26:43 -0400 | [diff] [blame] | 1 | """ |
| 2 | Tests for generated client code |
| 3 | |
| 4 | """ |
| 5 | |
| 6 | import mock |
| Adam Israel | dcdf82b | 2017-08-15 15:26:43 -0400 | [diff] [blame] | 7 | from juju.client import client |
| 8 | |
| 9 | |
| Adam Israel | dcdf82b | 2017-08-15 15:26:43 -0400 | [diff] [blame] | 10 | def test_basics(): |
| 11 | assert client.CLIENTS |
| Adam Israel | 1a15d1c | 2017-10-23 12:00:49 -0400 | [diff] [blame] | 12 | for i in range(1, 5): # Assert versions 1-4 in client dict |
| Adam Israel | dcdf82b | 2017-08-15 15:26:43 -0400 | [diff] [blame] | 13 | assert str(i) in client.CLIENTS |
| 14 | |
| 15 | |
| 16 | def test_from_connection(): |
| 17 | connection = mock.Mock() |
| 18 | connection.facades = {"Action": 2} |
| 19 | action_facade = client.ActionFacade.from_connection(connection) |
| Adam Israel | 1a15d1c | 2017-10-23 12:00:49 -0400 | [diff] [blame] | 20 | assert action_facade |
| Adam Israel | dcdf82b | 2017-08-15 15:26:43 -0400 | [diff] [blame] | 21 | |
| Adam Israel | 1a15d1c | 2017-10-23 12:00:49 -0400 | [diff] [blame] | 22 | |
| 23 | def test_to_json(): |
| 24 | uml = client.UserModelList([client.UserModel()]) |
| 25 | assert uml.to_json() == ('{"user-models": [{"last-connection": null, ' |
| 26 | '"model": null}]}') |