PyObject * py_package_from_rpm(PyObject *self, PyObject *args) { CR_UNUSED(self); PyObject *ret; cr_Package *pkg; int checksum_type, changelog_limit; char *filename, *location_href, *location_base; GError *tmp_err = NULL; if (!PyArg_ParseTuple(args, "sizzi:py_package_from_rpm", &filename, &checksum_type, &location_href, &location_base, &changelog_limit)) { return NULL; } pkg = cr_package_from_rpm(filename, checksum_type, location_href, location_base, changelog_limit, NULL, &tmp_err); if (tmp_err) { nice_exception(&tmp_err, "Cannot load %s: ", filename); return NULL; } ret = Object_FromPackage(pkg, 1); return ret; }
PyObject * py_package_from_rpm(G_GNUC_UNUSED PyObject *self, PyObject *args) { PyObject *ret; cr_Package *pkg; int checksum_type, changelog_limit; char *filename, *location_href, *location_base; GError *tmp_err = NULL; cr_HeaderReadingFlags flags = CR_HDRR_NONE; // TODO - support for flags if (!PyArg_ParseTuple(args, "sizzi:py_package_from_rpm", &filename, &checksum_type, &location_href, &location_base, &changelog_limit)) { return NULL; } pkg = cr_package_from_rpm(filename, checksum_type, location_href, location_base, changelog_limit, NULL, flags, &tmp_err); if (tmp_err) { nice_exception(&tmp_err, "Cannot load %s: ", filename); return NULL; } ret = Object_FromPackage(pkg, 1); return ret; }
static void test_all(TestData *testdata, G_GNUC_UNUSED gconstpointer test_data) { GError *err = NULL; gchar *path; cr_SqliteDb *db = NULL; cr_Package *pkg, *pkg2 = NULL; // Create new db path = g_strconcat(testdata->tmp_dir, "/", TMP_PRIMARY_NAME, NULL); db = cr_db_open_primary(path, &err); g_assert(db); g_assert(!err); g_assert(g_file_test(path, G_FILE_TEST_EXISTS)); // Try cr_db_dbinfo_update cr_db_dbinfo_update(db, "foochecksum", &err); g_assert(!err); // Load package cr_package_parser_init(); pkg = cr_package_from_rpm(EMPTY_PKG, CR_CHECKSUM_SHA256, EMPTY_PKG, NULL, 5, NULL, CR_HDRR_NONE, NULL); g_assert(pkg); cr_package_parser_cleanup(); pkg2 = get_empty_package(); // Add package cr_db_add_pkg(db, pkg, &err); g_assert(!err); cr_db_add_pkg(db, pkg2, &err); g_assert(!err); // Try cr_db_dbinfo_update again cr_db_dbinfo_update(db, "foochecksum", &err); g_assert(!err); // Cleanup cr_package_free(pkg); cr_package_free(pkg2); cr_db_close(db, &err); g_assert(!err); g_free(path); }