def test_table_has_extra_item(self): self.db2.cursor().execute("INSERT INTO foo VALUES (" + str(11) + ", 'missing');"); self.assertEqual(fmt.format_table_diff("foo", diff.diff_table("foo", self.db1, self.db2)), "> INSERT INTO foo VALUES (11, 'missing');\n") self.db1.cursor().execute("INSERT INTO foo VALUES (" + str(11) + ", 'missing');"); self.db1.cursor().execute("INSERT INTO foo VALUES (" + str(12) + ", 'missing');"); self.assertEqual(fmt.format_table_diff("foo", diff.diff_table("foo", self.db1, self.db2)), "< INSERT INTO foo VALUES (12, 'missing');\n")
def test_table_has_diff_items(self): self.db1.cursor().execute("INSERT INTO foo VALUES (" + str(11) + ", 'AAA');"); self.db2.cursor().execute("INSERT INTO foo VALUES (" + str(11) + ", 'BBB');"); self.assertEqual(fmt.format_table_diff("foo", diff.diff_table("foo", self.db1, self.db2)), """< INSERT INTO foo VALUES (11, 'AAA'); --- > INSERT INTO foo VALUES (11, 'BBB'); """)
def test_tables_identical(self): self.assertEqual(fmt.format_table_diff("foo", diff.diff_table("foo", self.db1, self.db2)), '')
def test_table_has_diff_items(self): self.db1.cursor().execute("INSERT INTO foo VALUES (11, 11, 'AAA');"); self.db2.cursor().execute("INSERT INTO foo VALUES (11, 11, 'BBB');"); self.assertEqual(diff.diff_table("foo", self.db1, self.db2), [ ((11, 11, u"AAA"), (11, 11, u"BBB"))] )
def test_table_has_extra_item(self): self.db2.cursor().execute("INSERT INTO foo VALUES (11, 11, 'missing');"); self.assertEqual(diff.diff_table("foo", self.db1, self.db2), [ (None, (11, 11, u"missing") )] ) self.db1.cursor().execute("INSERT INTO foo VALUES (11, 11, 'missing');"); self.db1.cursor().execute("INSERT INTO foo VALUES (11, 12, 'missing');"); self.assertEqual(diff.diff_table("foo", self.db1, self.db2), [ ((11, 12, u"missing"), None)] )
def test_tables_identical(self): self.assertFalse(diff.diff_table("foo", self.db1, self.db2))
def test_table_has_gap(self): self.db2.cursor().execute("INSERT INTO foo VALUES (" + str(11) + ", 'missing');"); self.db1.cursor().execute("INSERT INTO foo VALUES (" + str(12) + ", 'AAA');"); self.db2.cursor().execute("INSERT INTO foo VALUES (" + str(12) + ", 'AAA');"); self.assertEqual(diff.diff_table("foo", self.db1, self.db2), [ (None, (11, u"missing"))] )