482
482
charm.OFFICIAL_CATEGORIES)
483
483
self.assertEqual([], charm.categories)
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.
488
self.assertEqual([], charm.maintainers)
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)
499
def test_maintainer_list(self):
500
# The maintainer property is a list of maintainers in RFC 2822
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.
493
self.assertEqual('', charm.maintainer)
506
self.assertEqual(sorted(maintainer), charm.maintainers)
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)
517
def test_maintainers_list(self):
518
# The maintainer property is a list of maintainers in RFC 2822
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)
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)
495
542
def test_subordinate(self):
496
543
# The subordinate property is a bool.