~chad.smith/landscape-charm/maas-haproxy-smoosh

« back to all changes in this revision

Viewing changes to tests/test_helpers.py

  • Committer: Landscape Builder
  • Author(s): Danilo Šegan
  • Date: 2015-06-15 09:27:05 UTC
  • mfrom: (306.1.11 admin-user-action)
  • Revision ID: landscape_builder-20150615092705-vouyiaxg1czmkzui
Merge admin-user-action [f=1462387] [r=landscape-builder,free.ekanayaka,benji] [a=Данило Шеган]
Create bootstrap action that creates an LDS account and adds an admin user

Introduce "bootstrap" action that takes "admin-name", "admin-email" and "admin-password" parameters and creates a "standalone" LDS account with the appropriate admin user.

At the moment, we are using 'schema --create-lds-account-only', though we should move to not using this in the future.  This script doesn't report nicely if you've already called 'bootstrap' once.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import json
 
2
import logging
1
3
import os
2
 
 
3
 
import logging
4
4
import unittest
5
5
 
6
6
from helpers import EnvironmentFixture
12
12
 
13
13
    def __init__(self, public_address=None):
14
14
        self.info = {
15
 
            "public-address": public_address
 
15
            "public-address": public_address,
 
16
            "unit_name": "landscape-server/0"
16
17
        }
17
18
        self.commands = []
18
19
 
155
156
        self.assertIn("good_content:['hello']", message)
156
157
        self.assertIn("output:bar", message)
157
158
 
 
159
    def test_bootstrap_landscape(self):
 
160
        """
 
161
        bootstrap_landscape method calls 'bootstrap' action on
 
162
        a landscape-server unit.
 
163
        """
 
164
        action_do_command = (
 
165
            "juju action do --format=json landscape-server/0 bootstrap "
 
166
            "admin-email=admin@example.com admin-name=foo admin-password=bar")
 
167
        self.subprocess.outputs[action_do_command] = json.dumps(
 
168
            {"Action queued with id": "17"}).encode("utf-8")
 
169
        action_fetch_command = "juju action fetch --format=json --wait 300 17"
 
170
        self.subprocess.outputs[action_fetch_command] = json.dumps(
 
171
            {"status": "fine"}).encode("utf-8")
 
172
 
 
173
        self.assertEqual(
 
174
            {"status": "fine"},
 
175
            self.fixture.bootstrap_landscape(
 
176
                admin_name="foo", admin_email="admin@example.com",
 
177
                admin_password="bar"))
 
178
 
158
179
 
159
180
if __name__ == "__main__":
160
181
    logging.basicConfig(