Skip to content

Commit

Permalink
First try at a test
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelklehr committed Apr 17, 2024
1 parent 78058e5 commit 745fa44
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/ClassifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use OCA\Recognize\Service\QueueService;
use OCP\AppFramework\Services\IAppConfig;
use OCP\BackgroundJob\IJobList;
use OCP\Constants;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\SystemTag\ISystemTagObjectMapper;
Expand All @@ -32,6 +33,7 @@
*/
class ClassifierTest extends TestCase {
public const TEST_USER1 = 'test-user1';
public const TEST_USER2 = 'test-user2';

public const TEST_FILES = ['alpine.jpg' ,'eiffeltower.jpg', 'Rock_Rejam.mp3', 'jumpingjack.gif', 'test'];
public const ALL_MODELS = [
Expand All @@ -58,6 +60,7 @@ class ClassifierTest extends TestCase {
private FaceDetectionMapper $faceDetectionMapper;
private IJobList $jobList;
private IAppConfig $config;
private \OCP\Share\IManager $shareManager;

public static function setUpBeforeClass(): void {
parent::setUpBeforeClass();
Expand All @@ -79,6 +82,7 @@ public function setUp(): void {
$this->jobList = \OC::$server->get(IJobList::class);
$this->config = \OC::$server->getRegisteredAppContainer('recognize')->get(IAppConfig::class);
$this->queue = \OC::$server->get(QueueService::class);
$this->shareManager = \OC::$server->get(\OCP\Share\IManager::class);
foreach (self::TEST_FILES as $filename) {
try {
$this->userFolder->get($filename)->delete();
Expand Down Expand Up @@ -143,6 +147,14 @@ public function testFileListener(string $ignoreFileName) : void {

$this->testFile = $this->userFolder->newFile('/alpine.jpg', file_get_contents(__DIR__.'/res/alpine.JPG'));
$this->userFolder->newFolder('/test/ignore/');
$sharedFolder = $this->userFolder->newFolder('/test/shared/');
$share = $this->shareManager->newShare();
$share->setSharedBy(self::TEST_USER1);
$share->setSharedWith(self::TEST_USER2);
$share->setShareType(\OCP\Share\IShare::TYPE_USER);
$share->setNode($sharedFolder);
$share->setPermissions(Constants::PERMISSION_ALL);
$this->shareManager->createShare($share);
$ignoreFile = $this->userFolder->newFile('/test/' . $ignoreFileName, '');
$this->ignoredFile = $this->userFolder->newFile('/test/ignore/alpine-2.jpg', file_get_contents(__DIR__.'/res/alpine.JPG'));

Expand Down

0 comments on commit 745fa44

Please sign in to comment.