@@ -13,7 +13,7 @@ import org.junit.jupiter.api.AfterEach
1313import org.junit.jupiter.api.BeforeEach
1414import org.junit.jupiter.api.Test
1515
16- import com.intellij.ide.plugins.IdeaPluginDescriptor
16+ import com.intellij.ide.plugins.PluginManager
1717import com.intellij.ide.plugins.PluginManagerCore
1818import com.intellij.notification.Notification
1919import com.intellij.notification.NotificationAction
@@ -45,6 +45,7 @@ class PythonRequiredStartupActivityTest {
4545 pythonCoreId = PluginId .getId(" PythonCore" )
4646
4747 mockkStatic(NotificationGroupManager ::class )
48+ mockkStatic(PluginManager ::class )
4849 mockkStatic(PluginManagerCore ::class )
4950 mockkObject(PyVenvManageSettings )
5051
@@ -61,15 +62,15 @@ class PythonRequiredStartupActivityTest {
6162 @AfterEach
6263 fun tearDown () {
6364 unmockkStatic(NotificationGroupManager ::class )
65+ unmockkStatic(PluginManager ::class )
6466 unmockkStatic(PluginManagerCore ::class )
6567 unmockkObject(PyVenvManageSettings )
6668 }
6769
6870 @Test
6971 fun `does not show notification when python module is available` (): Unit =
7072 runBlocking {
71- val pythonPlugin: IdeaPluginDescriptor = mockk(relaxed = true )
72- every { PluginManagerCore .getPlugin(pythonModuleId) } returns pythonPlugin
73+ every { PluginManager .isPluginInstalled(pythonModuleId) } returns true
7374 every { PluginManagerCore .isDisabled(pythonModuleId) } returns false
7475
7576 PythonRequiredStartupActivity ().execute(project)
@@ -80,9 +81,8 @@ class PythonRequiredStartupActivityTest {
8081 @Test
8182 fun `does not show notification when PythonCore plugin is available` (): Unit =
8283 runBlocking {
83- val pythonCorePlugin: IdeaPluginDescriptor = mockk(relaxed = true )
84- every { PluginManagerCore .getPlugin(pythonModuleId) } returns null
85- every { PluginManagerCore .getPlugin(pythonCoreId) } returns pythonCorePlugin
84+ every { PluginManager .isPluginInstalled(pythonModuleId) } returns false
85+ every { PluginManager .isPluginInstalled(pythonCoreId) } returns true
8686 every { PluginManagerCore .isDisabled(pythonCoreId) } returns false
8787
8888 PythonRequiredStartupActivity ().execute(project)
@@ -93,8 +93,8 @@ class PythonRequiredStartupActivityTest {
9393 @Test
9494 fun `shows warning notification when python is not available` (): Unit =
9595 runBlocking {
96- every { PluginManagerCore .getPlugin (pythonModuleId) } returns null
97- every { PluginManagerCore .getPlugin (pythonCoreId) } returns null
96+ every { PluginManager .isPluginInstalled (pythonModuleId) } returns false
97+ every { PluginManager .isPluginInstalled (pythonCoreId) } returns false
9898
9999 PythonRequiredStartupActivity ().execute(project)
100100
@@ -111,10 +111,9 @@ class PythonRequiredStartupActivityTest {
111111 @Test
112112 fun `shows warning when python plugin exists but is disabled` (): Unit =
113113 runBlocking {
114- val disabledPlugin: IdeaPluginDescriptor = mockk(relaxed = true )
115- every { PluginManagerCore .getPlugin(pythonModuleId) } returns disabledPlugin
114+ every { PluginManager .isPluginInstalled(pythonModuleId) } returns true
116115 every { PluginManagerCore .isDisabled(pythonModuleId) } returns true
117- every { PluginManagerCore .getPlugin (pythonCoreId) } returns null
116+ every { PluginManager .isPluginInstalled (pythonCoreId) } returns false
118117
119118 PythonRequiredStartupActivity ().execute(project)
120119
@@ -124,8 +123,8 @@ class PythonRequiredStartupActivityTest {
124123 @Test
125124 fun `does not show notification when warning was dismissed` (): Unit =
126125 runBlocking {
127- every { PluginManagerCore .getPlugin (pythonModuleId) } returns null
128- every { PluginManagerCore .getPlugin (pythonCoreId) } returns null
126+ every { PluginManager .isPluginInstalled (pythonModuleId) } returns false
127+ every { PluginManager .isPluginInstalled (pythonCoreId) } returns false
129128 every { settings.dismissedPythonWarning } returns true
130129
131130 PythonRequiredStartupActivity ().execute(project)
@@ -136,8 +135,8 @@ class PythonRequiredStartupActivityTest {
136135 @Test
137136 fun `notification includes dont show again action` (): Unit =
138137 runBlocking {
139- every { PluginManagerCore .getPlugin (pythonModuleId) } returns null
140- every { PluginManagerCore .getPlugin (pythonCoreId) } returns null
138+ every { PluginManager .isPluginInstalled (pythonModuleId) } returns false
139+ every { PluginManager .isPluginInstalled (pythonCoreId) } returns false
141140
142141 PythonRequiredStartupActivity ().execute(project)
143142
@@ -147,8 +146,8 @@ class PythonRequiredStartupActivityTest {
147146 @Test
148147 fun `dont show again action sets dismissed flag and expires notification` (): Unit =
149148 runBlocking {
150- every { PluginManagerCore .getPlugin (pythonModuleId) } returns null
151- every { PluginManagerCore .getPlugin (pythonCoreId) } returns null
149+ every { PluginManager .isPluginInstalled (pythonModuleId) } returns false
150+ every { PluginManager .isPluginInstalled (pythonCoreId) } returns false
152151
153152 val actionSlot = slot<NotificationAction >()
154153 every { notification.addAction(capture(actionSlot)) } returns notification
0 commit comments