'Test negation of query dicts'

def testNot(self):

    p = S3URLQueryParser()
    assertEqual = self.assertEqual
    assertTrue = self.assertTrue
    assertIn = self.assertIn
    q = (S3FieldSelector('example.test') == 1)
    qdict = {'example': q}
    result = p._not(qdict)
    assertTrue(isinstance(result, dict))
    assertEqual(len(result), 1)
    assertIn('example', result)
    query = result['example']
    assertEqual(query.op, query.NOT)
    assertEqual(query.left, q)
    q1 = (S3FieldSelector('~.field') != 'a')
    q2 = (S3FieldSelector('example.test') > 1)
    qdict = {None: (q1 | q2)}
    result = p._not(qdict)
    assertTrue(isinstance(result, dict))
    assertEqual(len(result), 2)
    assertIn(None, result)
    query = result[None]
    assertEqual(query.op, query.NOT)
    assertEqual(query.left, q1)
    assertIn('example', result)
    query = result['example']
    assertEqual(query.op, query.NOT)
    assertEqual(query.left, q2)
    q1 = S3FieldSelector('example.other').like('a*')
    q2 = (S3FieldSelector('example.test') > 1)
    qdict = {'example': (q1 | q2)}
    result = p._not(qdict)
    assertTrue(isinstance(result, dict))
    assertEqual(len(result), 1)
    assertIn('example', result)
    query = result['example']
    assertEqual(query.op, query.NOT)
    query = query.left
    assertEqual(query.op, query.OR)
    assertEqual(query.left, q1)
    assertEqual(query.right, q2)
    q1 = S3FieldSelector('~.other').like('x*')
    q2 = (S3FieldSelector('~.test') < 1)
    qdict = {None: (q1 & q2)}
    result = p._not(qdict)
    assertTrue(isinstance(result, dict))
    assertEqual(len(result), 1)
    assertIn(None, result)
    query = result[None]
    assertEqual(query.op, query.NOT)
    query = query.left
    assertEqual(query.op, query.AND)
    assertEqual(query.left, q1)
    assertEqual(query.right, q2)
    q = S3FieldSelector('test.other').like('x*')
    qdict = {'test': (~ q)}
    result = p._not(qdict)
    assertTrue(isinstance(result, dict))
    assertEqual(len(result), 1)
    assertIn('test', result)
    query = result['test']
    assertEqual(query, q)
    q1 = S3FieldSelector('test.other').like('y*')
    q2 = (S3FieldSelector('~.test') != 1)
    qdict = {'test': q1, None: q2}
    result = p._not(qdict)
    assertTrue(isinstance(result, dict))
    assertEqual(len(result), 1)
    assertIn(None, result)
    query = result[None]
    assertEqual(query.op, query.NOT)
    query = query.left
    assertEqual(query.op, query.AND)
    assertEqual(query.left, q1)
    assertEqual(query.right, q2)
