Skip to content

Commit

Permalink
Replace module scope and use consecutive tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtisvg committed Mar 27, 2018
1 parent a16d2ec commit c35406b
Showing 1 changed file with 9 additions and 39 deletions.
48 changes: 9 additions & 39 deletions spanner/cloud-client/snippets_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def test_read_stale_data(temporary_database, capsys):
assert 'Total Junk' not in out


@pytest.fixture()
@pytest.fixture(scope='module')
def temporary_database_with_column(temporary_database):
snippets.add_column(SPANNER_INSTANCE, temporary_database.database_id)
yield temporary_database
Expand All @@ -105,7 +105,7 @@ def test_query_data_with_new_column(temporary_database_with_column, capsys):
assert 'MarketingBudget' in out


@pytest.fixture()
@pytest.fixture(scope='module')
def temporary_database_with_indexes(temporary_database_with_column):
snippets.add_index(
SPANNER_INSTANCE,
Expand Down Expand Up @@ -205,64 +205,34 @@ def test_insert_data_with_timestamp(temporary_database, capsys):
assert 'Inserted data.' in out


@pytest.fixture()
def temp_database_with_timestamps(temporary_database):
snippets.create_table_with_timestamp(
SPANNER_INSTANCE,
temporary_database.database_id)
snippets.insert_data_with_timestamp(
SPANNER_INSTANCE,
temporary_database.database_id)

yield temporary_database


def test_add_timestamp_column(temp_database_with_timestamps, capsys):
def test_add_timestamp_column(temporary_database, capsys):
snippets.add_timestamp_column(
SPANNER_INSTANCE,
temp_database_with_timestamps.database_id)
temporary_database.database_id)

out, _ = capsys.readouterr()

assert 'Albums' in out


@pytest.fixture()
def temp_database_with_timestamps_column(temp_database_with_timestamps):
snippets.add_timestamp_column(
SPANNER_INSTANCE,
temp_database_with_timestamps.database_id)

yield temporary_database


def test_update_data_with_timestamp(
temp_database_with_timestamps_column, capsys):
@pytest.mark.slow
def test_update_data_with_timestamp(temporary_database, capsys):
snippets.update_data_with_timestamp(
SPANNER_INSTANCE,
temp_database_with_timestamps_column.database_id)
temporary_database.database_id)

out, _ = capsys.readouterr()

assert 'Updated data.' in out


@pytest.fixture()
def temp_database_with_timestamps_data(temp_database_with_timestamps_column):
snippets.update_data_with_timestamp(
SPANNER_INSTANCE,
temp_database_with_timestamps_column.database_id)

yield temporary_database


@pytest.mark.slow
def test_query_data_with_timestamp(temp_database_with_timestamps_data, capsys):
def test_query_data_with_timestamp(temporary_database, capsys):
@eventually_consistent.call
def _():
snippets.query_data_with_timestamp(
SPANNER_INSTANCE,
temp_database_with_timestamps_data.database_id)
temporary_database.database_id)

out, _ = capsys.readouterr()

Expand Down

0 comments on commit c35406b

Please sign in to comment.