<commit_before>from zope.interface.verify import verifyClass, verifyObject
from ironman.packet import IPBusPacket
from ironman.interfaces import IIPBusPacket

def test_ipbus_packet_create():
    obj = IPBusPacket()
    assert obj is not None

def test_ipbus_packet_class_iface():
    # Assure the class implements the declared interface
    assert verifyClass(IIPBusPacket, IPBusPacket)

def test_ipbus_packet_instance_iface():
    # Assure instances of the class provide the declared interface
    assert verifyObject(IIPBusPacket, IPBusPacket())

# test packets using the following:
# little endian packet
#data = '\xf0\x00\x00 \x0f\x01\x00 \x03\x00\x00\x00'
# big endian packet
#data = ' \x00\x00\xf0 \x00\x01\x0f\x00\x00\x00\x03'
<commit_msg>finalizing more tests for test_packet.py<commit_after>from zope.interface.verify import verifyClass, verifyObject
from ironman.packet import IPBusPacket
from ironman.interfaces import IIPBusPacket
from ironman.utilities import byteswap

IPBUS_VERSION = 2
BENDIAN_TESTPACKET = ' \x00\x00\xf0 \x00\x01\x0f\x00\x00\x00\x03'
LENDIAN_TESTPACKET = '\xf0\x00\x00 \x0f\x01\x00 \x03\x00\x00\x00'

# fixtures for passing in the objects
import pytest

@pytest.mark.parametrize("data", [BENDIAN_TESTPACKET, LENDIAN_TESTPACKET])
def test_ipbus_packet_create(data):
    obj = IPBusPacket(data)
    assert obj is not None

def test_ipbus_packet_class_iface():
    # Assure the class implements the declared interface
    assert verifyClass(IIPBusPacket, IPBusPacket)

@pytest.mark.parametrize("data", [BENDIAN_TESTPACKET, LENDIAN_TESTPACKET])
def test_ipbus_packet_instance_iface(data):
    # Assure instances of the class provide the declared interface
    assert verifyObject(IIPBusPacket, IPBusPacket(data))

@pytest.mark.parametrize("data", [BENDIAN_TESTPACKET, LENDIAN_TESTPACKET])
def test_ipbus_packet_parse(data):
    # this should parse it all for us without erroring
    packet_normal = IPBusPacket(data)
    packet_swapped = IPBusPacket(byteswap(data))
    assert packet_normal.protocol_version == IPBUS_VERSION
    assert packet_normal.struct.header.reserved == 0x0
    assert packet_normal.packet_id == 0x0
    assert packet_normal.byteorder == 0xf
    assert packet_normal.packet_type == 'CONTROL'
    assert packet_normal.struct == packet_swapped.struct
{'fraction_non_alphanumeric': 0.08264462809917356, 'fraction_numerical': 0.033927794693344934, 'mean_word_length': 5.284153005464481, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4361783', 'n_tokens_mistral': 812, 'n_tokens_neox': 774, 'n_words': 181}