def testBadCountDomainsInput(self): tlds = [{"badkey": "junkvalue"}] try: dCs = j.countDomains(tlds) self.assertTrue(False, "bad tld result") except KeyError as e: self.assertTrue(True, "good tld result")
def testCountDomains(self): tlds = [{"domain": "whatever"}, {"domain":"tld"}, {"domain":"whatever"}, {"domain":"whatever"}] domainCounts = j.countDomains(tlds) self.assertEqual(2, len(domainCounts), "number of distinct domains") self.assertEqual(3, domainCounts["whatever"], "number of whatever domains")