コード例 #1
0
 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)
コード例 #2
0
    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}))
コード例 #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)
コード例 #4
0
 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)