blob: 9a26117089498423ebba7dda3f7e3acb50ba54e7 [file] [log] [blame]
Adam Israel102cd7f2018-05-08 12:55:29 -04001#!/usr/bin/python3
2
3import amulet
4import requests
5import unittest
6
7
8class TestCharm(unittest.TestCase):
9 def setUp(self):
10 self.d = amulet.Deployment()
11
12 self.d.add('simple')
13 self.d.expose('simple')
14
15 self.d.setup(timeout=900)
16 self.d.sentry.wait()
17
18 self.unit = self.d.sentry['simple'][0]
19
20 def test_service(self):
21 # test we can access over http
22 page = requests.get('http://{}'.format(self.unit.info['public-address']))
23 self.assertEqual(page.status_code, 200)
24 # Now you can use self.d.sentry[SERVICE][UNIT] to address each of the units and perform
25 # more in-depth steps. Each self.d.sentry[SERVICE][UNIT] has the following methods:
26 # - .info - An array of the information of that unit from Juju
27 # - .file(PATH) - Get the details of a file on that unit
28 # - .file_contents(PATH) - Get plain text output of PATH file from that unit
29 # - .directory(PATH) - Get details of directory
30 # - .directory_contents(PATH) - List files and folders in PATH on that unit
31 # - .relation(relation, service:rel) - Get relation data from return service
32
33
34if __name__ == '__main__':
35 unittest.main()