Select Git revision
test_xmlparsing.py
-
Daniel Hornung authoredDaniel Hornung authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
test_select.cpp 26.74 KiB
/*
* This file is a part of the CaosDB Project.
*
* Copyright (C) 2022 IndiScale GmbH <info@indiscale.com>
* Copyright (C) 2022 Timm Fitschen <t.fitschen@indiscale.com>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "caosdb/connection.h" // for Connection, ConnectionManager
#include "caosdb/data_type.h" // for AtomicDataType
#include "caosdb/entity.h" // for Entity, Property, Role, Parent
#include "caosdb/result_set.h" // for Entity, ResultSet, ResultSet::ite...
#include "caosdb/result_table.h" // for ResultTable::HeaderIterator, Resu...
#include "caosdb/transaction.h" // for Transaction, ResultTable
#include "caosdb/value.h" // for Value
#include <gtest/gtest-message.h> // for Message
#include <gtest/gtest-spi.h> // for EXPECT_NONFATAL_FA...
#include <gtest/gtest-test-part.h> // for SuiteApiResolver, TestFactoryImpl
#include <gtest/gtest_pred_impl.h> // for Test, TestInfo, EXPECT_EQ, TEST
#include <iostream> // for operator<<, basic_ostream::operat...
#include <memory> // for allocator, unique_ptr, __shared_p...
#include <string> // for string
namespace caosdb::transaction {
using caosdb::entity::AtomicDataType;
using caosdb::entity::DataType;
using caosdb::entity::Entity;
using caosdb::entity::Parent;
using caosdb::entity::Property;
using caosdb::entity::Role;
using caosdb::entity::Value;
class test_select : public ::testing::Test {
public:
static void InsertEntity(Entity *entity) {
const auto &connection = caosdb::connection::ConnectionManager::GetDefaultConnection();
auto insert_transaction(connection->CreateTransaction());
insert_transaction->InsertEntity(entity);
insert_transaction->Execute();
}
static void DeleteEntities() {
// delete all entities
const auto &connection = caosdb::connection::ConnectionManager::GetDefaultConnection();
auto query_transaction(connection->CreateTransaction());
query_transaction->Query("FIND Entity");
query_transaction->Execute();
if (query_transaction->GetResultSet().size() > 0) {
auto delete_transaction(connection->CreateTransaction());
for (const Entity &entity : query_transaction->GetResultSet()) {
delete_transaction->DeleteById(entity.GetId());
}
delete_transaction->Execute();
}
}
static auto CreateTestProp(const std::string &name, AtomicDataType data_type, bool isList = false)
-> Entity {
Entity entity;