MCPcopy Index your code
hub / github.com/dbcli/pgcli / test_refresh_called_twice

Function test_refresh_called_twice

tests/test_completion_refresher.py:52–78  ·  view source on GitHub ↗

If refresh is called a second time, it should be restarted :param refresher: :return:

(refresher)

Source from the content-addressed store, hash-verified

50
51
52def test_refresh_called_twice(refresher):
53 """
54 If refresh is called a second time, it should be restarted
55 :param refresher:
56 :return:
57 """
58 callbacks = Mock()
59
60 pgexecute = Mock(**{"is_virtual_database.return_value": False})
61 special = Mock()
62
63 def dummy_bg_refresh(*args):
64 time.sleep(3) # seconds
65
66 refresher._bg_refresh = dummy_bg_refresh
67
68 actual1 = refresher.refresh(pgexecute, special, callbacks)
69 time.sleep(1) # Wait for the thread to work.
70 assert len(actual1) == 1
71 assert len(actual1[0]) == 4
72 assert actual1[0][3] == "Auto-completion refresh started in the background."
73
74 actual2 = refresher.refresh(pgexecute, special, callbacks)
75 time.sleep(1) # Wait for the thread to work.
76 assert len(actual2) == 1
77 assert len(actual2[0]) == 4
78 assert actual2[0][3] == "Auto-completion refresh restarted."
79
80
81def test_refresh_with_callbacks(refresher):

Callers

nothing calls this directly

Calls 1

refreshMethod · 0.80

Tested by

no test coverage detected