Skip to content

Commit

Permalink
Entity completion tests (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
daniele-athome committed Feb 8, 2025
1 parent a973a2f commit c08d84e
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package it.casaricci.hass.plugin.completion

import com.intellij.codeInsight.completion.CompletionType
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixture4TestCase
import org.junit.Test

class EntityCompletionTest : LightPlatformCodeInsightFixture4TestCase() {

override fun getTestDataPath(): String = "src/test/resources/completion/entity"

@Test
fun testLocalCompletion() {
myFixture.configureByFiles("configuration.yaml", "scripts.yaml")
myFixture.complete(CompletionType.BASIC)
val lookupElementStrings = myFixture.lookupElementStrings
assertNotNull(lookupElementStrings)
assertSameElements(
lookupElementStrings!!,
"script.script_test1",
"script.do_some_action",
"script.do_some_other_action"
)
}

@Test
fun testRemoteCompletion() {
// TODO we need somehow to inject states.json into systemDir
}

}
6 changes: 6 additions & 0 deletions src/test/resources/completion/entity/configuration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
script:
script_test1:
sequence:
- action: <caret>

# TODO add some other supported local entities (e.g. input_text, automation, ...)
8 changes: 8 additions & 0 deletions src/test/resources/completion/entity/scripts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
script:
do_some_action:
sequence:
- action: notify.test

do_some_other_action:
sequence:
- action: notify.test
23 changes: 23 additions & 0 deletions src/test/resources/completion/entity/states.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[
{
"entity_id": "scene.house_entrance",
"state": "2025-01-15T18:09:37.483591+00:00",
"attributes": {
"entity_id": [
"light.living_ceiling",
"light.living_stand",
"light.living_main",
"input_boolean.house_entrance_lights"
],
"friendly_name": "house_entrance"
},
"last_changed": "2025-01-15T18:09:37.483638+00:00",
"last_reported": "2025-01-15T18:09:37.483638+00:00",
"last_updated": "2025-01-15T18:09:37.483638+00:00",
"context": {
"id": "01JHNJG65V7YKPVPFNPGY61FJA",
"parent_id": "01JHNJG65VWQHRE2DZBPANA6SP",
"user_id": null
}
}
]

0 comments on commit c08d84e

Please sign in to comment.