| 1 | import pexpect |
| 2 | |
| 3 | |
| 4 | def test_client_help(): |
| 5 | with pexpect.spawn("python -m labgrid.remote.client --help") as spawn: |
| 6 | spawn.expect("usage") |
| 7 | spawn.expect(pexpect.EOF) |
| 8 | spawn.close() |
| 9 | assert spawn.exitstatus == 0 |
| 10 | assert spawn.signalstatus is None |
| 11 | |
| 12 | |
| 13 | def test_exporter_help(): |
| 14 | with pexpect.spawn("python -m labgrid.remote.exporter --help") as spawn: |
| 15 | spawn.expect("usage") |
| 16 | spawn.expect(pexpect.EOF) |
| 17 | spawn.close() |
| 18 | assert spawn.exitstatus == 0 |
| 19 | assert spawn.signalstatus is None |
| 20 | |
| 21 | |
| 22 | def test_exporter_start_coordinator_unreachable(monkeypatch, tmpdir): |
| 23 | monkeypatch.setenv("LG_COORDINATOR", "coordinator.invalid") |
| 24 | |
| 25 | config = "exports.yaml" |
| 26 | p = tmpdir.join(config) |
| 27 | p.write( |
| 28 | """ |
| 29 | Testport: |
| 30 | NetworkSerialPort: |
| 31 | host: 'localhost' |
| 32 | port: 4000 |
| 33 | """ |
| 34 | ) |
| 35 | |
| 36 | with pexpect.spawn(f"python -m labgrid.remote.exporter {config}", cwd=tmpdir) as spawn: |
| 37 | spawn.expect("coordinator is unavailable", timeout=10) |
| 38 | spawn.expect(pexpect.EOF) |
| 39 | spawn.close() |
| 40 | assert spawn.exitstatus == 100, spawn.before |
| 41 | |
| 42 | |
| 43 | def test_exporter_coordinator_becomes_unreachable(coordinator, exporter): |
| 44 | coordinator.suspend_tree() |
| 45 | |
| 46 | exporter.spawn.expect(pexpect.EOF, timeout=30) |
| 47 | exporter.spawn.close() |
| 48 | assert exporter.exitstatus == 100 |
| 49 | |
| 50 | coordinator.resume_tree() |