src/python/key.h \
src/python/package.c \
src/python/package.h \
- src/python/pakfire.c \
- src/python/pakfire.h \
src/python/problem.c \
src/python/problem.h \
src/python/repo.c \
src/python/repo.h \
+ src/python/root.c \
+ src/python/root.h \
src/python/solution.c \
src/python/solution.h \
src/python/transaction.c \
#include "key.h"
#include "package.h"
#include "repo.h"
+#include "root.h"
#include "util.h"
PyObject* new_archive(PyTypeObject* type, pakfire_archive* archive) {
}
static int Archive_init(ArchiveObject* self, PyObject* args, PyObject* kwds) {
- PakfireObject* pakfire = NULL;
+ RootObject* root = NULL;
const char* filename = NULL;
- if (!PyArg_ParseTuple(args, "O!s", &PakfireType, &pakfire, &filename))
+ if (!PyArg_ParseTuple(args, "O!s", &RootType, &root, &filename))
return -1;
- errno = -pakfire_archive_open(&self->archive, pakfire->root, filename);
+ errno = -pakfire_archive_open(&self->archive, root->root, filename);
if (errno) {
PyErr_SetFromErrno(PyExc_OSError);
return -1;
#include <pakfire/file.h>
#include "file.h"
-#include "pakfire.h"
+#include "root.h"
#include "util.h"
PyObject* new_file(PyTypeObject* type, pakfire_file* file) {
#include <pakfire/util.h>
#include "key.h"
-#include "pakfire.h"
+#include "root.h"
#include "util.h"
PyObject* new_key(PyTypeObject* type, pakfire_key* key) {
#include "errors.h"
#include "package.h"
-#include "pakfire.h"
#include "repo.h"
+#include "root.h"
#include "util.h"
PyObject* new_package(PyTypeObject* type, pakfire_package* pkg) {
}
static int Package_init(PackageObject* self, PyObject* args, PyObject* kwds) {
- PakfireObject* pakfire = NULL;
+ RootObject* root = NULL;
RepoObject* repo = NULL;
const char* name = NULL;
const char* evr = NULL;
int r;
if (!PyArg_ParseTuple(args, "O!O!sss",
- &PakfireType, &pakfire, &RepoType, &repo, &name, &evr, &arch))
+ &RootType, &root, &RepoType, &repo, &name, &evr, &arch))
return -1;
// Create the package object
- r = pakfire_package_create(&self->package, pakfire->root, repo->repo, name, evr, arch);
+ r = pakfire_package_create(&self->package, root->root, repo->repo, name, evr, arch);
if (r < 0) {
errno = -r;
PyErr_SetFromErrno(PyExc_OSError);
#include <Python.h>
-#include <pakfire/ctx.h>
#include <pakfire/package.h>
-#include "pakfire.h"
-
typedef struct {
PyObject_HEAD
pakfire_package* package;
#include "file.h"
#include "key.h"
#include "package.h"
-#include "pakfire.h"
#include "problem.h"
#include "repo.h"
+#include "root.h"
#include "solution.h"
#include "transaction.h"
#include "util.h"
Py_INCREF(PyExc_DependencyError);
PyModule_AddObject(module, "DependencyError", PyExc_DependencyError);
- // Pakfire
- if (PyType_Ready(&PakfireType) < 0)
- return NULL;
-
- Py_INCREF(&PakfireType);
- PyModule_AddObject(module, "Pakfire", (PyObject *)&PakfireType);
-
// Archive
if (PyType_Ready(&ArchiveType) < 0)
return NULL;
Py_INCREF(&RepoType);
PyModule_AddObject(module, "Repo", (PyObject *)&RepoType);
+ // Root
+ if (PyType_Ready(&RootType) < 0)
+ return NULL;
+
+ Py_INCREF(&RootType);
+ PyModule_AddObject(module, "Root", (PyObject *)&RootType);
+
// Solution
if (PyType_Ready(&SolutionType) < 0)
return NULL;
#include "key.h"
#include "package.h"
#include "repo.h"
+#include "root.h"
PyObject* new_repo(PyTypeObject* type, pakfire_repo* repo) {
RepoObject* self = (RepoObject *)type->tp_alloc(type, 0);
}
static int Repo_init(RepoObject* self, PyObject* args, PyObject* kwds) {
- PakfireObject* pakfire;
+ RootObject* root = NULL;
const char* name;
int clean = 0;
- if (!PyArg_ParseTuple(args, "O!s|i", &PakfireType, &pakfire, &name, &clean))
+ if (!PyArg_ParseTuple(args, "O!s|i", &RootType, &root, &name, &clean))
return -1;
// Create a new repository
- int r = pakfire_repo_create(&self->repo, pakfire->root, name);
+ int r = pakfire_repo_create(&self->repo, root->root, name);
if (r) {
PyErr_SetFromErrno(PyExc_OSError);
return -1;
#include <pakfire/repo.h>
-#include "pakfire.h"
-
typedef struct {
PyObject_HEAD
pakfire_repo* repo;
#include "ctx.h"
#include "errors.h"
#include "key.h"
-#include "pakfire.h"
#include "repo.h"
+#include "root.h"
#include "util.h"
-static PyObject* Pakfire_new(PyTypeObject* type, PyObject* args, PyObject* kwds) {
- PakfireObject* self = (PakfireObject *)type->tp_alloc(type, 0);
+static PyObject* Root_new(PyTypeObject* type, PyObject* args, PyObject* kwds) {
+ RootObject* self = (RootObject *)type->tp_alloc(type, 0);
if (self) {
self->ctx = NULL;
self->root = NULL;
return (PyObject *)self;
}
-static int Pakfire_init(PakfireObject* self, PyObject* args, PyObject* kwds) {
+static int Root_init(RootObject* self, PyObject* args, PyObject* kwds) {
const char* kwlist[] = { "ctx", "path", "arch", "config", "stub", NULL };
pakfire_config* c = NULL;
const char* config = NULL;
return r;
}
-static void Pakfire_dealloc(PakfireObject* self) {
+static void Root_dealloc(RootObject* self) {
Py_BEGIN_ALLOW_THREADS
if (self->root)
Py_TYPE(self)->tp_free((PyObject *)self);
}
-static PyObject* Pakfire_repr(PakfireObject* self) {
+static PyObject* Root_repr(RootObject* self) {
const char* path = pakfire_root_get_path(self->root);
const char* arch = pakfire_root_get_arch(self->root);
- return PyUnicode_FromFormat("<_pakfire.Pakfire %s (%s)>", path, arch);
+ return PyUnicode_FromFormat("<_pakfire.Root %s (%s)>", path, arch);
}
-static PyObject* Pakfire_get_path(PakfireObject* self) {
+static PyObject* Root_get_path(RootObject* self) {
const char* path = pakfire_root_get_path(self->root);
return PyUnicode_FromString(path);
}
-static PyObject* Pakfire_get_arch(PakfireObject* self) {
+static PyObject* Root_get_arch(RootObject* self) {
const char* arch = pakfire_root_get_arch(self->root);
return PyUnicode_FromString(arch);
}
-static PyObject* Pakfire_get_repo(PakfireObject* self, PyObject* args) {
+static PyObject* Root_get_repo(RootObject* self, PyObject* args) {
const char* name = NULL;
if (!PyArg_ParseTuple(args, "s", &name))
/*
XXX This could be moved out of here as this no longer depends on Pakfire
*/
-static PyObject* Pakfire_generate_key(PakfireObject* self, PyObject* args, PyObject* kwds) {
+static PyObject* Root_generate_key(RootObject* self, PyObject* args, PyObject* kwds) {
const char* kwlist[] = { "algorithm", "comment", NULL };
pakfire_key* key = NULL;
pakfire_key_algo_t algo = PAKFIRE_KEY_ALGO_NULL;
/*
XXX This could be moved out of here as this no longer depends on Pakfire
*/
-static PyObject* Pakfire_import_key(PakfireObject* self, PyObject* args) {
+static PyObject* Root_import_key(RootObject* self, PyObject* args) {
pakfire_key* key = NULL;
PyObject* object = NULL;
char* data = NULL;
return object;
}
-static PyObject* Pakfire_whatprovides(PakfireObject* self, PyObject* args) {
+static PyObject* Root_whatprovides(RootObject* self, PyObject* args) {
const char* provides = NULL;
pakfire_packagelist* list = NULL;
PyObject* ret = NULL;
return ret;
}
-static PyObject* Pakfire_whatrequires(PakfireObject* self, PyObject* args) {
+static PyObject* Root_whatrequires(RootObject* self, PyObject* args) {
pakfire_packagelist* list = NULL;
const char* requires = NULL;
PyObject* ret = NULL;
return ret;
}
-static PyObject* Pakfire_search(PakfireObject* self, PyObject* args, PyObject* kwds) {
+static PyObject* Root_search(RootObject* self, PyObject* args, PyObject* kwds) {
const char* kwlist[] = { "pattern", "name_only", NULL };
pakfire_packagelist* list = NULL;
const char* pattern = NULL;
return ret;
}
-static PyObject* Pakfire_version_compare(PakfireObject* self, PyObject* args) {
+static PyObject* Root_version_compare(RootObject* self, PyObject* args) {
const char* evr1 = NULL;
const char* evr2 = NULL;
return PyLong_FromLong(cmp);
}
-static PyObject* Pakfire_dist(PakfireObject* self, PyObject* args) {
+static PyObject* Root_dist(RootObject* self, PyObject* args) {
pakfire_archive* archive = NULL;
const char* path = NULL;
PyObject* ret = NULL;
return ret;
}
-static PyObject* Pakfire_get_repos(PakfireObject* self) {
+static PyObject* Root_get_repos(RootObject* self) {
pakfire_repolist* repos = pakfire_root_get_repos(self->root);
if (!repos) {
PyErr_SetFromErrno(PyExc_OSError);
return list;
}
-static PyObject* Pakfire_clean(PakfireObject* self) {
+static PyObject* Root_clean(RootObject* self) {
int r;
Py_BEGIN_ALLOW_THREADS
Py_RETURN_NONE;
}
-static PyObject* Pakfire_open(PakfireObject* self, PyObject* args) {
+static PyObject* Root_open(RootObject* self, PyObject* args) {
pakfire_archive* archive = NULL;
const char* path = NULL;
return object;
}
-static PyObject* Pakfire_repo_compose(PakfireObject* self, PyObject* args, PyObject* kwargs) {
+static PyObject* Root_repo_compose(RootObject* self, PyObject* args, PyObject* kwargs) {
const char* kwlist[] = { "path", "files", "key", NULL };
const char* path = NULL;
PyObject* list = NULL;
PyObject* stderr;
};
-static int Pakfire_execute_stdout_callback(pakfire_ctx* ctx, void* data,
+static int Root_execute_stdout_callback(pakfire_ctx* ctx, void* data,
const enum pakfire_jail_output_stream stream, const char* line, const size_t length) {
struct Pakfire_execute_output* output = data;
PyObject* chunk = NULL;
return 0;
}
-static PyObject* Pakfire_execute(PakfireObject* self, PyObject* args, PyObject* kwargs) {
+static PyObject* Root_execute(RootObject* self, PyObject* args, PyObject* kwargs) {
struct pakfire_input_buffer input = {};
pakfire_jail* jail = NULL;
pakfire_env* env = NULL;
// Execute command
r = pakfire_jail_communicate(jail, argv, env, 0,
- input_callback, &input, Pakfire_execute_stdout_callback, &output);
+ input_callback, &input, Root_execute_stdout_callback, &output);
Py_END_ALLOW_THREADS
return ret;
}
-static struct PyMethodDef Pakfire_methods[] = {
+static struct PyMethodDef Root_methods[] = {
{
"clean",
- (PyCFunction)Pakfire_clean,
+ (PyCFunction)Root_clean,
METH_NOARGS,
NULL,
},
{
"dist",
- (PyCFunction)Pakfire_dist,
+ (PyCFunction)Root_dist,
METH_VARARGS,
NULL
},
{
"execute",
- (PyCFunction)Pakfire_execute,
+ (PyCFunction)Root_execute,
METH_VARARGS|METH_KEYWORDS,
NULL,
},
{
"generate_key",
- (PyCFunction)Pakfire_generate_key,
+ (PyCFunction)Root_generate_key,
METH_VARARGS|METH_KEYWORDS,
NULL
},
{
"get_repo",
- (PyCFunction)Pakfire_get_repo,
+ (PyCFunction)Root_get_repo,
METH_VARARGS,
NULL
},
{
"import_key",
- (PyCFunction)Pakfire_import_key,
+ (PyCFunction)Root_import_key,
METH_VARARGS,
NULL,
},
{
"open",
- (PyCFunction)Pakfire_open,
+ (PyCFunction)Root_open,
METH_VARARGS,
NULL
},
{
"repo_compose",
- (PyCFunction)Pakfire_repo_compose,
+ (PyCFunction)Root_repo_compose,
METH_VARARGS|METH_KEYWORDS,
NULL
},
{
"search",
- (PyCFunction)Pakfire_search,
+ (PyCFunction)Root_search,
METH_VARARGS|METH_KEYWORDS,
NULL
},
{
"version_compare",
- (PyCFunction)Pakfire_version_compare,
+ (PyCFunction)Root_version_compare,
METH_VARARGS,
NULL
},
{
"whatprovides",
- (PyCFunction)Pakfire_whatprovides,
+ (PyCFunction)Root_whatprovides,
METH_VARARGS,
NULL
},
{
"whatrequires",
- (PyCFunction)Pakfire_whatrequires,
+ (PyCFunction)Root_whatrequires,
METH_VARARGS,
NULL
},
{ NULL },
};
-static struct PyGetSetDef Pakfire_getsetters[] = {
+static struct PyGetSetDef Root_getsetters[] = {
{
"arch",
- (getter)Pakfire_get_arch,
+ (getter)Root_get_arch,
NULL,
NULL,
NULL
},
{
"path",
- (getter)Pakfire_get_path,
+ (getter)Root_get_path,
NULL,
NULL,
NULL
},
{
"repos",
- (getter)Pakfire_get_repos,
+ (getter)Root_get_repos,
NULL,
NULL,
NULL
{ NULL },
};
-PyTypeObject PakfireType = {
+PyTypeObject RootType = {
PyVarObject_HEAD_INIT(NULL, 0)
- .tp_name = "pakfire.Pakfire",
- .tp_basicsize = sizeof(PakfireObject),
+ .tp_name = "pakfire.Root",
+ .tp_basicsize = sizeof(RootObject),
.tp_flags = Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE,
- .tp_new = Pakfire_new,
- .tp_dealloc = (destructor)Pakfire_dealloc,
- .tp_init = (initproc)Pakfire_init,
- .tp_doc = "Pakfire Object",
- .tp_methods = Pakfire_methods,
- .tp_getset = Pakfire_getsetters,
- .tp_repr = (reprfunc)Pakfire_repr,
+ .tp_new = Root_new,
+ .tp_dealloc = (destructor)Root_dealloc,
+ .tp_init = (initproc)Root_init,
+ .tp_doc = "Root Object",
+ .tp_methods = Root_methods,
+ .tp_getset = Root_getsetters,
+ .tp_repr = (reprfunc)Root_repr,
};
# #
#############################################################################*/
-#ifndef PYTHON_PAKFIRE_PAKFIRE_H
-#define PYTHON_PAKFIRE_PAKFIRE_H
+#ifndef PYTHON_PAKFIRE_ROOT_H
+#define PYTHON_PAKFIRE_ROOT_H
#include <Python.h>
// Root
pakfire_root* root;
-} PakfireObject;
+} RootObject;
-extern PyTypeObject PakfireType;
+extern PyTypeObject RootType;
-#endif /* PYTHON_PAKFIRE_PAKFIRE_H */
+#endif /* PYTHON_PAKFIRE_ROOT_H */
#include <pakfire/transaction.h>
#include "errors.h"
-#include "pakfire.h"
+#include "root.h"
#include "transaction.h"
static PyObject* Transaction_new(PyTypeObject* type, PyObject* args, PyObject* kwds) {
}
static int Transaction_init(TransactionObject* self, PyObject* args, PyObject* kwargs) {
- PakfireObject* pakfire = NULL;
+ RootObject* root = NULL;
int allow_downgrade = 0;
int allow_uninstall = 0;
int without_recommended = 0;
};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!|bbb", (char**)kwlist,
- &PakfireType, &pakfire, &allow_downgrade, &allow_uninstall, &without_recommended))
+ &RootType, &root, &allow_downgrade, &allow_uninstall, &without_recommended))
return -1;
if (allow_downgrade)
flags |= PAKFIRE_TRANSACTION_WITHOUT_RECOMMENDED;
// Create a new transaction
- r = pakfire_transaction_create(&self->transaction, pakfire->root, flags);
+ r = pakfire_transaction_create(&self->transaction, root->root, flags);
if (r < 0) {
errno = -r;
PyErr_SetFromErrno(PyExc_OSError);
This tests the Package class
"""
def setUp(self):
- self.pakfire = self.setup_pakfire()
+ self.root = self.setup_root()
def test_open(self):
"""
path = self.path("beep-1.3-2.ip3.x86_64.pfm")
# Open the archive
- archive = self.pakfire.open(path)
+ archive = self.root.open(path)
# Read back the path
self.assertEqual(archive.path, path)
path = self.path("beep-1.3-2.ip3.x86_64.pfm")
# Open the archive
- archive = self.pakfire.open(path)
+ archive = self.root.open(path)
# Check that we read the entire list of 7 files
self.assertEqual(len(archive.filelist), 7)
path = self.path("beep-1.3-2.ip3.x86_64.pfm")
# Open the archive
- archive = self.pakfire.open(path)
+ archive = self.root.open(path)
# Try opening /usr/bin/beep
f = archive.read("/usr/bin/beep")
path = self.path("beep-1.3-2.ip3.x86_64.pfm")
# Open the archive
- archive = self.pakfire.open(path)
+ archive = self.root.open(path)
with self.tempdir() as t:
# Perform extraction
path = self.path("beep-1.3-2.ip3.x86_64.pfm")
# Open the archive
- archive = self.pakfire.open(path)
+ archive = self.root.open(path)
# Fetch the package metadata
package = archive.get_package()
def test_open_stub(self):
# Launch Pakfire in stub mode
- p = self.setup_pakfire(stub=True)
+ p = self.setup_root(stub=True)
# Make path
path = self.path("beep-1.3-2.ip3.x86_64.pfm")
# Open the archive
- archive = self.pakfire.open(path)
+ archive = self.root.open(path)
# Fetch the filelist
self.assertIsInstance(archive.filelist, list)
logger = logging.getLogger("pakfire")
with self.assertLogs(logger, logging.DEBUG):
- self.setup_pakfire()
+ self.setup_root()
def test_log_custom(self):
"""
ctx.set_logger(logger)
# Create a new Pakfire instance to create some log messages
- self.setup_pakfire(ctx=ctx)
+ self.setup_root(ctx=ctx)
# Check if we have received anything
self.assertTrue(logger.buffer)
This tests the dist command
"""
def setUp(self):
- self.pakfire = self.setup_pakfire()
+ self.root = self.setup_root()
def test_dist(self):
"""
makefile = os.path.join(TEST_DATA_DIR, "packages/dummy/dummy.nm")
# Run dist()
- archive = self.pakfire.dist(makefile)
+ archive = self.root.dist(makefile)
self.assertIsInstance(archive, pakfire.Archive)
This tests the execute command
"""
def setUp(self):
- self.pakfire = self.setup_pakfire()
+ self.root = self.setup_root()
# XXX Temporarily disabled, because the jail messes up the console
def test_execute(self):
- r = self.pakfire.execute(["/command", "exit-with-code", "0"])
+ r = self.root.execute(["/command", "exit-with-code", "0"])
self.assertIsNone(r)
def test_return_value(self):
with self.assertRaises(pakfire.CommandExecutionError) as e:
- self.pakfire.execute(["/command", "exit-with-code", "123"])
+ self.root.execute(["/command", "exit-with-code", "123"])
# Extract return code
code, output = e.exception.args
self.assertIsInstance(output, bytes)
def test_environ(self):
- r = self.pakfire.execute(["/command", "echo-environ", "VAR1"],
+ r = self.root.execute(["/command", "echo-environ", "VAR1"],
environ={"VAR1" : "VAL1"})
self.assertIsNone(r)
def test_invalid_inputs(self):
# Arguments
with self.assertRaises(TypeError):
- self.pakfire.execute("/command")
+ self.root.execute("/command")
with self.assertRaises(TypeError):
- self.pakfire.execute(["/command", 1])
+ self.root.execute(["/command", 1])
with self.assertRaises(TypeError):
- self.pakfire.execute(("/command", "--help"))
+ self.root.execute(("/command", "--help"))
# Environment
with self.assertRaises(TypeError):
- self.pakfire.execute(["/command", "--help"], environ={"VAR1" : 1})
+ self.root.execute(["/command", "--help"], environ={"VAR1" : 1})
with self.assertRaises(TypeError):
- self.pakfire.execute(["/command", "--help"], environ={1 : "VAL1"})
+ self.root.execute(["/command", "--help"], environ={1 : "VAL1"})
with self.assertRaises(TypeError):
- self.pakfire.execute(["/command", "--help"], environ="VAR1=VAL1")
+ self.root.execute(["/command", "--help"], environ="VAR1=VAL1")
def test_execute_non_existant_command(self):
"""
Executing non-existant commands should raise an error
"""
with self.assertRaises(pakfire.CommandExecutionError):
- self.pakfire.execute(["/command-does-not-exist"])
+ self.root.execute(["/command-does-not-exist"])
def test_execute_output(self):
self.assertEqual(
- self.pakfire.execute(["/command", "echo", "123"], return_output=True),
+ self.root.execute(["/command", "echo", "123"], return_output=True),
b"123\n",
)
# Multiple newlines in one read
self.assertEqual(
- self.pakfire.execute(["/command", "echo", "1\n2\n3"], return_output=True),
+ self.root.execute(["/command", "echo", "1\n2\n3"], return_output=True),
b"1\n2\n3\n",
)
# Run a command with a lot of output which exceeds the buffer size
- self.pakfire.execute(["/command", "lines", "1", "65536"])
+ self.root.execute(["/command", "lines", "1", "65536"])
# Run a command that generates lots of lines
- output = self.pakfire.execute(["/command", "lines", "100", "40"], return_output=True)
+ output = self.root.execute(["/command", "lines", "100", "40"], return_output=True)
self.assertEqual(output.count(b"\n"), 100)
def test_execute_input(self):
output = input
# Pipe the data through the command
- output = self.pakfire.execute(["/command", "pipe"],
+ output = self.root.execute(["/command", "pipe"],
input=input, return_output=True)
# Input and output must match
# Ensure that we won't run forever in case the command cannot be found
with self.assertRaises(pakfire.CommandExecutionError):
- self.pakfire.execute(["/does-not-exist"], input=b"1234")
+ self.root.execute(["/does-not-exist"], input=b"1234")
def test_execute_bind(self):
"""
mountpoint = self.path()
# Check if this is actually a mountpoint
- self.pakfire.execute(["/command", "check-mountpoint", mountpoint], bind=[mountpoint])
+ self.root.execute(["/command", "check-mountpoint", mountpoint], bind=[mountpoint])
# Try some invalid inputs
with self.assertRaises(TypeError):
- self.pakfire.execute(["/command", "exit-with-code", "0"], bind="/something")
+ self.root.execute(["/command", "exit-with-code", "0"], bind="/something")
with self.assertRaises(TypeError):
- self.pakfire.execute(["/command", "exit-with-code", "0"], bind=[123])
+ self.root.execute(["/command", "exit-with-code", "0"], bind=[123])
def test_nice(self):
"""
Check if the jail is able to set the nice level
"""
- output = self.pakfire.execute(["/command", "print-nice"],
+ output = self.root.execute(["/command", "print-nice"],
nice=5, return_output=True)
# Check that we have received 5
Tries using an invalid nice value
"""
with self.assertRaises(OSError):
- self.pakfire.execute(["/command", "print-nice"], nice=100)
+ self.root.execute(["/command", "print-nice"], nice=100)
def test_check_open_file_descriptors(self):
"""
Since we are spawning child processes, it might happen that we leak file
descriptors to the child process.
"""
- self.pakfire.execute(["/command", "check-open-file-descriptors"])
+ self.root.execute(["/command", "check-open-file-descriptors"])
# Signals
"""
Sends a stupid signal which doesn't do anything
"""
- self.pakfire.execute(["/command", "send-signal", "0"])
+ self.root.execute(["/command", "send-signal", "0"])
def test_send_signal_KILL(self):
"""
Test the process killing itself
"""
- self.pakfire.execute(["/command", "send-signal", "9"])
+ self.root.execute(["/command", "send-signal", "9"])
def test_send_signal_TERM(self):
"""
Test the process terminating itself
"""
- self.pakfire.execute(["/command", "send-signal", "15"])
+ self.root.execute(["/command", "send-signal", "15"])
if __name__ == "__main__":
This tests the keys
"""
def setUp(self):
- self.pakfire = self.setup_pakfire()
+ self.root = self.setup_root()
def test_generate(self):
"""
Generate a new key
"""
- key = self.pakfire.generate_key(
+ key = self.root.generate_key(
algorithm=pakfire.PAKFIRE_KEY_ALGO_ED25519, comment="Key 1")
# Check if we got the correct type
with self.open(path) as f:
payload = f.read()
- return self.pakfire.import_key(payload)
+ return self.root.import_key(payload)
def test_import_public_key(self):
# Import a public key
"""
Generate a new key
"""
- key = self.pakfire.generate_key(
+ key = self.root.generate_key(
algorithm=pakfire.PAKFIRE_KEY_ALGO_ED25519, comment="Key 1")
data = b"Pakfire"
This tests the main Pakfire class
"""
def test_repr(self):
- p = self.setup_pakfire()
+ p = self.setup_root()
self.assertIn("Pakfire", repr(p))
def test_properties(self):
- p = self.setup_pakfire()
+ p = self.setup_root()
# Fetch the path and check if it is absolute
self.assertTrue(p.path.startswith("/"))
self.assertIn(p.arch, pakfire.supported_arches())
def test_repo(self):
- p = self.setup_pakfire()
+ p = self.setup_root()
# Fetch a repository
repo = p.get_repo("@system")
self.assertIsInstance(repo, pakfire.Repo)
def test_whatprovides_whatrequires(self):
- p = self.setup_pakfire()
+ p = self.setup_root()
self.assertIsInstance(p.whatprovides("bash"), list)
self.assertIsInstance(p.whatrequires("bash"), list)
This tests the Package class
"""
def setUp(self):
- self.pakfire = self.setup_pakfire()
+ self.root = self.setup_root()
def test_open(self):
path = self.path("beep-1.3-2.ip3.x86_64.pfm")
# Open the archive
- a = self.pakfire.open(path)
+ a = self.root.open(path)
# Fetch the package
p = a.get_package()
# Return a new context
return pakfire.Ctx(path=path, **kwargs)
- def setup_pakfire(self, ctx=None, path=None, config=None, stub=False, **kwargs):
+ def setup_root(self, ctx=None, path=None, config=None, stub=False, **kwargs):
"""
- Sets up a new Pakfire environment
+ Sets up a new root
"""
# Create a context if none given
if ctx is None:
with open(config, "r") as f:
config = f.read()
- return pakfire.Pakfire(ctx=ctx, path=path, config=config, stub=stub, **kwargs)
+ return pakfire.Root(ctx=ctx, path=path, config=config, stub=stub, **kwargs)
def path(self, *args, **kwargs):
"""
This tests the Transaction class
"""
def setUp(self):
- self.pakfire = self.setup_pakfire()
+ self.root = self.setup_root()
def test_create(self):
# Create a new transaction
- t = pakfire.Transaction(self.pakfire)
+ t = pakfire.Transaction(self.root)
# Ensure we get a transaction
self.assertIsInstance(t, pakfire.Transaction)
"""
Performs some very simple operations which should all fail
"""
- t = pakfire.Transaction(self.pakfire)
+ t = pakfire.Transaction(self.root)
# Install a few packages
t.install("a", essential=True)