Skip to content

Tests for #95 #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
msgpack-python>=0.4.0
msgpack-python>=0.4.0
32 changes: 32 additions & 0 deletions tests/suites/test_dml.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,23 @@ def setUpClass(self):
parts = {1, 'num'},
unique = true})
""".replace('\n', ' '))

self.adm("box.schema.create_space('space_3')")
self.adm("""
box.space['space_3']:format({
{name='id', type='integer'},
{name='field1', type='string', is_nullable=true},
{name='field2', type='string', is_nullable=true}})
box.space['space_3']:create_index('primary', {
type = 'tree',
parts = {'id'},
unique = true})
box.space['space_3']:create_index('secondary', {
type = 'tree',
parts = {'field1', 'field2'},
unique = false})
""".replace('\n', ' '))

self.adm("json = require('json')")
self.adm("fiber = require('fiber')")
self.adm("uuid = require('uuid')")
Expand All @@ -59,10 +76,16 @@ def test_00_02_fill_space(self):
self.con.insert('space_1', [i, i%5, 'tuple_'+str(i)])[0],
[i, i%5, 'tuple_'+str(i)]
)

def test_00_03_answer_repr(self):
repr_str = """- [1, 1, 'tuple_1']"""
self.assertEqual(repr(self.con.select('space_1', 1)), repr_str)

def test_00_04_fill_space(self):
for i in range(1, 500):
tuple = [i, 'tuple_1_' + str(i), 'tuple_2_' + str(i)]
self.assertEqual(self.con.insert('space_3', tuple)[0], tuple)

def test_02_select(self):
# Check that select with different keys are Ok. (With and without index names)
self.assertSequenceEqual(self.con.select('space_1', 20), [[20, 0, 'tuple_20']])
Expand Down Expand Up @@ -286,6 +309,15 @@ def test_12_update_fields(self):
[[2, 'help', 7]]
)

def test_03_select(self):
# Check that select with different keys are Ok. (With and without index names)
self.assertSequenceEqual(self.con.select('space_3', 20), [[20, 'tuple_1_20', 'tuple_2_20']])
self.assertSequenceEqual(self.con.select('space_3', [21]), [[21, 'tuple_1_21', 'tuple_2_21']])
self.assertSequenceEqual(self.con.select('space_3', [22], index='primary'), [[22, 'tuple_1_22', 'tuple_2_22']])
self.assertSequenceEqual(
self.con.select('space_3', ['tuple_1_23', 'tuple_2_23'], index='secondary'),
[[23, 'tuple_1_23', 'tuple_2_23']])

@classmethod
def tearDownClass(self):
self.srv.stop()
Expand Down