Ejemplo n.º 1
0
    def test_archive_view_returns_words_occurred_in_certain_time_period(self):
        request = HttpRequest()
        request.method = 'GET'
        request.GET['startdate'] = self.datetime4
        request.GET['enddate'] = self.datetime5
        request.GET['info'] = 'get_words_archive'
        response = archive(request=request)

        import json
        response_json = json.loads((response.content.decode('utf-8')))

        words_text = get_response_jsons_items_attributes(response_json, 'words', 'text')
        self.assertIn(self.word2.text, words_text)
        self.assertNotIn(self.word1.text, words_text)
        self.assertNotIn(self.word3.text, words_text)
Ejemplo n.º 2
0
    def test_archive_return_proper_formatted_json_on_ajax_get_words_archive_request(self):
        request = HttpRequest()
        request.method = 'GET'
        request.GET['startdate'] = self.datetime4
        request.GET['enddate'] = self.datetime5
        request.GET['info'] = 'get_words_archive'
        response = archive(request=request)

        import json
        response_json = json.loads((response.content.decode('utf-8')))

        words_text = get_response_jsons_items_attributes(response_json, 'words', 'text')
        self.assertIn('car', words_text)
        self.assertIn('plane', words_text)
        self.assertNotIn('vehicle', words_text)
        self.assertNotIn('bike', words_text)

        self.assertEqual(response_json['startdate'], self.datetime4.strftime("%Y-%m-%d"))
        self.assertEqual(response_json['enddate'], self.datetime5.strftime("%Y-%m-%d"))