def test_put_and_get_shorturl(): """ putting and getting a short url works """ repository = InMemoryURLRepository() short_url = "short" original_url = OriginalUrl("www.url.com/rr") repository.put(short_url, original_url) assert repository.get(short_url) is original_url
def test_url_updated_when_putting_same_key_different_url(): """ updating a short url works """ repository = InMemoryURLRepository() short_url = "short" original_url1 = OriginalUrl("www.first.com") original_url2 = OriginalUrl("www.second.com", datetime.now()) repository.put(short_url, original_url1) repository.put(short_url, original_url2) assert len(repository.url_map) == 1 assert repository.get(short_url) is original_url2
def test_none_when_shorturl_non_present(): """ getting a non existing short url returns None """ repository = InMemoryURLRepository() assert repository.get("a-short-url") is None