Exemplo n.º 1
0
 def post(self, request, *args, **kwargs):
     if request.META.get('AUTHORIZATION') == settings.API_KEY or request.META.get(
             'HTTP_AUTHORIZATION') == settings.API_KEY:
         data_saver = NTCDataSaver(request.body)
         data_saver.load()
         return JsonResponse({'status': 'ok'})
     else:
         return JsonResponse({'error': 'wrong api key'}, status=401)
Exemplo n.º 2
0
 def post(self, request, *args, **kwargs):
     if (
         request.META.get("AUTHORIZATION") == settings.API_KEY
         or request.META.get("HTTP_AUTHORIZATION") == settings.API_KEY
     ):
         data_saver = NTCDataSaver(request.body)
         data_saver.load()
         return JsonResponse({"status": "ok"})
     else:
         return JsonResponse({"error": "wrong api key"}, status=401)
Exemplo n.º 3
0
    def test_data_saved_last_object(self):
        data_saver = NTCDataSaver(self.json)
        data_saver.load()

        last_record = ParsedNTC.objects.last()
        actual_last_record_full_name = last_record.full_name
        actual_last_record_school_title = last_record.school_title
        actual_last_record_location = last_record.location
        actual_last_record_eng_lang_result = last_record.eng_lang
        actual_last_record_history_result = last_record.history

        expected_last_record_full_name = u"ЯКОВЛЕВА АНАСТАСИЯ"
        expected_last_record_school_title = u"Эврика"
        expected_last_record_location = u"г. Бишкек г. БишкекНЦТ"
        expected_last_record_eng_lang_result = '25'
        expected_last_record_history_result = '20'

        self.assertEqual(actual_last_record_full_name, expected_last_record_full_name)
        self.assertEqual(actual_last_record_school_title, expected_last_record_school_title)
        self.assertEqual(actual_last_record_location, expected_last_record_location)
        self.assertEqual(actual_last_record_eng_lang_result, expected_last_record_eng_lang_result)
        self.assertEqual(actual_last_record_history_result, expected_last_record_history_result)
Exemplo n.º 4
0
    def test_data_saved_first_object(self):
        data_saver = NTCDataSaver(self.json)
        data_saver.load()

        first_record = ParsedNTC.objects.first()
        actual_first_record_full_name = first_record.full_name
        actual_first_record_school_title = first_record.school_title
        actual_first_record_location = first_record.location
        actual_first_record_eng_lang_result = first_record.eng_lang
        actual_first_record_history_result = first_record.history

        expected_first_record_full_name = u"АБДЫКЕРИМОВ ЭЛЬНУР"
        expected_first_record_school_title = u"Абитуриент"
        expected_first_record_location = u"г. Бишкек г. БишкекНЦТ"
        expected_first_record_eng_lang_result = '22'
        expected_first_record_history_result = '29'

        self.assertEqual(actual_first_record_full_name, expected_first_record_full_name)
        self.assertEqual(actual_first_record_school_title, expected_first_record_school_title)
        self.assertEqual(actual_first_record_location, expected_first_record_location)
        self.assertEqual(actual_first_record_eng_lang_result, expected_first_record_eng_lang_result)
        self.assertEqual(actual_first_record_history_result, expected_first_record_history_result)