|
| 1 | +import os |
| 2 | + |
1 | 3 | import pytest
|
2 | 4 | from dbt.tests.adapter.simple_seed.seeds import seeds__expected_sql
|
| 5 | +from dbt.tests.adapter.simple_seed.test_seed import SeedConfigBase |
3 | 6 | from dbt.tests.adapter.simple_seed.test_seed import TestBasicSeedTests as BaseBasicSeedTests
|
4 | 7 | from dbt.tests.adapter.simple_seed.test_seed import (
|
5 | 8 | TestSeedConfigFullRefreshOff as BaseSeedConfigFullRefreshOff,
|
|
20 | 23 | seeds__disabled_in_config_csv,
|
21 | 24 | seeds__enabled_in_config_csv,
|
22 | 25 | )
|
23 |
| -from dbt.tests.util import get_connection |
| 26 | +from dbt.tests.util import get_connection, run_dbt |
24 | 27 |
|
25 | 28 | from dbt.adapters.sqlserver import SQLServerAdapter
|
26 | 29 |
|
@@ -180,3 +183,43 @@ def setUp(self, project):
|
180 | 183 |
|
181 | 184 | class TestSeedSpecificFormatsSQLServer(BaseSeedSpecificFormats):
|
182 | 185 | pass
|
| 186 | + |
| 187 | + |
| 188 | +class TestSeedBatchSizeMaxSQLServer(SeedConfigBase): |
| 189 | + @pytest.fixture(scope="class") |
| 190 | + def seeds(self, test_data_dir): |
| 191 | + return { |
| 192 | + "five_columns.csv": """ |
| 193 | +seed_id,first_name,email,ip_address,birthday |
| 194 | +1,Larry,[email protected],69.135.206.194,2008-09-12 19:08:31 |
| 195 | +2,Larry,[email protected],64.210.133.162,1978-05-09 04:15:14 |
| 196 | +3,Anna,[email protected],168.104.64.114,2011-10-16 04:07:57 |
| 197 | + """ |
| 198 | + } |
| 199 | + |
| 200 | + def test_max_batch_size(self, project, logs_dir): |
| 201 | + run_dbt(["seed"]) |
| 202 | + with open(os.path.join(logs_dir, "dbt.log"), "r") as fp: |
| 203 | + logs = "".join(fp.readlines()) |
| 204 | + |
| 205 | + assert "Inserting batches of 400 records" in logs |
| 206 | + |
| 207 | + |
| 208 | +class TestSeedBatchSizeCustomSQLServer(SeedConfigBase): |
| 209 | + @pytest.fixture(scope="class") |
| 210 | + def seeds(self, test_data_dir): |
| 211 | + return { |
| 212 | + "six_columns.csv": """ |
| 213 | +seed_id,first_name,last_name,email,ip_address,birthday |
| 214 | +1,Larry,King,[email protected],69.135.206.194,2008-09-12 19:08:31 |
| 215 | +2,Larry,Perkins,[email protected],64.210.133.162,1978-05-09 04:15:14 |
| 216 | +3,Anna,Montgomery,[email protected],168.104.64.114,2011-10-16 04:07:57 |
| 217 | + """ |
| 218 | + } |
| 219 | + |
| 220 | + def test_custom_batch_size(self, project, logs_dir): |
| 221 | + run_dbt(["seed"]) |
| 222 | + with open(os.path.join(logs_dir, "dbt.log"), "r") as fp: |
| 223 | + logs = "".join(fp.readlines()) |
| 224 | + |
| 225 | + assert "Inserting batches of 350 records" in logs |
0 commit comments