'Test POST filter interpretation with multipart request body'

def testPOSTFilter(self):

    assertEqual = self.assertEqual
    assertNotIn = self.assertNotIn
    assertIn = self.assertIn
    request = current.request
    request.env.content_type = 'multipart/form-data'
    r = S3Request(prefix='org', name='organisation', http='POST', get_vars={'$search': 'form', 'test': 'retained'}, post_vars={'~.name|~.comments__like': '["first","second"]', '~.other_field__lt': '"1"', 'multi.nonstr__belongs': '[1,2,3]', 'service_organisation.service_id__belongs': '1', 'other': 'testing'})
    assertEqual(r.http, 'GET')
    get_vars = r.get_vars
    post_vars = r.post_vars
    assertNotIn('$search', get_vars)
    assertEqual(get_vars.get('~.name|~.comments__like'), ['first', 'second'])
    assertEqual(get_vars.get('~.other_field__lt'), '1')
    assertEqual(get_vars.get('multi.nonstr__belongs'), ['1', '2', '3'])
    assertEqual(get_vars.get('service_organisation.service_id__belongs'), '1')
    assertNotIn('~.name|~.comments__like', post_vars)
    assertNotIn('~.other_field__lt', post_vars)
    assertNotIn('service_organisation.service_id__belongs', post_vars)
    assertIn('other', post_vars)
    assertEqual(get_vars.get('test'), 'retained')
    r = S3Request(prefix='org', name='organisation', http='POST', get_vars={'test': 'retained'}, post_vars={'service_organisation.service_id__belongs': '1', 'other': 'testing'})
    assertEqual(r.http, 'POST')
    get_vars = r.get_vars
    post_vars = r.post_vars
    assertNotIn('$search', get_vars)
    assertNotIn('service_organisation.service_id__belongs', get_vars)
    assertIn('service_organisation.service_id__belongs', post_vars)
    assertEqual(get_vars.get('test'), 'retained')
