def test_charm_supported(self): data = copy.deepcopy(charm_data) data["Meta"]["extra-info"]["supported"] = "true" data["Meta"]["extra-info"]["price"] = "99" data["Meta"]["extra-info"]["description"] = "Great ol' charm\nthis one" charm = models.Charm(data) self.assertTrue(charm.supported) self.assertEqual(charm.supported_price, "99") self.assertEqual(charm.supported_description, "<p>Great ol' charm\nthis one</p>")
def test_charm_terms(self): data = copy.deepcopy(charm_data) data["Meta"]["terms"] = ["special-term/99", "another-term"] charm = models.Charm(data) self.assertEqual( charm.term_ids, [ { "id": "special-term/99", "name": "special-term", "revision": 99, }, { "id": "another-term", "name": "another-term", "revision": None, }, ], )
def test_charm(self): charm = models.Charm(charm_data) self.assertTrue(charm.archive_url.endswith("apache2-26/archive")) self.assertEqual(charm.bugs_url, "https://bugs.launchpad.net/apache2-charm") self.assertEqual(charm.card_id, "apache2-26") self.assertEqual(charm.channels, [{ "Channel": "stable", "Current": True }]) self.assertTrue( "The Apache Software Foundation's goal" in charm.description) self.assertEqual(charm.display_name, "apache2") self.assertEqual(charm.homepage, "https://launchpad.net/apache2-charm") self.assertTrue(charm.icon.endswith("apache2-26/icon.svg")) self.assertEqual(charm.id, "cs:apache2-26") self.assertTrue(charm.is_charm) self.assertEqual( charm.options.get("apt-key-id"), { "Type": "string", "Description": ("A PGP key id. This is used with PPA and the source " "option to import a PGP public key for verifying " "repository signatures. This value must match the PPA " "for apt-source."), "Default": "", }, ) self.assertEqual(charm.owner, "apache2-charmers") self.assertIsNone(charm.promulgated) self.assertEqual( charm.provides.get("apache-website"), { "Name": "apache-website", "Role": "provider", "Interface": "apache-website", "Optional": False, "Limit": 0, "Scope": "container", }, ) self.assertEqual( charm.requires.get("balancer"), { "Name": "balancer", "Role": "requirer", "Interface": "http", "Optional": False, "Limit": 1, "Scope": "global", }, ) self.assertEqual(charm.resources, {}) self.assertTrue(len(charm.revision_list) > 0) self.assertEqual(charm.revision_list[0], "cs:precise/apache2-27") self.assertEqual(charm.revision_number, 26) self.assertEqual(len(charm.revisions), 10) self.assertEqual(charm.series, ["xenial", "trusty", "bionic"]) self.assertEqual(charm.tags, ["app-servers"]) self.assertEqual(charm.url, "apache2/26")