Skip to main content

D-Stability

VIKTOR's D-Stability integration requires a specific D-Stability worker which can be downloaded here.

Analyzing a D-Stability model in VIKTOR can be done using the DStabilityAnalysis class (worker required). No binding is provided by VIKTOR for this module, which means that the input file has to be generated manually or by using the GEOLIB:

from viktor.external.dstability import DStabilityAnalysis

# Generate the input STIX file.
input_file = ...

# Run the analysis and obtain the output file.
analysis = DStabilityAnalysis(input_file)
analysis.execute(timeout=10)
output_file = analysis.get_output_file()

Testing

New in v13.5.0

mock_DStabilityAnalysis decorator for easier testing of DStabilityAnalysis

DStabilityAnalysis.execute needs to be mocked within the context of (automated) testing.

The viktor.testing module provides the mock_DStabilityAnalysis decorator that facilitate mocking of workers:

import unittest

from viktor import File
from viktor.testing import mock_DStabilityAnalysis

from app.my_entity_type.controller import MyEntityTypeController

class TestMyEntityTypeController(unittest.TestCase):

@mock_DStabilityAnalysis(get_output_file={
'.stix': File.from_path('test_output.stix')
})
def test_dstability_analysis(self):
MyEntityTypeController().dstability_analysis()

For the decorator's input parameters the following holds:

  • If a Sequence type is provided, the next entry is returned for each corresponding method call. When a call is performed on a depleted iterable, an Exception is raised.
  • If a single object is provided, the object is returned each time the corresponding method is called (endlessly).
  • If None is provided (default), a default File/BytesIO object (with empty content) is returned each time the corresponding method is called (endlessly).