def test_item_type_es_mapping(es_clear, db, org_martigny, item_type_data_tmp): """Test item type elasticsearch mapping.""" search = ItemTypesSearch() mapping = get_mapping(search.Meta.index) assert mapping ItemType.create(item_type_data_tmp, dbcommit=True, reindex=True, delete_pid=True) assert mapping == get_mapping(search.Meta.index)
def test_item_type_es_mapping(es_clear, db, organisation, item_type_data_tmp): """.""" search = ItemTypesSearch() mapping = get_mapping(search.Meta.index) assert mapping ItemType.create(item_type_data_tmp, dbcommit=True, reindex=True, delete_pid=True) assert mapping == get_mapping(search.Meta.index)
def item_type_online_sion(app, org_sion, item_type_online_sion_data): """Create particular item type of sion.""" itty = ItemType.create(data=item_type_online_sion_data, delete_pid=False, dbcommit=True, reindex=True) flush_index(ItemTypesSearch.Meta.index) return itty
def item_type(app, organisation, item_type_data): """.""" itty = ItemType.create(data=item_type_data, delete_pid=False, dbcommit=True, reindex=True) flush_index(ItemTypesSearch.Meta.index) return itty
def item_type_missing_martigny(app, org_martigny, item_type_missing_martigny_data): """Create missing item type of martigny.""" itty = ItemType.create(data=item_type_missing_martigny_data, delete_pid=False, dbcommit=True, reindex=True) flush_index(ItemTypesSearch.Meta.index) return itty
def test_item_type_create(db, item_type_data_tmp, org_martigny, item_type_online_martigny): """Test item type record creation.""" item_type_data_tmp['type'] = 'online' with pytest.raises(RecordValidationError): itty = ItemType.create(item_type_data_tmp, delete_pid=True) item_type_data_tmp['type'] = 'standard' itty = ItemType.create(item_type_data_tmp, delete_pid=True) assert itty == item_type_data_tmp assert itty.get('pid') == '2' itty = ItemType.get_record_by_pid('2') assert itty == item_type_data_tmp fetched_pid = item_type_id_fetcher(itty.id, itty) assert fetched_pid.pid_value == '2' assert fetched_pid.pid_type == 'itty' assert not ItemType.get_pid_by_name('no exists')
def test_item_type_create(db, item_type_data_tmp): """Test item type record creation.""" itty = ItemType.create(item_type_data_tmp, delete_pid=True) assert itty == item_type_data_tmp assert itty.get('pid') == '1' itty = ItemType.get_record_by_pid('1') assert itty == item_type_data_tmp fetched_pid = item_type_id_fetcher(itty.id, itty) assert fetched_pid.pid_value == '1' assert fetched_pid.pid_type == 'itty' assert not ItemType.get_pid_by_name('no exists')
def test_item_type_create(db, item_type_data_tmp, org_martigny, item_type_online_martigny): """Test item type record creation.""" item_type_data_tmp['type'] = 'online' with pytest.raises(ValidationError): itty = ItemType.create(item_type_data_tmp, delete_pid=True) db.session.rollback() next_pid = ItemType.provider.identifier.next() item_type_data_tmp['type'] = 'standard' itty = ItemType.create(item_type_data_tmp, delete_pid=True) next_pid += 1 assert itty == item_type_data_tmp assert itty.get('pid') == str(next_pid) itty = ItemType.get_record_by_pid(str(next_pid)) assert itty == item_type_data_tmp fetched_pid = item_type_id_fetcher(itty.id, itty) assert fetched_pid.pid_value == str(next_pid) assert fetched_pid.pid_type == 'itty' assert not ItemType.get_pid_by_name('no exists')
def test_item_type_can_delete(app, item_type_data_tmp): """Test item type can delete""" itty = ItemType.create(item_type_data_tmp, delete_pid=True) assert itty.get_links_to_me() == {} assert itty.can_delete
def test_item_type_can_delete(app, item_type_data_tmp): """Test item type can delete""" itty = ItemType.create(item_type_data_tmp, delete_pid=True) can, reasons = itty.can_delete assert can assert reasons == {}