def test_set_and_check_attributes_duplicated_locations(self): url = "http://www.google.com" google_page = IndexedPage(url=url) google_page.save() our_word = WordFromIndexedPage(word="google", indexed_page=google_page) locations_list = [2, 5, 7, 7, 2, 2, 11] our_word.set_offsets(locations_list) our_word.save() # checking if the locations are retrievable retrieved_offsets = our_word.get_offsets() for location in locations_list: self.assertIn(location, retrieved_offsets) self.assertEqual(len(locations_list), len(retrieved_offsets))
def test_set_and_check_attributes_duplicated_locations(self): url = "http://www.google.com" google_page = IndexedPage(url = url) google_page.save() our_word = WordFromIndexedPage(word = "google", indexed_page = google_page) locations_list = [2, 5, 7, 7, 2, 2, 11] our_word.set_offsets(locations_list) our_word.save() #checking if the locations are retrievable retrieved_offsets = our_word.get_offsets() for location in locations_list: self.assertIn(location, retrieved_offsets) self.assertEqual(len(locations_list), len(retrieved_offsets))
from searchEngine.models import WordFromIndexedPage, IndexedPage googlePage = IndexedPage(url="http://www.google.com") googlePage.save() print googlePage googleWord = "google" googleWord2 = "google2" googleWordLocation = WordFromIndexedPage(indexedPage=googlePage, word=googleWord) googleWordLocation.set_offsets([1]) googleWordLocation.save() googleWord2Location = WordFromIndexedPage(indexedPage=googlePage, word=googleWord2) googleWord2Location.set_offsets([1]) googleWord2Location.save() print "--" * 100 print "googlePage.words:", googlePage.get_words() print len(googlePage.words.all())
from searchEngine.models import WordFromIndexedPage, IndexedPage googlePage = IndexedPage(url="http://www.google.com") googlePage.save() print googlePage googleWord = "google" googleWord2 = "google2" googleWordLocation = WordFromIndexedPage(indexedPage=googlePage, word=googleWord) googleWordLocation.set_offsets([1]) googleWordLocation.save() googleWord2Location = WordFromIndexedPage(indexedPage=googlePage, word=googleWord2) googleWord2Location.set_offsets([1]) googleWord2Location.save() print "--"* 100 print "googlePage.words:", googlePage.get_words() print len(googlePage.words.all())