diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_gui.py | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/tests/test_gui.py b/tests/test_gui.py index 44418ac..73146c1 100644 --- a/tests/test_gui.py +++ b/tests/test_gui.py @@ -430,7 +430,7 @@ class SmokeTest(unittest.TestCase): self.assertEqual(w.dashboard.legend.text(), "n/a") jobs = w.open_jobs() self.assertIs(w.open_jobs(), jobs) - self.assertEqual(w.tabs.count(), 5) + self.assertEqual(w.tabs.count(), 6) self.assertEqual([a.text() for a in jobs.pull_menu.actions()], ["personal (preview)"]) jobs.pull_menu.actions()[0].trigger() self.assertIn(("job-start", "sbpull", "personal", "--no"), remote.calls) @@ -627,11 +627,46 @@ class SmokeTest(unittest.TestCase): w.dashboard.jobs.clicked.emit() self.assertIs(w.tabs.currentWidget(), w.jobs_tab) + def wait(self, cond, secs=5): + end = time.time() + secs + while not cond() and time.time() < end: + app.processEvents() + self.assertTrue(cond()) + + def test_repository_tab(self): + root = tempfile.mkdtemp() + self.addCleanup(shutil.rmtree, root) + make_repo(root) + w, _remote = self.window() + w.cfg["repository"]["path"] = root + tab = w.repository_tab + w.tabs.setCurrentWidget(tab) + self.wait(lambda: tab.model.rows) + self.assertIn("2 packages", tab.stats.text()) + self.assertEqual(tab.proxy.rowCount(), 2) + tab.chips["unpublished"].setChecked(True) + self.assertEqual(tab.proxy.rowCount(), 1) + tab.chips["unpublished"].setChecked(False) + tab.query.setText("test package") + self.assertEqual(tab.proxy.rowCount(), 1) + tab.table.setCurrentIndex(tab.proxy.index(0, 0)) + self.assertIn("Updated for version 1.0.", tab.detail.text()) + tab.link.linkActivated.emit("#") + self.assertIs(w.tabs.currentWidget(), w.packages_tab) + self.assertEqual(w.packages_tab.query.text(), "foo") + + def test_repository_missing(self): + w, _remote = self.window() + w.cfg["repository"]["path"] = "/nonexistent/repo" + w.tabs.setCurrentWidget(w.repository_tab) + self.wait(lambda: "not a directory" in w.repository_tab.stats.text()) + def test_ribbons_per_tab(self): w, remote = self.window() + w.cfg["repository"]["path"] = "/nonexistent/repo" w.poll_jobs() self.assertEqual([w.tabs.tabText(i) for i in range(w.tabs.count())], - ["Dashboard", "Packages", "Hints", "Results", "Jobs"]) + ["Dashboard", "Packages", "Hints", "Results", "Repository", "Jobs"]) self.assertFalse(w.tabs.tabsClosable()) self.assertNotIn(("inventory",), remote.calls) # each tab loads on first show expect = { @@ -641,6 +676,7 @@ class SmokeTest(unittest.TestCase): "Hints": (["Check upstream", "Update selected", "Delete hint", "Phantom deps…"], ["Select visible", "Clear", "No download", "Refresh"]), "Results": (["Show build log"], ["Refresh"]), + "Repository": ([], ["Refresh"]), "Jobs": (["Pull overlay", "Check shadowing", "Run it", "Kill"], []), } for i in range(w.tabs.count()): @@ -851,7 +887,7 @@ class SmokeTest(unittest.TestCase): nxt.activated.emit() self.assertEqual(w.tabs.currentIndex(), 0) # wrapped from Jobs to Dashboard prev.activated.emit() - self.assertEqual(w.tabs.currentIndex(), 4) + self.assertEqual(w.tabs.currentIndex(), 5) def test_results_tab(self): w, remote = self.window() |
