kicad/qa/tests/pcbnewswig/test_004_tracks.py

44 lines
1.7 KiB
Python
Raw Normal View History

2023-05-06 00:13:08 +00:00
import pytest
2021-02-28 00:18:56 +00:00
import pcbnew
2023-05-06 00:13:08 +00:00
class TestTracks:
pcb : pcbnew.BOARD = None
2021-02-28 00:18:56 +00:00
2023-05-06 00:13:08 +00:00
def setup_method(self):
self.pcb = pcbnew.LoadBoard("../data/pcbnew/tracks_arcs_vias.kicad_pcb")
2021-02-28 00:18:56 +00:00
def test_tracks(self):
tracks = [t for t in self.pcb.Tracks() if t.GetClass() == 'PCB_TRACK']
2023-05-06 00:13:08 +00:00
assert 16 == len(tracks)
2021-02-28 00:18:56 +00:00
track = sorted(tracks, key=lambda t: [t.GetStart()[0], t.GetStart()[1]])[0]
2023-05-06 00:13:08 +00:00
assert [27000000, 27585787] == [track.GetStart()[0], track.GetStart()[1]]
assert [27000000, 26500000] == [track.GetEnd()[0], track.GetEnd()[1]]
assert 250000 == track.GetWidth()
assert 'McNetty' == track.GetNetname()
2021-02-28 00:18:56 +00:00
dup_track = track.Duplicate()
2023-05-06 00:13:08 +00:00
assert dup_track.m_Uuid != track.m_Uuid
2021-02-28 00:18:56 +00:00
def test_arcs(self):
arcs = [t.Cast() for t in self.pcb.Tracks() if t.GetClass() == 'PCB_ARC']
2023-05-06 00:13:08 +00:00
assert 13 == len(arcs)
2021-02-28 00:18:56 +00:00
arc = sorted(arcs, key=lambda t: [t.GetStart()[0], t.GetStart()[1]])[0]
2023-05-06 00:13:08 +00:00
assert [29414200, 26500000] == [arc.GetCenter()[0], arc.GetCenter()[1]]
assert [1800, 2250] == [round(arc.GetArcAngleStart().AsTenthsOfADegree()),
round(arc.GetArcAngleEnd().AsTenthsOfADegree())]
assert 2414200 == round(arc.GetRadius())
2021-02-28 00:18:56 +00:00
dup_arc = arc.Duplicate()
2023-05-06 00:13:08 +00:00
assert dup_arc.m_Uuid != arc.m_Uuid
2021-02-28 00:18:56 +00:00
def test_vias(self):
vias = [t.Cast() for t in self.pcb.Tracks() if t.GetClass() == 'PCB_VIA']
2023-05-06 00:13:08 +00:00
assert 2 == len(vias)
2021-02-28 00:18:56 +00:00
via = sorted(vias, key=lambda t: [t.GetStart()[0], t.GetStart()[1]])[0]
2023-05-06 00:13:08 +00:00
assert [29000000, 41000000] == [via.GetStart()[0], via.GetStart()[1]]
assert 400000 == via.GetDrillValue()
dup_via = via.Duplicate()
2023-05-06 00:13:08 +00:00
assert dup_via.m_Uuid != via.m_Uuid