Skip to content

Commit dc1a414

Browse files
author
stonebig
committed
a real test
1 parent 7136e45 commit dc1a414

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ MANIFEST
77
.tox/
88
.cache/
99
*.egg-info/
10+
*.tmp

sqlite_bro/tests/test_general.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,32 @@
11
# from pyappveyordemo.extension import some_function
22
from nose.tools import assert_equal
33

4-
54
def test_DeBase():
65
"learning the ropes"
76
assert_equal(1 , 1)
7+
8+
def test_Basics():
9+
"create script, run script, output result, check result"
10+
import os
11+
import io
12+
from sqlite_bro import sqlite_bro
13+
app = sqlite_bro.App()
14+
app.new_db(":memory:")
15+
tmp_file = 'sqlite_bro_test_Basics.tmp'
16+
welcome_text = """
17+
create table item (ItemNo, Description,Kg , PRIMARY KEY (ItemNo));
18+
INSERT INTO item values("T","Ford",1000);
19+
INSERT INTO item select "A","Merced",1250 union all select "W","Wheel",9 ;
20+
.once 'this_file_of_result.tmp'
21+
select ItemNo, Description, 1000*Kg Gramm from item order by ItemNo desc;
22+
.import '%s' in_this_table""" % tmp_file
23+
app.n.new_query_tab("Welcome", welcome_text)
24+
app.run_tab()
25+
app.close_db
26+
27+
file_encoding = sqlite_bro.guess_encoding(tmp_file)[0]
28+
with io.open(tmp_file, mode='rt', encoding=file_encoding) as f:
29+
result = f.readlines()
30+
assert_equal(len(result) , 4)
31+
assert_equal(result[-1] , "A,Merced,1250000\n")
32+
os.remove(tmp_file)

0 commit comments

Comments
 (0)