Skip to content

Commit

Permalink
Applied updates and worked on tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz committed Jan 10, 2024
1 parent 2ff843f commit dfc15fe
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 27 deletions.
4 changes: 2 additions & 2 deletions config/dpkg/changelog
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
esedb-kb (20231228-1) unstable; urgency=low
esedb-kb (20240110-1) unstable; urgency=low

* Auto-generated

-- Joachim Metz <[email protected]> Thu, 28 Dec 2023 06:24:19 +0100
-- Joachim Metz <[email protected]> Wed, 10 Jan 2024 05:43:55 +0100
30 changes: 15 additions & 15 deletions docs/sources/api/esedbrc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,42 @@ esedbrc package
Submodules
----------

esedbrc.catalog\_extractor module
---------------------------------
esedbrc.definitions module
--------------------------

.. automodule:: esedbrc.catalog_extractor
.. automodule:: esedbrc.definitions
:members:
:undoc-members:
:show-inheritance:

esedbrc.database module
-----------------------
esedbrc.file\_entry\_lister module
----------------------------------

.. automodule:: esedbrc.database
.. automodule:: esedbrc.file_entry_lister
:members:
:undoc-members:
:show-inheritance:

esedbrc.definitions module
--------------------------
esedbrc.resources module
------------------------

.. automodule:: esedbrc.definitions
.. automodule:: esedbrc.resources
:members:
:undoc-members:
:show-inheritance:

esedbrc.file\_entry\_lister module
----------------------------------
esedbrc.schema\_extractor module
--------------------------------

.. automodule:: esedbrc.file_entry_lister
.. automodule:: esedbrc.schema_extractor
:members:
:undoc-members:
:show-inheritance:

esedbrc.resources module
------------------------
esedbrc.yaml\_definitions\_file module
--------------------------------------

.. automodule:: esedbrc.resources
.. automodule:: esedbrc.yaml_definitions_file
:members:
:undoc-members:
:show-inheritance:
Expand Down
2 changes: 1 addition & 1 deletion esedbrc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
"""Extensible Storage Engine (ESE) Database resources (esedbrc)."""

__version__ = '20231228'
__version__ = '20240110'
8 changes: 4 additions & 4 deletions esedbrc/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def __init__(self, column_identifier, column_name, column_type):
"""Initializes an ESE database column definition.
Args:
column_identifier (str): column identifier.
column_identifier (int): column identifier.
column_name (str): column name.
column_type (str): column type.
column_type (int): column type.
"""
super(EseColumnDefinition, self).__init__()
self.identifier = column_identifier
Expand Down Expand Up @@ -83,9 +83,9 @@ def AddColumnDefinition(self, column_identifier, column_name, column_type):
"""Adds a column.
Args:
column_identifier (str): column identifier.
column_identifier (int): column identifier.
column_name (str): column name.
column_type (str): column type.
column_type (int): column type.
"""
ese_column_definition = EseColumnDefinition(
column_identifier, column_name, column_type)
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = esedbrc
version = 20240108
version = 20240110
description = Extensible Storage Engine (ESE) database resources (esedbrc)
long_description = esedbrc is a Python module part of esedb-kb to allow reuse of Extensible Storage Engine (ESE) database resources.
long_description_content_type = text/plain
Expand Down
52 changes: 48 additions & 4 deletions tests/schema_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
# -*- coding: utf-8 -*-
"""Tests for the ESE database schema extractor."""

import io
import os
import unittest

import artifacts

from esedbrc import resources
from esedbrc import schema_extractor

from tests import test_lib
Expand All @@ -14,14 +19,53 @@ class EseDbSchemaExtractorTest(test_lib.BaseTestCase):

# pylint: disable=protected-access

_ARTIFACT_DEFINITIONS_PATH = os.path.join(
os.path.dirname(artifacts.__file__), 'data')
if not os.path.isdir(_ARTIFACT_DEFINITIONS_PATH):
_ARTIFACT_DEFINITIONS_PATH = os.path.join(
'/', 'usr', 'share', 'artifacts')

def testInitialize(self):
"""Tests the __init__ function."""
# TODO: pass artifact definitions path.
test_extractor = schema_extractor.EseDbSchemaExtractor(None)
test_extractor = schema_extractor.EseDbSchemaExtractor(
self._ARTIFACT_DEFINITIONS_PATH)
self.assertIsNotNone(test_extractor)

# TODO: add tests for _CheckSignature
# TODO: add tests for _FormatSchemaAsYAML
def testCheckSignature(self):
"""Tests the _CheckSignature function."""
test_extractor = schema_extractor.EseDbSchemaExtractor(
self._ARTIFACT_DEFINITIONS_PATH)

file_object = io.BytesIO(b'\x00\x00\x00\x00\xef\xcd\xab\x89')
result = test_extractor._CheckSignature(file_object)
self.assertTrue(result)

file_object = io.BytesIO(b'\x00\x00\x00\x00\xff\xff\xff\xff')
result = test_extractor._CheckSignature(file_object)
self.assertFalse(result)

def testFormatSchemaAsYAML(self):
"""Tests the _FormatSchemaAsYAML function."""
test_extractor = schema_extractor.EseDbSchemaExtractor(
self._ARTIFACT_DEFINITIONS_PATH)

table_definition = resources.EseTableDefinition('MyTable', None)

table_definition.AddColumnDefinition(1, 'MyColumn', 4)

yaml_data = test_extractor._FormatSchemaAsYAML([table_definition])

expected_yaml_data = '\n'.join([
'# esedb-kb database schema.',
'---',
'table: MyTable',
'columns:',
'- name: MyColumn',
' value_type: 4',
''])

self.assertEqual(yaml_data, expected_yaml_data)

# TODO: add tests for _GetDatabaseSchema
# TODO: add tests for _GetDatabaseIdentifier
# TODO: add tests for _GetDatabaseSchemaFromFileObject
Expand Down

0 comments on commit dfc15fe

Please sign in to comment.