Skip to content

Commit

Permalink
Merge pull request #459 from tiiuae/cbma_adaptation_unit_test
Browse files Browse the repository at this point in the history
Cbma adaptation unit test
  • Loading branch information
saauvine committed May 23, 2024
2 parents 190b749 + f4d21af commit 85f31eb
Show file tree
Hide file tree
Showing 7 changed files with 829 additions and 79 deletions.
11 changes: 6 additions & 5 deletions modules/sc-mesh-secure-deployment/src/nats/coverage_report.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,24 @@ Name Stmts Miss Cover Missing
-----------------------------------------------------------------
mdm_agent.py 458 110 76% 115-117, 190, 209-210, 215-216, 246, 250-254, 265-273, 282-284, 290, 310-319, 325-353, 364, 378-379, 388-392, 406, 408, 441-456, 464-474, 492-496, 591, 650, 661-667, 680-681, 702, 713-719, 740-741, 748-749, 756-757, 787-793, 796-817, 825-827, 833, 853-854, 864, 921
src/__init__.py 0 0 100%
src/bat_ctrl_utils.py 130 19 85% 40-41, 78-79, 135-136, 161-162, 173, 193-194, 224-225, 254-263, 277-279
src/cbma_adaptation.py 458 372 19% 81-82, 90-102, 112-181, 184-192, 195-219, 225-239, 242-249, 257-294, 297-302, 309-319, 322-325, 328-338, 341-348, 352-399, 403-419, 422-462, 470-483, 486-511, 518-532, 536-563, 578-606, 616-647, 657-668, 671-682, 693-721, 729-765, 774-845, 848-855, 864-874, 882-891
src/bat_ctrl_utils.py 129 16 88% 77-78, 134-135, 160-161, 172, 192-193, 223-224, 253-254, 276-278
src/cbma_adaptation.py 518 53 90% 130-131, 257-258, 333, 381-382, 434-436, 502, 546-549, 563, 590-592, 629-630, 647-648, 653-657, 660-661, 671, 704-705, 735-736, 775-777, 790, 806-810, 826-827, 867-868, 899, 913-924, 947-948, 978-979
src/cbma_paths.py 7 0 100%
src/comms_command.py 192 39 80% 88, 90, 94-102, 105, 107, 112, 117, 121, 142-144, 147-150, 155-157, 164, 175, 189-190, 235-240, 251, 262, 291, 309-310, 322, 336-337, 349, 373-375
src/comms_common.py 26 0 100%
src/comms_config_store.py 21 0 100%
src/comms_controller.py 38 5 87% 33, 48, 79-82
src/comms_if_monitor.py 56 2 96% 95-96
src/comms_service_discovery.py 88 14 84% 114-115, 147, 152-153, 162, 180-211
src/comms_settings.py 253 27 89% 12-13, 156-157, 172-192, 257-264, 320-323, 363, 370
src/comms_settings.py 253 25 90% 156-157, 172-192, 257-264, 320-323, 363, 370
src/comms_status.py 302 23 92% 70, 194, 225-227, 240-242, 247, 251-253, 257-261, 270, 278, 294, 302, 330, 433, 436-438
src/constants.py 44 0 100%
src/constants.py 47 0 100%
src/interface.py 5 0 100%
src/validation.py 104 2 98% 221-222
tests/__init__.py 0 0 100%
tests/service_discovery_helper.py 22 0 100%
tests/test_bat_ctrl_utils.py 129 10 92% 232-233, 241-242, 245-246, 249-250, 253-254
tests/test_cbma_adaptation.py 248 8 97% 274-277, 282-283, 292-293
tests/test_command.py 210 0 100%
tests/test_config_store.py 26 0 100%
tests/test_constants.py 27 0 100%
Expand All @@ -30,6 +31,6 @@ tests/test_settings.py 173 0 100%
tests/test_status.py 128 8 94% 28-35
tests/test_validation.py 146 0 100%
-----------------------------------------------------------------
TOTAL 3621 638 82%
TOTAL 3931 322 92%
Not tested files as not MDM content or tested elsewhere:
batadvvis.py,batstat.py,fmo_agent.py,comms_nats_discovery.py,cbma/*,debug_tests/*,comms_mesh_telemetry.py,comms_interface_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ python3 -m venv unittest
source unittest/bin/activate

# install dependencies to virtualenv
pip install coverage==7.4.4 # this is for testing purpose
pip install -r requirements.txt
# install testing only related dependencies
pip install -r ./tests/requirements.txt

# List of files not to used for coverage calculation.
# Files tested elsewhere or not needed to be tested or not mesh shield content
Expand All @@ -43,3 +44,9 @@ echo -e "Not tested files as not MDM content or tested elsewhere:\n $not_used" >
# deactivate virtualenv
deactivate

# Clean up __pycache__ directories
find . -type d -name '__pycache__' -exec rm -rf {} +
# Clean up unittest venv
rm -rf unittest
# Clean up coverage tool's SQL database
rm -f .coverage
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import logging
import subprocess
from typing import Optional, Union
import re
from pyroute2 import IPRoute # type: ignore[import-not-found, import-untyped]

from src.constants import Constants
Expand Down Expand Up @@ -73,8 +72,8 @@ def create_batman_interface(
ip.link("add", ifname=batman_if, kind="batadv", address=mac_addr)
else:
ip.link("add", ifname=batman_if, kind="batadv")
# Add interface to the book keeping list
self.__bat_interfaces.append(batman_if)
# Add interface to the book keeping list
self.__bat_interfaces.append(batman_if)
except Exception as e:
self.logger.error(
"Error creating Batman interface %s: %s",
Expand Down
Loading

0 comments on commit 85f31eb

Please sign in to comment.