def test_insert_into(self): sql_runner = SQLRunner() table = sql_runner.execute_alter_file() table_values = sql_runner.execute_insert_file() test = table_values.execute("SELECT * FROM planets").fetchall() self.assertEqual(len(test), 9)
def test_insert_into(): sql_runner = SQLRunner() table = sql_runner.execute_alter_file() table_values = sql_runner.execute_insert_file() test = table_values.execute("SELECT * FROM planets").fetchall() assert len(test) == 9
def test_delete_from(self): sql_runner = SQLRunner() table = sql_runner.execute_alter_file() table_values = sql_runner.execute_insert_file() deletion = sql_runner.execute_delete_file() test_delete = deletion.execute("SELECT * FROM planets").fetchall() self.assertEqual(len(test_delete), 8, "Delete Pluto!")
def test_update_jupiter(): sql_runner = SQLRunner() table = sql_runner.execute_alter_file() table_values = sql_runner.execute_insert_file() update = sql_runner.execute_update_file() result = 68 assert table_values.execute( "SELECT num_of_moons FROM planets WHERE name = 'Jupiter';").fetchone( )[0] == result
import unittest, sys from sql_runner import SQLRunner sys.path.insert(0, '..') from queries import * sql_runner = SQLRunner() cursor = sql_runner.execute_create_file() cursor = sql_runner.execute_insert_file() cursor = sql_runner.execute_update_file() class TestUpdateTables(unittest.TestCase): def test_metta_world_peace(self): self.assertEqual( cursor.execute( "SELECT name FROM players WHERE id = 1;").fetchone()[0], "Metta World Peace") def test_chad_ochocinco(self): self.assertEqual( cursor.execute( "SELECT name FROM players WHERE id = 4;").fetchone()[0], "Chad OchoCinco")