| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # | ||
| # Copyright (C) 2022-present ScyllaDB | ||
| # | ||
| # SPDX-License-Identifier: AGPL-3.0-or-later | ||
| # | ||
| import time | ||
|
|
||
| unique_name_prefix = 'test_' | ||
|
|
||
|
|
||
| def unique_name(): | ||
| current_ms = int(round(time.time() * 1000)) | ||
| # If unique_name() is called twice in the same millisecond... | ||
| if unique_name.last_ms >= current_ms: | ||
| current_ms = unique_name.last_ms + 1 | ||
| unique_name.last_ms = current_ms | ||
| return unique_name_prefix + str(current_ms) | ||
|
|
||
|
|
||
| unique_name.last_ms = 0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| type: Python | ||
| pool_size: 1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # | ||
| # Copyright (C) 2022-present ScyllaDB | ||
| # | ||
| # SPDX-License-Identifier: AGPL-3.0-or-later | ||
| # | ||
| # This file configures pytest for all tests in this directory, and also | ||
| # defines common test fixtures for all of them to use | ||
|
|
||
| import pathlib | ||
| import sys | ||
|
|
||
| # Add test.pylib to the search path | ||
| sys.path.append(str(pathlib.Path(__file__).resolve().parents[1])) | ||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # Pytest configuration file. If we don't have one in this directory, | ||
| # pytest will look for one in our ancestor directories, and may find | ||
| # something irrelevant. So we should have one here, even if empty. | ||
| [pytest] | ||
| # Use shared fixtures from the parent dir | ||
| addopts = --confcutdir .. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| type: Python | ||
| pool_size: 4 | ||
| topology: | ||
| class: Simple | ||
| replication_factor: 3 | ||
| disable: | ||
| - test_null |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # | ||
| # Copyright (C) 2022-present ScyllaDB | ||
| # | ||
| # SPDX-License-Identifier: AGPL-3.0-or-later | ||
| # | ||
| from cassandra.protocol import InvalidRequest # type: ignore | ||
| from pylib.util import unique_name | ||
| import pytest | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def table1(cql, test_keyspace): | ||
| table = test_keyspace + "." + unique_name() | ||
| cql.execute(f"CREATE TABLE {table} (p text, c text, v text, primary key (p, c))") | ||
| yield table | ||
| cql.execute("DROP TABLE " + table) | ||
|
|
||
|
|
||
| def test_delete_empty_string_key(cql, table1): | ||
| s = "foobar" | ||
| # An empty-string clustering *is* allowed: | ||
| cql.execute(f"DELETE FROM {table1} WHERE p='{s}' AND c=''") | ||
| # But an empty-string partition key is *not* allowed, with a specific | ||
| # error that a "Key may not be empty": | ||
| with pytest.raises(InvalidRequest, match='Key may not be empty'): | ||
| cql.execute(f"DELETE FROM {table1} WHERE p='' AND c='{s}'") |