~adam-collard/charms/trusty/landscape-client/landscape-client-multiple-juju-files

« back to all changes in this revision

Viewing changes to hooks/test_hooks.py

Make sure the juju-info file is written to disk before trying to
register the client with the server, so that information about the
Juju environment is sent to the server at registration time.

Show diffs side-by-side

added added

removed removed

Lines of Context:
124
124
        self.landscape_broker.config.data_path = data_path
125
125
        self.landscape_broker.config.config = os.path.join(
126
126
            data_path, "landscape.conf")
 
127
        self.landscape_broker.config.account_name = "account1"
127
128
        self.landscape_broker.config.write()
128
129
        self.juju_broker = FakeJujuBroker()
129
130
        self.juju_broker.environment["JUJU_REMOTE_UNIT"] = "remote/0"
152
153
             "api-addresses": "10.0.0.1:1234",
153
154
             "private-address": "10.0.0.99"},
154
155
            juju_info)
 
156
 
 
157
    def test_registers_after_juju_info_is_written(self):
 
158
        """
 
159
        The client tries to register to Landscape after the juju-info
 
160
        file has been written, so that juju information is sent in the
 
161
        registration message.
 
162
        """
 
163
        registration_attempts = []
 
164
 
 
165
        def record_registration_attempt():
 
166
            juju_info_path = os.path.join(
 
167
                self.landscape_broker.config.data_path, "juju-info.json")
 
168
            registration_attempts.append(os.path.exists(juju_info_path))
 
169
 
 
170
        self.landscape_broker.try_to_register = record_registration_attempt
 
171
        self.hook(self.juju_broker, self.landscape_broker)
 
172
 
 
173
        self.assertEqual([True], registration_attempts)