Skip to content

Commit

Permalink
Remove dependency from CSV adapter in AnalyzeTest
Browse files Browse the repository at this point in the history
  • Loading branch information
norberttech committed Jan 28, 2024
1 parent be1b369 commit 21d48bc
Showing 1 changed file with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

namespace Flow\ETL\Tests\Integration\DataFrame;

use function Flow\ETL\Adapter\CSV\from_csv;
use function Flow\ETL\Adapter\Text\from_text;
use function Flow\ETL\DSL\datetime_schema;
use function Flow\ETL\DSL\df;
use function Flow\ETL\DSL\float_schema;
use function Flow\ETL\DSL\from_array;
use function Flow\ETL\DSL\int_schema;
use function Flow\ETL\DSL\schema;
use function Flow\ETL\DSL\str_schema;
Expand All @@ -19,11 +19,17 @@ final class AnalyzeTest extends IntegrationTestCase
public function test_analyzing_csv_file_with_auto_cast() : void
{
$report = df()
->read(from_csv(__DIR__ . '/Fixtures/Analyze/goldstock.csv'))
->read(from_array([
['Index' => 1, 'Date' => '2024-01-19', 'Close' => '2029.3', 'Volume' => '166078.0', 'Open' => '2027.4', 'High' => '2041.9', 'Low' => '2022.2'],
['Index' => 2, 'Date' => '2024-01-20', 'Close' => '2029.3', 'Volume' => '166078.0', 'Open' => '2027.4', 'High' => '2041.9', 'Low' => '2022.2'],
['Index' => 3, 'Date' => '2024-01-21', 'Close' => '2029.3', 'Volume' => '166078.0', 'Open' => '2027.4', 'High' => '2041.9', 'Low' => '2022.2'],
['Index' => 4, 'Date' => '2024-01-22', 'Close' => '2029.3', 'Volume' => '166078.0', 'Open' => '2027.4', 'High' => '2041.9', 'Low' => '2022.2'],
['Index' => 5, 'Date' => '2024-01-23', 'Close' => '2029.3', 'Volume' => '166078.0', 'Open' => '2027.4', 'High' => '2041.9', 'Low' => '2022.2'],
]))
->autoCast()
->run(analyze: true);

$this->assertSame(2511, $report->statistics()->totalRows());
$this->assertSame(5, $report->statistics()->totalRows());
$this->assertEquals(
schema(
int_schema('Index'),
Expand All @@ -42,11 +48,17 @@ public function test_analyzing_csv_file_with_auto_cast() : void
public function test_analyzing_csv_file_with_limit() : void
{
$report = df()
->read(from_csv(__DIR__ . '/Fixtures/Analyze/goldstock.csv'))
->limit(100)
->read(from_array([
['Index' => '1', 'Date' => '2024-01-19', 'Close' => '2029.3', 'Volume' => '166078.0', 'Open' => '2027.4', 'High' => '2041.9', 'Low' => '2022.2'],
['Index' => '2', 'Date' => '2024-01-20', 'Close' => '2029.3', 'Volume' => '166078.0', 'Open' => '2027.4', 'High' => '2041.9', 'Low' => '2022.2'],
['Index' => '3', 'Date' => '2024-01-21', 'Close' => '2029.3', 'Volume' => '166078.0', 'Open' => '2027.4', 'High' => '2041.9', 'Low' => '2022.2'],
['Index' => '4', 'Date' => '2024-01-22', 'Close' => '2029.3', 'Volume' => '166078.0', 'Open' => '2027.4', 'High' => '2041.9', 'Low' => '2022.2'],
['Index' => '5', 'Date' => '2024-01-23', 'Close' => '2029.3', 'Volume' => '166078.0', 'Open' => '2027.4', 'High' => '2041.9', 'Low' => '2022.2'],
]))
->limit(2)
->run(analyze: true);

$this->assertSame(100, $report->statistics()->totalRows());
$this->assertSame(2, $report->statistics()->totalRows());
$this->assertEquals(
schema(
str_schema('Index'),
Expand Down

0 comments on commit 21d48bc

Please sign in to comment.