예제 #1
0
 def test_saving_and_retrieving_searches(self):
     search = Search(search_terms = 'atrazine')
     search.save()
     searches = Searches(search_id = search)
     searches.save()
     saved_searches = Searches.objects.all()
     saved_search = saved_searches[0]
     self.assertEqual(saved_searches.count(),1)
     self.assertEqual(saved_search.search_id.search_terms,search.search_terms)
예제 #2
0
    def test_saving_and_retrieving_results(self):
        search = Search(search_terms = 'atrazine')
        search.save()
        searches = Searches(search_id = search)
        searches.save()
        document = Document(doc_id = '1', filename='test.pdf', author="Slick Willy",title='here is an title')
        document.save()
        
        result = Result(doc_id = document, searches_id = searches)
        result.save()

        results = Result.objects.all()
        saved_result = results[0]

        self.assertEqual(results.count(),1)
        self.assertEqual(saved_result.pk,result.pk)
        self.assertEqual(saved_result.doc_id.pk, document.pk)
        self.assertEqual(saved_result.searches_id.pk,searches.pk)
        self.assertEqual(saved_result.searches_id.search_id.pk,search.pk)
예제 #3
0
    def test_get_search_results_creates_results_objects(self):
        request = HttpRequest()
        search = Search(search_terms = 'atrazine missouri')
        search.save()
        searches = Searches(search_id = search,time=datetime.now())
        searches.save()
        document1 = Document(doc_id = '1', filename = 'test.csv', author="Paul Bryant", title = "Here is the atrazine title")
        document2 = Document(doc_id = '2', filename = 'test2.csv', author="Gill Humphry", title = "document 2 title")

        document1.save()
        document2.save()

        get_search_results(request,'atrazine_missouri_1')
    
        newly_saved_results = Result.objects.all()
        result1 = newly_saved_results[0]
        result2 = newly_saved_results[1]

        self.assertEqual(Result.objects.count(),2)
        self.assertEqual(result1.doc_id,document1)
        self.assertEqual(result2.doc_id,document2)