~jcsackett/charmworld/bac-tag-constraints

« back to all changes in this revision

Viewing changes to charmworld/tests/test_models.py

  • Committer: Tarmac
  • Author(s): Brad Crittenden
  • Date: 2014-04-02 18:25:54 UTC
  • mfrom: (497.1.1 add-maintainers)
  • Revision ID: tarmac-20140402182554-h4fo6e0qnroitzni
Add a 'maintainer's field.

It was decided on the mailing list that the 'maintainer' field should be
renamed to 'maintainers' to make it clear that there can be more than one.
Note the old 'maintainer' field was capable of being a single entity or a list
just fine.

So for backward compatability, 'maintainer' is preserved, 'maintainers' is
added and the actual value used is the union of the two, with duplicates
removed.  

On the charm page the heading has been changed to 'Maintainer(s)" and an
unordered list is used to present the names.

https://codereview.appspot.com/83620043/

R=rharding.

Approved by Juju Gui Bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
482
482
            charm.OFFICIAL_CATEGORIES)
483
483
        self.assertEqual([], charm.categories)
484
484
 
485
 
    def test_maintainer(self):
486
 
        # The maintainer property is a list of category names.
 
485
    def test_maintainer_default(self):
 
486
        # The default is an empty list.
 
487
        charm = Charm({})
 
488
        self.assertEqual([], charm.maintainers)
 
489
 
 
490
    def test_maintainer_single(self):
 
491
        # The maintainer property is a single string or a list of maintainers
 
492
        # in RFC 2822 name/email format.
 
493
        # It is deprecated in favor of 'maintainers'.
 
494
        maintainer = 'Jane <jane@example.com>'
 
495
        charm_data = factory.get_charm_json(maintainer=maintainer)
 
496
        charm = Charm(charm_data)
 
497
        self.assertEqual([maintainer], charm.maintainers)
 
498
 
 
499
    def test_maintainer_list(self):
 
500
        # The maintainer property is a list of maintainers in RFC 2822
 
501
        # name/email format.
 
502
        # It is deprecated in favor of 'maintainers'.
487
503
        maintainer = ['Jane <jane@example.com>', 'Ian <ian@example.com>']
488
504
        charm_data = factory.get_charm_json(maintainer=maintainer)
489
505
        charm = Charm(charm_data)
490
 
        self.assertIs(maintainer, charm.maintainer)
491
 
        # The default is an empty string.
492
 
        charm = Charm({})
493
 
        self.assertEqual('', charm.maintainer)
 
506
        self.assertEqual(sorted(maintainer), charm.maintainers)
 
507
 
 
508
    def test_maintainers_single(self):
 
509
        # The maintainers field is the same.
 
510
        maintainers = 'Jane <jane@example.com>'
 
511
        charm_data = factory.get_charm_json(maintainers=maintainers)
 
512
        # Forcibly remove the default maintainer.
 
513
        del charm_data['maintainer']
 
514
        charm = Charm(charm_data)
 
515
        self.assertEqual([maintainers], charm.maintainers)
 
516
 
 
517
    def test_maintainers_list(self):
 
518
        # The maintainer property is a list of maintainers in RFC 2822
 
519
        # name/email format.
 
520
        # It is deprecated in favor of 'maintainers'.
 
521
        maintainers = ['Jane <jane@example.com>', 'Ian <ian@example.com>']
 
522
        charm_data = factory.get_charm_json(maintainers=maintainers)
 
523
        # Forcibly remove the default maintainer.
 
524
        del charm_data['maintainer']
 
525
        charm = Charm(charm_data)
 
526
        self.assertEqual(sorted(maintainers), charm.maintainers)
 
527
 
 
528
    def test_both_maintainer_and_maintainers(self):
 
529
        # If both the old 'maintainer' and new 'maintainers' are given, then
 
530
        # the output is the de-duplicated union.
 
531
        maintainer = ['Alice <alice@example.com>', 'Ian <ian@example.com>']
 
532
        maintainers = ['Jane <jane@example.com>', 'Ian <ian@example.com>']
 
533
        charm_data = factory.get_charm_json(
 
534
            maintainer=maintainer,
 
535
            maintainers=maintainers)
 
536
        charm = Charm(charm_data)
 
537
        union = set(maintainer)
 
538
        union.update(maintainers)
 
539
        self.assertEqual(3, len(charm.maintainers))
 
540
        self.assertEqual(sorted(union), charm.maintainers)
494
541
 
495
542
    def test_subordinate(self):
496
543
        # The subordinate property is a bool.