~ubuntu-branches/ubuntu/trusty/landscape-client/trusty-proposed

« back to all changes in this revision

Viewing changes to landscape/monitor/tests/test_computerinfo.py

  • Committer: Package Import Robot
  • Author(s): Christopher Glass (Canonical)
  • Date: 2013-09-18 11:42:28 UTC
  • mfrom: (1.1.32)
  • Revision ID: package-import@ubuntu.com-20130918114228-o35arr47suk1r2ra
Tags: 13.07.3-0ubuntu1
* New release: 13.07.3
  - The metadata.d/ directory was renamed to annotations.d/ (LP: #1226087)
  - Metadata exchange mechanism now uses the less ambiguous term
    "annotations" instead of "metadata". (LP: #1226597)

Show diffs side-by-side

added added

removed removed

Lines of Context:
328
328
        self.mstore.set_accepted_types(["distribution-info", "computer-info"])
329
329
        self.assertMessages(list(self.mstore.get_pending_messages()), [])
330
330
 
331
 
    def test_extra_meta_data(self):
 
331
    def test_annotations(self):
332
332
        """
333
 
        L{ComputerInfo} sends extra meta data the meta-data.d directory
 
333
        L{ComputerInfo} sends extra meta data the annotations.d directory
334
334
        if it's present.
335
335
 
336
 
        Each file name is used as a key in the extra-meta-data dict and
 
336
        Each file name is used as a key in the annotations dict and
337
337
        the file's contents are used as values.
338
338
 
339
339
        This allows, for example, the landscape-client charm to send
340
340
        information about the juju environment to the landscape server.
341
341
        """
342
 
        meta_data_dir = self.monitor.config.meta_data_path
343
 
        os.mkdir(meta_data_dir)
344
 
        create_file(os.path.join(meta_data_dir, "juju-env-uuid"), "uuid1")
345
 
        create_file(os.path.join(meta_data_dir, "juju-unit-name"), "unit/0")
 
342
        annotations_dir = self.monitor.config.annotations_path
 
343
        os.mkdir(annotations_dir)
 
344
        create_file(os.path.join(annotations_dir, "annotation1"), "value1")
 
345
        create_file(os.path.join(annotations_dir, "annotation2"), "value2")
346
346
        self.mstore.set_accepted_types(["computer-info"])
347
347
 
348
348
        plugin = ComputerInfo()
350
350
        plugin.exchange()
351
351
        messages = self.mstore.get_pending_messages()
352
352
        self.assertEqual(1, len(messages))
353
 
        meta_data = messages[0]["extra-meta-data"]
 
353
        meta_data = messages[0]["annotations"]
354
354
        self.assertEqual(2, len(meta_data))
355
 
        self.assertEqual("uuid1", meta_data["juju-env-uuid"])
356
 
        self.assertEqual("unit/0", meta_data["juju-unit-name"])
 
355
        self.assertEqual("value1", meta_data["annotation1"])
 
356
        self.assertEqual("value2", meta_data["annotation2"])
357
357
 
358
 
    def test_extra_meta_data_no_directory(self):
359
 
        """
360
 
        L{ComputerInfo} doesn't include the extra-meta-data key if there
361
 
        is no meta-data.d directory.
362
 
        """
363
 
        meta_data_dir = self.monitor.config.meta_data_path
 
358
    def test_annotations_no_directory(self):
 
359
        """
 
360
        L{ComputerInfo} doesn't include the annotations key if there
 
361
        is no annotations.d directory.
 
362
        """
 
363
        meta_data_dir = self.monitor.config.annotations_path
364
364
        self.assertFalse(os.path.exists(meta_data_dir))
365
365
        self.mstore.set_accepted_types(["computer-info"])
366
366
 
369
369
        plugin.exchange()
370
370
        messages = self.mstore.get_pending_messages()
371
371
        self.assertEqual(1, len(messages))
372
 
        self.assertNotIn("extra-meta-data", messages[0])
 
372
        self.assertNotIn("annotations", messages[0])
373
373
 
374
374
    def test_extra_meta_data_empty_directory(self):
375
375
        """
376
 
        L{ComputerInfo} doesn't include the extra-meta-data key if the
377
 
        meta-data.d directory doesn't contain any files.
 
376
        L{ComputerInfo} doesn't include the annotations key if the
 
377
        annotations.d directory doesn't contain any files.
378
378
        """
379
 
        meta_data_dir = self.monitor.config.meta_data_path
 
379
        meta_data_dir = self.monitor.config.annotations_path
380
380
        os.mkdir(meta_data_dir)
381
381
        self.mstore.set_accepted_types(["computer-info"])
382
382
 
385
385
        plugin.exchange()
386
386
        messages = self.mstore.get_pending_messages()
387
387
        self.assertEqual(1, len(messages))
388
 
        self.assertNotIn("extra-meta-data", messages[0])
 
388
        self.assertNotIn("annotations", messages[0])