コード例 #1
0
    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)
コード例 #2
0
    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)
コード例 #3
0
ファイル: test_search_common.py プロジェクト: snorp/socorro
    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)
コード例 #4
0
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))
コード例 #5
0
ファイル: test_search_common.py プロジェクト: richev/socorro
    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)
コード例 #6
0
    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)