Skip to content

Commit

Permalink
Add test case for issue mycodeplug#38
Browse files Browse the repository at this point in the history
A corresponding Talkgroups__ZoneName.csv is not
strictly required.
  • Loading branch information
masenf committed Feb 10, 2021
1 parent 6377bd1 commit af76d2a
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Zone Name,Comment,Power,RX Freq,TX Freq,Color Code,TG 2,TG 9,Simplex 99
Bar;BAR,,High,430.4375,439.4375,1,2,2,2
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Zone Name,Comment,Power,RX Freq,TX Freq,Color Code,TG 2,TG 9,Simplex 99
Foo;FOO,,High,430.4375,439.4375,1,1,1,1
3 changes: 3 additions & 0 deletions tests/multiple-repeaters-one-talkgroups/Talkgroups__Main.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
TG 2,2
TG 9,9
Simplex 99,99
38 changes: 38 additions & 0 deletions tests/test_k7abd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import os
from pathlib import Path

from dzcb import k7abd
from dzcb.model import Timeslot


def test_multiple_repeaters_one_talkgroups():
"""
a Digital-Repeaters__ZoneName.csv files does NOT require a Talkgroups__ZoneName.csv
file, as long as all of the talkgroups are defined in at least one
existing Talkgroups.csv
"""

input_dir = Path(os.path.dirname(__file__)) / "multiple-repeaters-one-talkgroups"
cp = k7abd.Codeplug_from_k7abd(input_dir)
assert len(cp.zones) == 2
assert len(cp.contacts) == 3
assert len(cp.channels) == 2

exp_cp = cp.expand_static_talkgroups()
assert len(exp_cp.zones) == 2
assert len(exp_cp.contacts) == 3
assert len(exp_cp.channels) == 6

expect_channels = [
("Simplex 99 2 BAR", "Simplex 99", Timeslot.TWO),
("TG 2 BAR", "TG 2", Timeslot.TWO),
("TG 9 2 BAR", "TG 9", Timeslot.TWO),
("Simplex 99 1 FOO", "Simplex 99", Timeslot.ONE),
("TG 2 1 FOO", "TG 2", Timeslot.ONE),
("TG 9 1 FOO", "TG 9", Timeslot.ONE),
]

for ch, exp_ch in zip(exp_cp.channels, expect_channels):
assert ch.name == exp_ch[0]
assert ch.talkgroup.name == exp_ch[1]
assert ch.talkgroup.timeslot == exp_ch[2]
9 changes: 9 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[tox]
envlist = py38

[pytest]
testpaths = tests

[testenv]
deps = pytest ~= 6.2.2
commands = pytest {posargs}

0 comments on commit af76d2a

Please sign in to comment.