def testGetTargetTCB(self): src = 'https://www.topcashback.co.uk/earncashback.aspx?mpurl=currys&continue=1' target = 'http://www.currys.co.uk/gbuk/index.html?srcid=369&xtor=AL-1&cmpid=aff~TopCashBack~' domain = 'currys.co.uk' url = get_target(src) self.assertEqual(url,target) self.assertEqual(strip_www(url_to_domain(url)), domain)
def testGetTargetMediaplex(self): src = 'http://adfarm.mediaplex.com/ad/ck/15368-110724-36269-43?CJAID=801842&CJPID=1777643&ttp=100&rfr=123' target = 'https://promotions.betfair.com/value-uk-football-dual-aff-t?CID=&PLA=153681107243626943&ttp=100&rfr=123&mpch=ads' domain = 'promotions.betfair.com' url = get_target(src) self.assertEqual(url,target) self.assertEqual(strip_www(url_to_domain(url)), domain)
def testHttp(self): self.assertEqual(url_to_domain('http://example.org'), 'example.org')
def testDirect(self): self.assertEqual(url_to_domain('direct.asda.com'), 'direct.asda.com')
def testEmpty(self): self.assertEqual(url_to_domain(''), None)
def testWww(self): self.assertEqual(url_to_domain('www.asda.com'), 'www.asda.com')
def testSansWww(self): self.assertEqual(url_to_domain('asda.com'), 'asda.com')
def testNoHttp3(self): self.assertEqual(url_to_domain('example.org/foo/bar'), 'example.org')
def testNoHttp1(self): self.assertEqual(url_to_domain('example.org'), 'example.org')
def testPort(self): self.assertEqual(url_to_domain('http://www.example.org:80'), 'www.example.org')