forked from mycodeplug/dzcb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test case for issue mycodeplug#38
A corresponding Talkgroups__ZoneName.csv is not strictly required.
- Loading branch information
Showing
5 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
tests/multiple-repeaters-one-talkgroups/Digital-Repeaters__Additional.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
2 changes: 2 additions & 0 deletions
2
tests/multiple-repeaters-one-talkgroups/Digital-Repeaters__Main.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
TG 2,2 | ||
TG 9,9 | ||
Simplex 99,99 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |