def setUp(cls):
     cls.app, cls.db, cls.validator = test_utils.set_up_service()
     import_data = test_utils.read_data('import.json')
     for citizen in import_data['citizens']:
         citizen['birth_date'] = datetime.strptime(citizen['birth_date'], '%d.%m.%Y')
     import_data['import_id'] = 0
     cls.db['imports'].insert_one(import_data)
    def test_import_id_should_increase_for_each_import(self):
        headers = [('Content-Type', 'application/json')]

        for import_id in range(2):
            import_data = test_utils.read_data('import.json')
            http_response = self.app.post('/imports', data=json_util.dumps(import_data), headers=headers)

            response_data = http_response.get_json()
            import_data['import_id'] = import_id
            for citizen in import_data['citizens']:
                citizen['birth_date'] = datetime.strptime(citizen['birth_date'], '%d.%m.%Y')
            self.assertEqual(import_id, response_data['data']['import_id'])
            self.assertEqual(http_response.status_code, 201)
            self.assertEqual(import_data, self.db['imports'].find_one({'import_id': import_id}, {'_id': 0}))
Beispiel #3
0
 def test_correct_import_should_be_valid(self):
     import_data = test_utils.read_data('import.json')
     self.data_validator.validate_import(import_data)
 def test_correct_patch_should_be_valid(self):
     patch_data = test_utils.read_data('citizen_patch.json')
     self.data_validator.validate_citizen_patch(0, patch_data)