def test_select_example1_by_id_success_none_value(self): record = example1.select_example1_by_id(self.conn, 2) # データの確認:1件目 self.assertEqual(record['id'], 2) self.assertEqual(record['varchar_col'], None) self.assertEqual(record['int_col'], None) self.assertEqual(record['double_col'], None) self.assertEqual(record['datetime_col'], None)
def test_delete_example1_by_id_success(self): result = example1.delete_example1_by_id(self.conn, id=2) # 戻り値の確認 self.assertEqual(result, 1) # 削除後の件数の確認(3 - 1 -> 2) self.assertEqual(count_example1(self.conn), 2) # 削除したデータがないことを確認 record = example1.select_example1_by_id(self.conn, 2) self.assertIsNone(record)
def test_select_example1_by_id_success(self): record = example1.select_example1_by_id(self.conn, 1) # データの確認:1件目 expected = { 'id': 1, 'varchar_col': 'abcdefghij', 'int_col': 1234567890, 'double_col': 123.456, 'datetime_col': datetime(2018, 8, 1, 12, 34, 56) } self.assertDictEqual(record, expected)
def test_insert_example1_success(self): result = example1.insert_example1(self.conn, id=100, varchar_col='あいうえおかきくけこ', int_col=987654321, double_col=654.321, datetime_col=datetime( 2001, 1, 2, 3, 4, 5)) # 戻り値の確認 self.assertEqual(result, 1) # 登録後の件数の確認(2 + 1 -> 3) self.assertEqual(count_example1(self.conn), 3) # 登録データの確認 record = example1.select_example1_by_id(self.conn, 100) self.assertEqual(record['id'], 100) self.assertEqual(record['varchar_col'], 'あいうえおかきくけこ') self.assertEqual(record['int_col'], 987654321) self.assertEqual(record['double_col'], 654.321) self.assertEqual(record['datetime_col'], datetime(2001, 1, 2, 3, 4, 5))
def test_select_example1_by_id_success_no_data(self): result = example1.select_example1_by_id(self.conn, 100) # 件数の確認 self.assertIsNone(result)