Skip to content

Commit

Permalink
Light cleanup on tests to avoid reptition of constants
Browse files Browse the repository at this point in the history
  • Loading branch information
drewgl committed Dec 7, 2018
1 parent 2dd88f7 commit d7565e3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 34 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ __pycache__
/.pytest_cache
/tests/archive
/BAC0/web/test
/venv/
12 changes: 7 additions & 5 deletions tests/test_1AddressesTypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import BAC0
import pytest

VENDOR_ID = 842

@pytest.fixture(scope='session')
def host_ip():
hip = HostIP()
Expand All @@ -22,33 +24,33 @@ def host_ip():
def test_WithIPProvided(host_ip):
ip, subnet = host_ip
bacnet_with_ip = BAC0.lite(ip=ip,port=47812)
assert bacnet_with_ip.vendorId == 842
assert bacnet_with_ip.vendorId == VENDOR_ID
bacnet_with_ip.disconnect()

@pytest.mark.skip("Works locally but nt in Travis")
def test_WithIPAndMask(host_ip):
ip, subnet = host_ip
bacnet_with_ip = BAC0.lite(ip=ip, mask=subnet, port=47812)
assert bacnet_with_ip.vendorId == 842
assert bacnet_with_ip.vendorId == VENDOR_ID
bacnet_with_ip.disconnect()

@pytest.mark.skip("Works locally but not in Travis")
def test_WithIPAndMaskAndPort(host_ip):
ip, subnet = host_ip
bacnet_with_ip = BAC0.lite(ip=ip, mask=subnet, port=47812)
assert bacnet_with_ip.vendorId == 842
assert bacnet_with_ip.vendorId == VENDOR_ID
bacnet_with_ip.disconnect()

@pytest.mark.skip("Works locally but not in Travis")
def test_WithIPAndMaskInString(host_ip):
ip, subnet = host_ip
bacnet_with_ip = BAC0.lite(ip='{}/{}'.format(ip,subnet),port=47812)
assert bacnet_with_ip.vendorId == 842
assert bacnet_with_ip.vendorId == VENDOR_ID
bacnet_with_ip.disconnect()

@pytest.mark.skip("Works locally but not in Travis")
def test_WithIPAndMaskAndPortInString(host_ip):
ip, subnet = host_ip
bacnet_with_ip = BAC0.lite(ip='{}/{}:47812'.format(ip,subnet))
assert bacnet_with_ip.vendorId == 842
assert bacnet_with_ip.vendorId == VENDOR_ID
bacnet_with_ip.disconnect()
16 changes: 10 additions & 6 deletions tests/test_Read.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,34 @@
Test Bacnet communication with another device
"""

CHANGE_DELTA = 99.90
TOLERANCE = 0.01
BINARY_TEST_STATE = 'active'

def test_ReadAV(network_and_devices):
test_device = network_and_devices.test_device
assert (test_device['av0'] - 99.90) < 0.01
assert (test_device['av0'] - CHANGE_DELTA) < TOLERANCE

def test_ReadMV(network_and_devices):
test_device = network_and_devices.test_device
assert test_device['mv0'].value == 1

def test_ReadBV(network_and_devices):
test_device = network_and_devices.test_device
assert test_device['bv0'].value == 'active'
assert test_device['bv0'].value == BINARY_TEST_STATE

def test_ReadAI(network_and_devices):
test_device = network_and_devices.test_device
assert (test_device['ai0'] - 99.90) < 0.01
assert (test_device['ai0'] - CHANGE_DELTA) < TOLERANCE

def test_ReadAO(network_and_devices):
test_device = network_and_devices.test_device
assert (test_device['ao0'] - 99.90) < 0.01
assert (test_device['ao0'] - CHANGE_DELTA) < TOLERANCE

def test_ReadBI(network_and_devices):
test_device = network_and_devices.test_device
assert test_device['bi0'].value == 'active'
assert test_device['bi0'].value == BINARY_TEST_STATE

def test_ReadBO(network_and_devices):
test_device = network_and_devices.test_device
assert test_device['bo0'].value == 'active'
assert test_device['bo0'].value == BINARY_TEST_STATE
23 changes: 0 additions & 23 deletions tests/wait_bacpypes_0176_test_Segmentation_300objects.py

This file was deleted.

0 comments on commit d7565e3

Please sign in to comment.