コード例 #1
0
 def test_condition_multi(self):
     names, values = ['first', 'last'], ['foo', 'bar']
     conditions = [eq(name, value) for name, value in zip(names, values)]
     where = Where(*conditions)
     self.assertEquals(where.cql,
                       ' AND '.join(cond.cql for cond in conditions))
     self.assertEquals(where.values, values)
コード例 #2
0
 def test_valid(self):
     assignment = Set(first='foo')
     condition = eq('last', 'bar')
     op = (Update(
         self.column_family).set(**assignment.kwargs).where(condition))
     cql, args = op.statement()
     self.assertEquals(cql, self.get_query(assignment, condition))
     self.assertEquals(args, assignment.values + condition.values)
コード例 #3
0
	def test_no_selection(self):
		condition = eq('name', 'foo')
		op = (Delete(self.column_family)
			.where(condition)
		)
		cql, args = op.statement()
		self.assertEquals(cql, self.get_query(condition))
		self.assertEquals(args, condition.values)
コード例 #4
0
 def test_selection(self):
     condition = eq('name', 'foo')
     selection = Columns('first', 'last')
     op = (Delete(
         self.column_family).columns(*selection.args).where(condition))
     cql, args = op.statement()
     self.assertEquals(cql, self.get_query(condition, selection))
     self.assertEquals(args, condition.values + selection.values)
コード例 #5
0
	def test_condition(self):
		selection = Columns('first', 'last')
		condition = eq('name', 'foo')
		op = (Select(self.column_family)
			.columns(*selection.args)
			.where(condition)
		)
		cql, args = op.statement()
		self.assertEquals(cql, self.get_query(selection, condition))
		self.assertEquals(args, selection.values + condition.values)
コード例 #6
0
	def test_valid(self):
		assignment = Set(first='foo')
		condition = eq('last', 'bar')
		op = (Update(self.column_family)
			.set(**assignment.kwargs)
			.where(condition)
		)
		cql, args = op.statement()
		self.assertEquals(cql, self.get_query(assignment, condition))
		self.assertEquals(args, assignment.values + condition.values)
コード例 #7
0
 def test_options(self):
     assignment = Set(first='foo')
     condition = eq('last', 'bar')
     using = Using(ttl=10800)
     op = (Update(self.column_family).using(**using.options).set(
         **assignment.kwargs).where(condition))
     cql, args = op.statement()
     self.assertEquals(cql, self.get_query(assignment, condition, using))
     self.assertEquals(args,
                       using.values + assignment.values + condition.values)
コード例 #8
0
	def test_options(self):
		assignment = Set(first='foo')
		condition = eq('last', 'bar')
		using = Using(ttl=10800)
		op = (Update(self.column_family)
			.using(**using.options)
			.set(**assignment.kwargs)
			.where(condition)
		)
		cql, args = op.statement()
		self.assertEquals(cql, self.get_query(assignment, condition, using))
		self.assertEquals(args, using.values + assignment.values + condition.values)
コード例 #9
0
 def test_condition_single(self):
     cond = eq('name', 'foo')
     where = Where(cond)
     self.assertEquals(where.cql, cond.cql)
     self.assertEquals(where.values, cond.values)
コード例 #10
0
 def test_eq(self):
     name, value = 'x', 13
     comp = eq(name, value)
     self.assertEquals(comp.cql, '{}=%s'.format(name))
     self.assertEquals(comp.values, [value])
コード例 #11
0
 def test_no_assignment(self):
     op = (Update(self.column_family).where(eq('name', 'foo')))
     self.assertRaises(ValidationError, op.statement)
コード例 #12
0
	def test_condition_multi(self):
		names, values = ['first', 'last'], ['foo', 'bar']
		conditions = [eq(name, value) for name, value in zip(names, values)]
		where = Where(*conditions)
		self.assertEquals(where.cql, ' AND '.join(cond.cql for cond in conditions))
		self.assertEquals(where.values, values)
コード例 #13
0
	def test_condition_single(self):
		cond = eq('name', 'foo')
		where = Where(cond)
		self.assertEquals(where.cql, cond.cql)
		self.assertEquals(where.values, cond.values)
コード例 #14
0
	def test_eq(self):
		name, value = 'x', 13
		comp = eq(name, value)
		self.assertEquals(comp.cql, '{}=%s'.format(name))
		self.assertEquals(comp.values, [value])
コード例 #15
0
	def test_none_condition(self):
		conditions = [eq('name', 'foo'), None]
		self.assertRaises(ValidationError, Where, *conditions)
コード例 #16
0
	def test_no_assignment(self):
		op = (Update(self.column_family)
			.where(eq('name', 'foo'))
		)
		self.assertRaises(ValidationError, op.statement)
コード例 #17
0
	def test_invalid_instance_value(self):
		op = Assignments()
		op.add(Set(name='foo'))
		op.add(eq('name', 'bar'))
		self.assertRaises(ValidationError, op.validate)
コード例 #18
0
 def test_invalid_instance_value(self):
     op = Assignments()
     op.add(Set(name='foo'))
     op.add(eq('name', 'bar'))
     self.assertRaises(ValidationError, op.validate)
コード例 #19
0
 def test_none_condition(self):
     conditions = [eq('name', 'foo'), None]
     self.assertRaises(ValidationError, Where, *conditions)