import json import pytest from masters_registry.constant import error def make_post(client, valid_headers, data): url = '/ownership' valid_headers['Content-Type'] = 'application/json' return client.post(url, data=json.dumps(data), headers=valid_headers) @pytest.fixture def invalid_data(): return { 'tuid': '1234567', 'isrc': 'ABC12345', 'territories': ['CA', 'US'] } def test_post_add_tuid_validation_failed(client, valid_headers, invalid_data): """Test post invalid data """ res = make_post(client, valid_headers, invalid_data) assert json.loads(res.data.decode())['code'] == error.BODY_VALIDATION_ERROR assert res.status_code == 400