def _add_record(self, item):
     location = item['location']
     for school in item['schools']:
         school_title = school['title']
         for result in school['results']:
             ntc = ParsedNTC()
             ntc.location = location
             ntc.school_title = school_title
             ntc.full_name = result['full_name']
             ntc.math = result['math']
             ntc.physics = result['physics']
             ntc.chemistry = result['chemistry']
             ntc.geometry = result['geometry']
             ntc.biology = result['biology']
             ntc.geography = result['geography']
             ntc.history = result['history']
             ntc.eng_lang = result['eng_lang']
             ntc.ger_lang = result['ger_lang']
             ntc.fr_lang = result['fr_lang']
             ntc.kyr_lang = result['kyr_lang']
             ntc.rus_lang = result['rus_lang']
             ntc.uzb_lang = result['uzb_lang']
             ntc.informatics = result['informatics']
             ntc.civics = result['civics']
             ntc.notes = result['notes']
             ntc.integration_queue = self.integration_queue
             self.objects_to_save.append(ntc)
Example #2
0
    def test_integration_complete_for_school_with_only_numeric_title(self):
        integration_queue = IntegrationQueue.objects.create()
        parsed_ntc = ParsedNTC()
        parsed_ntc.location = u'г. Бишкек Свердловский район'
        parsed_ntc.school_title = u'1'
        parsed_ntc.full_name = u'АБДЫЛАСОВА ЖИБЕК'
        parsed_ntc.chemistry = '16'
        parsed_ntc.integration_queue = integration_queue
        parsed_ntc.save()
        integrator = DataIntegrator(integration_queue)

        integrator.integrate()
        first_ntc_result = NTC.objects.last()
        expected_full_name = u'АБДЫЛАСОВА ЖИБЕК'
        expected_school = School.objects.get(pk=132)
        expected_chemistry_result = 16
        self.assertEqual(first_ntc_result.full_name, expected_full_name)
        self.assertEqual(first_ntc_result.school, expected_school)
        self.assertEqual(first_ntc_result.chemistry, expected_chemistry_result)
        self.assertEqual(integration_queue.status, True)
Example #3
0
    def test_integration_complete(self):
        integration_queue = IntegrationQueue.objects.create()
        parsed_ntc = ParsedNTC()
        parsed_ntc.location = u'Нарынская область г. Нарын'
        parsed_ntc.school_title = u'Жакыпов К. №5'
        parsed_ntc.full_name = u'АБДЫЛАСОВА ЖИБЕК'
        parsed_ntc.chemistry = '16'
        parsed_ntc.integration_queue = integration_queue
        parsed_ntc.save()
        integrator = DataIntegrator(integration_queue)


        integrator.integrate()
        first_ntc_result = NTC.objects.last()
        expected_full_name = u'АБДЫЛАСОВА ЖИБЕК'
        expected_school = School.objects.get(pk=1216)
        expected_chemistry_result = 16
        self.assertEqual(first_ntc_result.full_name, expected_full_name)
        self.assertEqual(first_ntc_result.school, expected_school)
        self.assertEqual(first_ntc_result.chemistry, expected_chemistry_result)
        self.assertEqual(integration_queue.status, True)
Example #4
0
    def test_integration_fail(self):
        integration_queue = IntegrationQueue.objects.create()
        parsed_ntc = ParsedNTC()
        parsed_ntc.location = u'Нарынская область г. Нарын'
        parsed_ntc.school_title = u'unknown_school'
        parsed_ntc.full_name = u'АБДЫЛАСОВА ЖИБЕК'
        parsed_ntc.chemistry = '16'
        parsed_ntc.integration_queue = integration_queue
        parsed_ntc.save()
        integrator = DataIntegrator(integration_queue)

        integrator.integrate()

        self.assertEqual(integration_queue.status, False)

        try:
            parsed_ntc.ntc
            has_error = False
        except ObjectDoesNotExist:
            has_error = True

        self.assertTrue(has_error)