def test_width_diff(self): t1 = create_table(['a', 'b']) t2 = create_table(['a', 'b', 'c']) try: t1 + t2 self.fail() except TypeError as e: self.assertEqual(str(e), "Width of the tables are different: 2 != 3")
def test_column_types_diff(self): t1 = create_table(['a', 'b'], [ValueType(), ConditionType()]) t2 = create_table(['a', 'b'], [ValueType(), StringType()]) try: t1 + t2 self.fail() except TypeError as e: self.assertEqual(str(e), ('Column types of the tables are different: ' '(value, condition) != (value, string)'))
def test_labels_diff(self): t1 = create_table(['a', 'b']) t2 = create_table(['a', 'c']) try: t1 + t2 self.fail() except TypeError as e: self.assertEqual( str(e), "Labels of the tables are different: ('a', 'b') != ('a', 'c')")
def test_two_key_two_value2(self): tb = create_table(['keyA', 'keyB']) tb._insert(['value1A', 'value1B']) tb._insert(['value2A', 'value2B']) self.assertEqual(tb.select(keyB='value1B'), ('value1A', 'value1B')) self.assertEqual(tb.select(keyB='value2B'), ('value2A', 'value2B'))
def test_one_key_two_value(self): tb = create_table(['key']) tb._insert(['value1']) tb._insert(['value2']) self.assertEqual(tb.select(key='value1'), ('value1', )) self.assertEqual(tb.select(key='value2'), ('value2', ))
def test_one_key_no_value(self): tb = create_table(['key']) self.assertRaises(LookupError, lambda: tb.select(key='value'))
def test_labels(self): tb = create_table(['keyA', 'keyB', 'keyC']) self.assertEqual(tb._labels, ('keyA', 'keyB', 'keyC'))