Skip to content

Commit

Permalink
lint and unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
philkra committed Dec 14, 2023
1 parent 32f1dfe commit 51c8edd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tests/integration-tests/helpers_bulkprocessor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def setup_class(self):
)

def teardown_class(self):
#assert self.client.databases().delete(self.db_name).is_success()
# assert self.client.databases().delete(self.db_name).is_success()
pass

@pytest.fixture
Expand Down
6 changes: 3 additions & 3 deletions tests/unit-tests/helpers_bulk_processor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ def test_bulk_processor_init(self):

with pytest.raises(Exception) as e:
BulkProcessor(client, batch_size=-1)
assert str(e.value) == "batch size can not be less than one, default: 25"
assert str(e.value) == "batch size can not be less than one, default: 50"

with pytest.raises(Exception) as e:
BulkProcessor(client, flush_interval=-1)
assert str(e.value) == "flush interval can not be negative, default: 5.000000"
assert str(e.value) == "flush interval can not be negative, default: 2.000000"

with pytest.raises(Exception) as e:
BulkProcessor(client, processing_timeout=-1)
assert str(e.value) == "processing timeout can not be negative, default: 0.025000"
assert str(e.value) == "processing timeout can not be negative, default: 0.050000"

def test_bulk_processor_stats(self):
client = XataClient(api_key="api_key", workspace_id="ws_id")
Expand Down
6 changes: 3 additions & 3 deletions xata/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def process(self, id: int):
)
)
while self.worker_active:
sleep_backoff = 5 # slow down if no records exist
sleep_backoff = 5 # slow down if no records exist
time.sleep(self.processing_timeout * sleep_backoff)

# process
Expand Down Expand Up @@ -144,7 +144,7 @@ def process(self, id: int):
"thread #%d: pushed a batch of %d records to table %s"
% (id, len(batch["records"]), batch["table"])
)
#with self.stats_lock:
# with self.stats_lock:
self.stats["total"] += len(batch["records"])
self.stats["queue"] = self.records.size()
if batch["table"] not in self.stats["tables"]:
Expand All @@ -153,7 +153,7 @@ def process(self, id: int):
self.stats["total_batches"] += 1
except Exception as exc:
logging.error("thread #%d: %s" % (id, exc))
sleep_backoff = 1 # keep velocity
sleep_backoff = 1 # keep velocity

def put_record(self, table_name: str, record: dict):
"""
Expand Down

0 comments on commit 51c8edd

Please sign in to comment.