def test_calculate_distance_zero(self): base = "test" target = base info("Base keyword: {}".format(base)) info("Target keyword: {}".format(target)) l = calculate_levenstein(base, target) assert_type(l, int, "Check if proper type is returned") assert_equal(l, 0, "Check if proper distance is calculated")
def create_baddie(domain): _, ip_id = add_ip(domain) _, crt_id = add_cert(domain) good_keywords = [k['good_keyword'] for k in Goodies.get_all_goodies()] domain_phrases = domain.split('.') _, _, lev_matched_keyword = lev.levenstein_check(good_keywords, domain_phrases) min_lev_distance = 0 lev_distance = 0 if lev_matched_keyword: for phrase in domain_phrases: lev_distance = lev.calculate_levenstein(lev_matched_keyword, phrase) if 3 > min_lev_distance > lev_distance: min_lev_distance = lev_distance if not lev_matched_keyword: lev_matched_keyword = '' _, contained_matched_keyword = match_keyword(domain) if not contained_matched_keyword: contained_matched_keyword = '' entropy = ent.get_entropy(domain) return add_baddie(domain, ip_id[1], crt_id[1], lev_distance, lev_matched_keyword, contained_matched_keyword, entropy)