<commit_before><?php

namespace Keboola\Test\Common;

use Keboola\Csv\CsvFile;
use Keboola\Test\StorageApiTestCase;

class JobPollDelayTest extends StorageApiTestCase
{

    public function setUp()
    {
        parent::setUp();
        $this->_initEmptyTestBuckets();
    }

    public function testAlternateJobPollDelay()
    {
        $methodUsed = false;

        $linearDelay = function ($tries) use (&$methodUsed) {
            $methodUsed = true;
            return (int) $tries;
        };

        $client = new \Keboola\StorageApi\Client(array(
            'token' => STORAGE_API_TOKEN,
            'url' => STORAGE_API_URL,
            'retryDelay' => $linearDelay,
            'maxJobPollWaitPeriodSeconds' => 20,
        ));

        $csvFile = new CsvFile(__DIR__ . '/../../_data/languages.csv');
        $tableId = $client->createTable($this->getTestBucketId(), 'languages', $csvFile);

        $fileId = $client->uploadFile(
            $csvFile->getPathname(),
            (new \Keboola\StorageApi\Options\FileUploadOptions())
                ->setNotify(false)
                ->setIsPublic(false)
                ->setCompress(false)
                ->setTags(array('table-import'))<commit_msg>test: for setting delay method<commit_after><?php

namespace Keboola\Test\Common;

use Keboola\Csv\CsvFile;
use Keboola\Test\StorageApiTestCase;

class JobPollDelayTest extends StorageApiTestCase
{

    public function setUp()
    {
        parent::setUp();
        $this->_initEmptyTestBuckets();
    }

    public function testSetJobPollDelay()
    {
        $methodUsed = false;

        $linearDelay = function ($tries) use (&$methodUsed) {
            $methodUsed = true;
            return (int) $tries;
        };

        $this->_client->setJobPollDelayMethoc($linearDelay);

        $csvFile = new CsvFile(__DIR__ . '/../_data/languages.csv');
        $tableId = $this->_client->createTable($this->getTestBucketId(), 'languages', $csvFile);

        $fileId = $this->_client->uploadFile(
            $csvFile->getPathname(),
            (new \Keboola\StorageApi\Options\FileUploadOptions())
                ->setNotify(false)
                ->setIsPublic(false)
                ->setCompress(false)
                ->setTags(array('table-import'))
        );
        $job = $this->_client->apiPost("storage/tables/{$tableId}/import-async", [
            'dataFileId' => $fileId
        ], false);
        $job = $this->_client->waitForJob($job['id']);

        $this->assertTrue($methodUsed);
    }

    public function testAlternateJobPollDelay()
    {
        $methodUsed = false;

        $linearDelay = function ($tries) use (&$methodUsed) {
            $methodUsed = true;
            return (int) $tries;
        };

        $client = new \Keboola\StorageApi\Client(array(
            'token' => STORAGE_API_TOKEN,
            'url' => STORAGE_API_URL,
            'retryDelay' => $linearDelay,
            'maxJobPollWaitPeriodSeconds' => 20,
        ));

        $csvFile = new CsvFile(__DIR__ . '/../_data/languages.csv');
        $tableId = $client->createTable($this->getTestBucketId(), 'languages', $csvFile);

        $fileId = $client->uploadFile(
            $csvFile->getPathname(),
            (new \Keboola\StorageApi\Options\FileUploadOptions())
                ->setNotify(false)
                ->setIsPublic(false)
                ->setCompress(false)
                ->setTags(array('table-import'))
{'fraction_non_alphanumeric': 0.14107402031930333, 'fraction_numerical': 0.0011611030478955006, 'mean_word_length': 2.164370982552801, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6626035', 'n_tokens_mistral': 1056, 'n_tokens_neox': 1022, 'n_words': 162}