Skip to content

Commit

Permalink
Re-organizing HappyBase system tests.
Browse files Browse the repository at this point in the history
Making a TestCase sub-class for each method on Table.
  • Loading branch information
dhermes committed Sep 17, 2015
1 parent bc3539f commit a41d4dc
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions system_tests/run_happybase.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def test_families(self):
self.assertEqual(retrieved[key], value)


class TestTable(unittest2.TestCase):
class BaseTableTest(unittest2.TestCase):

def setUp(self):
self.rows_to_delete = []
Expand All @@ -120,13 +120,8 @@ def tearDown(self):
for row_key in self.rows_to_delete:
table.delete(row_key)

def test_empty_rows(self):
table = get_table()
row1 = table.row(ROW_KEY1)
row2 = table.row(ROW_KEY2)

self.assertEqual(row1, {})
self.assertEqual(row2, {})
class TestTable_put(BaseTableTest):

def test_put(self):
table = get_table()
Expand Down Expand Up @@ -224,6 +219,9 @@ def test_put_ttl_eviction(self):
all_values_after = table.cells(ROW_KEY1, chosen_col)
self.assertEqual(all_values_after, [])


class TestTable_delete(BaseTableTest):

def test_delete(self):
table = get_table()
value1 = 'value1'
Expand Down Expand Up @@ -355,6 +353,9 @@ def test_delete_with_columns_and_timestamp(self):
# COL1 is still present since it is not in `columns`.
self.assertEqual(row1_delete_fam, {COL2: (value2, ts2)})


class TestTable_cells(BaseTableTest):

def test_cells(self):
table = get_table()
value1 = 'value1'
Expand Down Expand Up @@ -396,6 +397,17 @@ def test_cells(self):
timestamp=ts2)
self.assertEqual(first_cell, [(value1, ts1)])


class TestTable_row(BaseTableTest):

def test_row_when_empty(self):
table = get_table()
row1 = table.row(ROW_KEY1)
row2 = table.row(ROW_KEY2)

self.assertEqual(row1, {})
self.assertEqual(row2, {})

def test_row_with_columns(self):
table = get_table()
value1 = 'value1'
Expand Down Expand Up @@ -476,6 +488,9 @@ def test_row_with_timestamp(self):
COL1: (value1, ts1),
})


class TestTable_rows(BaseTableTest):

def test_rows(self):
table = get_table()
value1 = 'value1'
Expand Down Expand Up @@ -641,6 +656,9 @@ def test_rows_with_timestamp(self):
columns=[COL2], include_timestamp=True)
self.assertEqual(rows, [(ROW_KEY1, {COL2: (value3, ts3)})])


class TestTableCounterMethods(BaseTableTest):

def test_counter_get(self):
table = get_table()

Expand Down

0 comments on commit a41d4dc

Please sign in to comment.