def test_getNetloc(self): # Given sut = Shop() sut.url = "https://www.43einhalb.com/new-balance-m997sob-made-in-usa" expectedNetloc = "www.43einhalb.com" # When result = sut.getNetloc() # Then self.assertEqual(expectedNetloc, result) # Given sut.url = "https://bubblegum.com/en/new-996-vhb-wl996vhb.html" expectedNetloc = "bubblegum.com" # When result = sut.getNetloc() # Then self.assertEqual(expectedNetloc, result) # Given sut.url = "http://www.somewhere.de/bubu/ghj45-3879475?req=nothing" expectedNetloc = "www.somewhere.de" # When result = sut.getNetloc() # Then self.assertEqual(expectedNetloc, result)
def test_getNetloc_shouldRaiseWhenNotExtractable(self): # Given sut = Shop() sut.url = "www.scary-tests.com/url-has-missing-schema.html" # When with self.assertRaises(ValueError): sut.getNetloc()