Exemplo n.º 1
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)
Exemplo n.º 2
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)
Exemplo n.º 3
0
 def test_saving_and_retrieving_documents(self):
     document = Document(doc_id = '1', filename='test.pdf', author="Slick Willy",title='document 1')
     document.save()
     saved_document = Document.objects.first()
     self.assertEqual(saved_document.pk,document.pk)