Browse Source

Check Capability and server version for tests

Signed-off-by: alperozturk <alper_ozturk@proton.me>
alperozturk 1 year ago
parent
commit
f7f6374120

+ 25 - 0
app/src/androidTest/java/com/nextcloud/client/assistant/AssistantRepositoryTests.kt

@@ -23,6 +23,7 @@ package com.nextcloud.client.assistant
 
 
 import com.nextcloud.client.assistant.repository.AssistantRepository
 import com.nextcloud.client.assistant.repository.AssistantRepository
 import com.owncloud.android.AbstractOnServerIT
 import com.owncloud.android.AbstractOnServerIT
+import com.owncloud.android.lib.resources.status.NextcloudVersion
 import org.junit.Assert.assertTrue
 import org.junit.Assert.assertTrue
 import org.junit.Before
 import org.junit.Before
 import org.junit.Test
 import org.junit.Test
@@ -39,6 +40,12 @@ class AssistantRepositoryTests : AbstractOnServerIT() {
 
 
     @Test
     @Test
     fun testGetTaskTypes() {
     fun testGetTaskTypes() {
+        testOnlyOnServer(NextcloudVersion.nextcloud_28)
+
+        if (capability.assistant.isFalse) {
+            return
+        }
+
         val result = sut?.getTaskTypes()
         val result = sut?.getTaskTypes()
         assertTrue(result?.isSuccess == true)
         assertTrue(result?.isSuccess == true)
 
 
@@ -48,6 +55,12 @@ class AssistantRepositoryTests : AbstractOnServerIT() {
 
 
     @Test
     @Test
     fun testGetTaskList() {
     fun testGetTaskList() {
+        testOnlyOnServer(NextcloudVersion.nextcloud_28)
+
+        if (capability.assistant.isFalse) {
+            return
+        }
+
         val result = sut?.getTaskList("assistant")
         val result = sut?.getTaskList("assistant")
         assertTrue(result?.isSuccess == true)
         assertTrue(result?.isSuccess == true)
 
 
@@ -57,6 +70,12 @@ class AssistantRepositoryTests : AbstractOnServerIT() {
 
 
     @Test
     @Test
     fun testCreateTask() {
     fun testCreateTask() {
+        testOnlyOnServer(NextcloudVersion.nextcloud_28)
+
+        if (capability.assistant.isFalse) {
+            return
+        }
+
         val input = "Give me some random output for test purpose"
         val input = "Give me some random output for test purpose"
         val type = "OCP\\TextProcessing\\FreePromptTaskType"
         val type = "OCP\\TextProcessing\\FreePromptTaskType"
         val result = sut?.createTask(input, type)
         val result = sut?.createTask(input, type)
@@ -65,6 +84,12 @@ class AssistantRepositoryTests : AbstractOnServerIT() {
 
 
     @Test
     @Test
     fun testDeleteTask() {
     fun testDeleteTask() {
+        testOnlyOnServer(NextcloudVersion.nextcloud_28)
+
+        if (capability.assistant.isFalse) {
+            return
+        }
+
         testCreateTask()
         testCreateTask()
 
 
         sleep(120)
         sleep(120)

+ 6 - 1
app/src/androidTest/java/com/owncloud/android/AbstractIT.java

@@ -195,13 +195,18 @@ public abstract class AbstractIT {
     }
     }
 
 
     protected void testOnlyOnServer(OwnCloudVersion version) throws AccountUtils.AccountNotFoundException {
     protected void testOnlyOnServer(OwnCloudVersion version) throws AccountUtils.AccountNotFoundException {
+        OCCapability ocCapability = getCapability();
+        assumeTrue(ocCapability.getVersion().isNewerOrEqual(version));
+    }
+
+    protected OCCapability getCapability() throws AccountUtils.AccountNotFoundException {
         NextcloudClient client = OwnCloudClientFactory.createNextcloudClient(user, targetContext);
         NextcloudClient client = OwnCloudClientFactory.createNextcloudClient(user, targetContext);
 
 
         OCCapability ocCapability = (OCCapability) new GetCapabilitiesRemoteOperation()
         OCCapability ocCapability = (OCCapability) new GetCapabilitiesRemoteOperation()
             .execute(client)
             .execute(client)
             .getSingleData();
             .getSingleData();
 
 
-        assumeTrue(ocCapability.getVersion().isNewerOrEqual(version));
+        return ocCapability;
     }
     }
 
 
     @Before
     @Before