From d3c1294c05579db9dd5a1436883fe3fb78a052be Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Wed, 1 Jul 2020 00:10:07 +0200
Subject: Fixed some cases from the test suite.

---
 plugins/pychrysalide/core/constants.c    |  2 +-
 plugins/pychrysalide/glibext/constants.c |  1 +
 tests/core/logs.py                       | 14 ++++----------
 tests/glibext/binportion.py              | 17 +++++++----------
 4 files changed, 13 insertions(+), 21 deletions(-)

diff --git a/plugins/pychrysalide/core/constants.c b/plugins/pychrysalide/core/constants.c
index f3ec530..99abf95 100644
--- a/plugins/pychrysalide/core/constants.c
+++ b/plugins/pychrysalide/core/constants.c
@@ -109,7 +109,7 @@ int convert_to_log_message_type(PyObject *arg, void *dst)
         case 1:
             value = PyLong_AsUnsignedLong(arg);
 
-            if (value > LMT_COUNT)
+            if (value >= LMT_COUNT)
             {
                 PyErr_SetString(PyExc_TypeError, "invalid value for LogMessageType");
                 result = 0;
diff --git a/plugins/pychrysalide/glibext/constants.c b/plugins/pychrysalide/glibext/constants.c
index e24a6e0..47bd00d 100644
--- a/plugins/pychrysalide/glibext/constants.c
+++ b/plugins/pychrysalide/glibext/constants.c
@@ -70,6 +70,7 @@ bool define_binary_portion_constants(PyTypeObject *type)
     if (result) result = add_const_to_group(values, "READ", PAC_READ);
     if (result) result = add_const_to_group(values, "WRITE", PAC_WRITE);
     if (result) result = add_const_to_group(values, "EXEC", PAC_EXEC);
+    if (result) result = add_const_to_group(values, "ALL", PAC_ALL);
 
     if (!result)
     {
diff --git a/tests/core/logs.py b/tests/core/logs.py
index 69a4775..656d212 100644
--- a/tests/core/logs.py
+++ b/tests/core/logs.py
@@ -1,9 +1,3 @@
-#!/usr/bin/python3-dbg
-# -*- coding: utf-8 -*-
-
-
-# Tests validant le bon calcul d'empreintes.
-
 
 from chrysacase import ChrysalideTestCase
 from pychrysalide import core
@@ -15,13 +9,13 @@ class TestCoreLogs(ChrysalideTestCase):
     def testDefaultLevel(self):
         """Ensure all messages are hidden by default."""
 
-        self.assertEqual(core.get_verbosity(), core.LMT_COUNT)
+        self.assertEqual(core.get_verbosity(), core.LogMessageType.COUNT)
 
 
     def testWrongLevel(self):
         """Verify the type of level when defining new verbosity."""
 
-        with self.assertRaisesRegex(Exception, 'argument 1 must be int, not str'):
+        with self.assertRaisesRegex(Exception, 'unable to convert the provided argument to LogMessageType'):
 
             core.set_verbosity('XXX')
 
@@ -29,6 +23,6 @@ class TestCoreLogs(ChrysalideTestCase):
     def testWrongMessage(self):
         """Check for unhandled message level."""
 
-        with self.assertRaisesRegex(Exception, 'Invalid type of message'):
+        with self.assertRaisesRegex(Exception, 'invalid value for LogMessageType'):
 
-            core.log_message(core.LMT_COUNT, 'Message')
+            core.log_message(core.LogMessageType.COUNT, 'Message')
diff --git a/tests/glibext/binportion.py b/tests/glibext/binportion.py
index a95352e..8d5f3af 100644
--- a/tests/glibext/binportion.py
+++ b/tests/glibext/binportion.py
@@ -1,6 +1,3 @@
-#!/usr/bin/python3-dbg
-# -*- coding: utf-8 -*-
-
 
 from chrysacase import ChrysalideTestCase
 from pychrysalide.arch import vmpa
@@ -14,7 +11,7 @@ class TestPathNames(ChrysalideTestCase):
     def testPortionProperties(self):
         """Validate various binary portion properties."""
 
-        p = BinPortion(BinPortion.BPC_RAW, 0x102, 10)
+        p = BinPortion(BinPortion.BinaryPortionCode.RAW, 0x102, 10)
 
         p.desc = 'ABC'
         self.assertEqual(p.desc, 'ABC')
@@ -29,14 +26,14 @@ class TestPathNames(ChrysalideTestCase):
         p.continuation = False
         self.assertFalse(p.continuation)
 
-        p.rights = BinPortion.PAC_ALL
-        self.assertEqual(p.rights, BinPortion.PAC_READ | BinPortion.PAC_WRITE | BinPortion.PAC_EXEC)
+        p.rights = BinPortion.PortionAccessRights.ALL
+        self.assertEqual(p.rights, BinPortion.PortionAccessRights.READ | BinPortion.PortionAccessRights.WRITE | BinPortion.PortionAccessRights.EXEC)
 
 
     def testPortionMethods(self):
         """Validate some binary portion methods."""
 
-        p = BinPortion(BinPortion.BPC_RAW, 0x102, 10)
+        p = BinPortion(BinPortion.BinaryPortionCode.RAW, 0x102, 10)
 
         self.assertEqual(p.range.length, 10)
 
@@ -52,9 +49,9 @@ class TestPathNames(ChrysalideTestCase):
     def testPortionComparison(self):
         """Compare different binary portions."""
 
-        p0 = BinPortion(BinPortion.BPC_CODE, 0x102, 10)
+        p0 = BinPortion(BinPortion.BinaryPortionCode.CODE, 0x102, 10)
 
-        addr = vmpa(vmpa.VMPA_NO_PHYSICAL, 0x102)
-        p1 = BinPortion(BinPortion.BPC_CODE, addr, 10)
+        addr = vmpa(vmpa.VmpaSpecialValue.NO_PHYSICAL, 0x102)
+        p1 = BinPortion(BinPortion.BinaryPortionCode.CODE, addr, 10)
 
         self.assertEqual(p0, p1)
-- 
cgit v0.11.2-87-g4458