#!/usr/bin/env python3 """Packet parsing in scripts/zmalarm-server.py. Run with: python3 tests/python/test_zmalarm_server.py Needs neither pyzm nor a running ZoneMinder. """ import importlib.util import json import os import socket import struct import time import unittest HERE = os.path.dirname(os.path.abspath(__file__)) SCRIPT = os.path.join(HERE, '..', '..', 'scripts', 'zmalarm-server.py') spec = importlib.util.spec_from_file_location('zmalarm_server', SCRIPT) als = importlib.util.module_from_spec(spec) spec.loader.exec_module(als) import configparser CAMERA = '192.168.1.10' OTHER_CAMERA = '192.168.1.11' MONITORS = {CAMERA: [3], OTHER_CAMERA: [4]} # Two cameras behind one NAT address, as map_monitors() builds it when both # Paths point at the NAT address and secrets.ini names each camera's LAN address. NAT = '203.0.113.7' NAT_MONITORS = {NAT: [5, 6], '10.0.0.5': [5], '10.0.0.6': [6]} def address_field(ip): return '0x%08X' % struct.unpack('