def test_restrict_fields(self): """ Test search_common.restrict_fields() """ fields = [ "signatute", "signature", "123456sfdgerw&$%#&", "dump", None, "dump" ] theoric_fields = ["signature", "dump"] restricted_fields = co.restrict_fields(fields) self.assertEqual(restricted_fields, theoric_fields) fields = [] theoric_fields = ["signature"] restricted_fields = co.restrict_fields(fields) self.assertEqual(restricted_fields, theoric_fields) fields = None theoric_fields = ["signature"] restricted_fields = co.restrict_fields(fields) self.assertEqual(restricted_fields, theoric_fields) fields = ["nothing"] theoric_fields = ["signature"] restricted_fields = co.restrict_fields(fields) self.assertEqual(restricted_fields, theoric_fields)
def test_restrict_fields(self): """ Test search_common.restrict_fields() """ authorized_fields = ['signature', 'dump'] fields = [ "signatute", "signature", "123456sfdgerw&$%#&", "dump", None, "dump" ] theoric_fields = ["signature", "dump"] restricted_fields = restrict_fields(fields, authorized_fields) eq_(restricted_fields, theoric_fields) fields = [] theoric_fields = ["signature"] restricted_fields = restrict_fields(fields, authorized_fields) eq_(restricted_fields, theoric_fields) fields = None theoric_fields = ["signature"] restricted_fields = restrict_fields(fields, authorized_fields) eq_(restricted_fields, theoric_fields) fields = ["nothing"] theoric_fields = ["signature"] restricted_fields = restrict_fields(fields, authorized_fields) eq_(restricted_fields, theoric_fields) assert_raises(ValueError, restrict_fields, fields, []) assert_raises(TypeError, restrict_fields, fields, None)
def test_restrict_fields(self): """ Test search_common.restrict_fields() """ authorized_fields = ['signature', 'dump'] fields = ["signatute", "signature", "123456sfdgerw&$%#&", "dump", None, "dump"] theoric_fields = ["signature", "dump"] restricted_fields = restrict_fields(fields, authorized_fields) eq_(restricted_fields, theoric_fields) fields = [] theoric_fields = ["signature"] restricted_fields = restrict_fields(fields, authorized_fields) eq_(restricted_fields, theoric_fields) fields = None theoric_fields = ["signature"] restricted_fields = restrict_fields(fields, authorized_fields) eq_(restricted_fields, theoric_fields) fields = ["nothing"] theoric_fields = ["signature"] restricted_fields = restrict_fields(fields, authorized_fields) eq_(restricted_fields, theoric_fields) assert_raises(ValueError, restrict_fields, fields, []) assert_raises(TypeError, restrict_fields, fields, None)
def test_restrict_fields(): """ Test SearchCommon.restrict_fields() """ fields = ["signatute", "signature", "123456sfdgerw&$%#&", "dump", None, "dump"] theoric_fields = ["signature", "dump"] restricted_fields = co.restrict_fields(fields) assert restricted_fields == theoric_fields, ( "Restricted fields expected %s, received %s" % (theoric_fields, restricted_fields)) fields = [] theoric_fields = ["signature"] restricted_fields = co.restrict_fields(fields) assert restricted_fields == theoric_fields, ( "Restricted fields expected %s, received %s" % (theoric_fields, restricted_fields)) fields = None theoric_fields = ["signature"] restricted_fields = co.restrict_fields(fields) assert restricted_fields == theoric_fields, ( "Restricted fields expected %s, received %s" % (theoric_fields, restricted_fields)) fields = ["nothing"] theoric_fields = ["signature"] restricted_fields = co.restrict_fields(fields) assert restricted_fields == theoric_fields, ( "Restricted fields expected %s, received %s" % (theoric_fields, restricted_fields))
def test_restrict_fields(self): """ Test search_common.restrict_fields() """ authorized_fields = ["signature", "dump"] fields = [ "signatute", "signature", "123456sfdgerw&$%#&", "dump", None, "dump" ] theoric_fields = ["signature", "dump"] restricted_fields = restrict_fields(fields, authorized_fields) assert restricted_fields == theoric_fields fields = [] theoric_fields = ["signature"] restricted_fields = restrict_fields(fields, authorized_fields) assert restricted_fields == theoric_fields fields = None theoric_fields = ["signature"] restricted_fields = restrict_fields(fields, authorized_fields) assert restricted_fields == theoric_fields fields = ["nothing"] theoric_fields = ["signature"] restricted_fields = restrict_fields(fields, authorized_fields) assert restricted_fields == theoric_fields with pytest.raises(ValueError): restrict_fields(fields, []) with pytest.raises(TypeError): restrict_fields(fields, None)
def test_restrict_fields(self): """ Test search_common.restrict_fields() """ fields = ["signatute", "signature", "123456sfdgerw&$%#&", "dump", None, "dump"] theoric_fields = ["signature", "dump"] restricted_fields = co.restrict_fields(fields) self.assertEqual(restricted_fields, theoric_fields) fields = [] theoric_fields = ["signature"] restricted_fields = co.restrict_fields(fields) self.assertEqual(restricted_fields, theoric_fields) fields = None theoric_fields = ["signature"] restricted_fields = co.restrict_fields(fields) self.assertEqual(restricted_fields, theoric_fields) fields = ["nothing"] theoric_fields = ["signature"] restricted_fields = co.restrict_fields(fields) self.assertEqual(restricted_fields, theoric_fields)