How to use the pypuppetdb.QueryBuilder.GreaterOperator function in pypuppetdb

To help you get started, we’ve selected a few pypuppetdb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github voxpupuli / pypuppetdb / tests / test_querybuilder.py View on Github external
def test_greater_operator(self):
        assert str(GreaterOperator("uptime", 150))\
            == '[">", "uptime", 150]'
        assert str(GreaterOperator("end_time", '2016-05-11T23:22:48.709Z'))\
            == '[">", "end_time", "2016-05-11T23:22:48.709Z"]'
        assert str(GreaterOperator(['parameter', 'version'], 4.0))\
            == '[">", ["parameter", "version"], 4.0]'
        assert str(GreaterOperator("report_timestamp",
                                   datetime.datetime(2016, 6, 11)))\
            == '[">", "report_timestamp", "2016-06-11 00:00:00"]'
github voxpupuli / pypuppetdb / tests / test_querybuilder.py View on Github external
op.add_query({'less': 42, 'greater': 50})

        op.add_query(EqualsOperator('domain', 'example.com'))

        assert repr(op) == 'Query: ["extract", '\
            '["certname", "fact_environment", "catalog_environment"], '\
            '["=", "domain", "example.com"]]'
        assert str(op) == '["extract", '\
            '["certname", "fact_environment", "catalog_environment"], '\
            '["=", "domain", "example.com"]]'
        assert str(op) == '["extract", ' \
                          '["certname", "fact_environment", "catalog_environment"], '\
            '["=", "domain", "example.com"]]'

        with pytest.raises(APIError):
            op.add_query(GreaterOperator("processorcount", 1))
github voxpupuli / pypuppetdb / tests / test_querybuilder.py View on Github external
def test_and_operator(self):
        op = AndOperator()
        op.add(EqualsOperator("operatingsystem", "CentOS"))
        op.add([EqualsOperator("architecture", "x86_64"),
                GreaterOperator("operatingsystemmajrelease", 6)])

        assert str(op) == '["and", ["=", "operatingsystem", "CentOS"], '\
            '["=", "architecture", "x86_64"], '\
            '[">", "operatingsystemmajrelease", 6]]'
        assert repr(op) == 'Query: ["and", '\
            '["=", "operatingsystem", "CentOS"], '\
            '["=", "architecture", "x86_64"], '\
            '[">", "operatingsystemmajrelease", 6]]'
        assert str(op) == '["and", ["=", "operatingsystem", "CentOS"], ' \
                          '["=", "architecture", "x86_64"], '\
            '[">", "operatingsystemmajrelease", 6]]'

        with pytest.raises(APIError):
            op.add({"query1": '["=", "catalog_environment", "production"]'})
github voxpupuli / pypuppetdb / tests / test_querybuilder.py View on Github external
def test_or_operator(self):
        op = OrOperator()
        op.add(EqualsOperator("operatingsystem", "CentOS"))
        op.add([EqualsOperator("architecture", "x86_64"),
                GreaterOperator("operatingsystemmajrelease", 6)])

        assert str(op) == '["or", ["=", "operatingsystem", "CentOS"], '\
            '["=", "architecture", "x86_64"], '\
            '[">", "operatingsystemmajrelease", 6]]'
        assert repr(op) == 'Query: ["or", '\
            '["=", "operatingsystem", "CentOS"], '\
            '["=", "architecture", "x86_64"], '\
            '[">", "operatingsystemmajrelease", 6]]'
        assert str(op) == '["or", ["=", "operatingsystem", "CentOS"], ' \
                          '["=", "architecture", "x86_64"], '\
            '[">", "operatingsystemmajrelease", 6]]'

        with pytest.raises(APIError):
            op.add({"query1": '["=", "catalog_environment", "production"]'})
github voxpupuli / pypuppetdb / tests / test_querybuilder.py View on Github external
def test_greater_operator(self):
        assert str(GreaterOperator("uptime", 150))\
            == '[">", "uptime", 150]'
        assert str(GreaterOperator("end_time", '2016-05-11T23:22:48.709Z'))\
            == '[">", "end_time", "2016-05-11T23:22:48.709Z"]'
        assert str(GreaterOperator(['parameter', 'version'], 4.0))\
            == '[">", ["parameter", "version"], 4.0]'
        assert str(GreaterOperator("report_timestamp",
                                   datetime.datetime(2016, 6, 11)))\
            == '[">", "report_timestamp", "2016-06-11 00:00:00"]'
github voxpupuli / pypuppetdb / tests / test_querybuilder.py View on Github external
def test_greater_operator(self):
        assert str(GreaterOperator("uptime", 150))\
            == '[">", "uptime", 150]'
        assert str(GreaterOperator("end_time", '2016-05-11T23:22:48.709Z'))\
            == '[">", "end_time", "2016-05-11T23:22:48.709Z"]'
        assert str(GreaterOperator(['parameter', 'version'], 4.0))\
            == '[">", ["parameter", "version"], 4.0]'
        assert str(GreaterOperator("report_timestamp",
                                   datetime.datetime(2016, 6, 11)))\
            == '[">", "report_timestamp", "2016-06-11 00:00:00"]'
github voxpupuli / pypuppetdb / tests / test_querybuilder.py View on Github external
def test_not_operator(self):
        op = NotOperator()
        op.add(EqualsOperator("operatingsystem", "CentOS"))

        assert str(op) == '["not", ["=", "operatingsystem", "CentOS"]]'
        assert repr(op) == 'Query: ["not", ["=", "operatingsystem", "CentOS"]]'
        assert str(op) == '["not", ["=", "operatingsystem", "CentOS"]]'

        with pytest.raises(APIError):
            op.add(GreaterOperator("operatingsystemmajrelease", 6))
        with pytest.raises(APIError):
            op.add([EqualsOperator("architecture", "x86_64"),
                    GreaterOperator("operatingsystemmajrelease", 6)])
github voxpupuli / pypuppetdb / tests / test_querybuilder.py View on Github external
def test_greater_operator(self):
        assert str(GreaterOperator("uptime", 150))\
            == '[">", "uptime", 150]'
        assert str(GreaterOperator("end_time", '2016-05-11T23:22:48.709Z'))\
            == '[">", "end_time", "2016-05-11T23:22:48.709Z"]'
        assert str(GreaterOperator(['parameter', 'version'], 4.0))\
            == '[">", ["parameter", "version"], 4.0]'
        assert str(GreaterOperator("report_timestamp",
                                   datetime.datetime(2016, 6, 11)))\
            == '[">", "report_timestamp", "2016-06-11 00:00:00"]'
github voxpupuli / pypuppetdb / tests / test_querybuilder.py View on Github external
def test_not_operator(self):
        op = NotOperator()
        op.add(EqualsOperator("operatingsystem", "CentOS"))

        assert str(op) == '["not", ["=", "operatingsystem", "CentOS"]]'
        assert repr(op) == 'Query: ["not", ["=", "operatingsystem", "CentOS"]]'
        assert str(op) == '["not", ["=", "operatingsystem", "CentOS"]]'

        with pytest.raises(APIError):
            op.add(GreaterOperator("operatingsystemmajrelease", 6))
        with pytest.raises(APIError):
            op.add([EqualsOperator("architecture", "x86_64"),
                    GreaterOperator("operatingsystemmajrelease", 6)])
github voxpupuli / pypuppetdb / pypuppetdb / QueryBuilder.py View on Github external
def __init__(self, field, value):
        super(GreaterOperator, self).__init__(">", field, value)