コード例 #1
0
    def test_can_handle_first(self):
        # the argument to filter for
        filter_args = dict(first=2, offset=0)
        # filter the models
        records_filtered = filter_model(self.model, filter_args)

        # figure out the names of the records we retrieved
        retrieved_names = [record.name for record in records_filtered]
        expected = ['foo1', 'bar1']
        assert retrieved_names == expected, (
            "Got %(retrieved_names)s instead of %(expected)s" % locals())
コード例 #2
0
    def test_can_handle_first_offset_order_by(self):
        # the argument to filter for
        filter_args = dict(first=4, offset=2, order_by=["date", "-name"])
        # filter the models
        records_filtered = filter_model(self.model, filter_args)

        # figure out the names of the records we retrieved
        retrieved_names = [record.name for record in records_filtered]
        expected = ['foo7', 'foo6', 'foo5', 'foo4']
        assert retrieved_names == expected, (
            "Got %(retrieved_names)s instead of %(expected)s" % locals())
コード例 #3
0
ファイル: test_filter.py プロジェクト: nautilus/nautilus
    def test_can_handle_first(self):
        # the argument to filter for
        filter_args = dict(first=2, offset=0)
        # filter the models
        records_filtered = filter_model(self.model, filter_args)

        # figure out the names of the records we retrieved
        retrieved_names = [record.name for record in records_filtered]
        expected = ['foo1', 'bar1']
        assert retrieved_names == expected, (
            "Got %(retrieved_names)s instead of %(expected)s" % locals()
        )
コード例 #4
0
ファイル: test_filter.py プロジェクト: nautilus/nautilus
    def test_can_handle_first_offset_order_by(self):
        # the argument to filter for
        filter_args = dict(first=4, offset=2, order_by=["date", "-name"])
        # filter the models
        records_filtered = filter_model(self.model, filter_args)

        # figure out the names of the records we retrieved
        retrieved_names = [record.name for record in records_filtered]
        expected = ['foo7', 'foo6', 'foo5', 'foo4']
        assert retrieved_names == expected, (
            "Got %(retrieved_names)s instead of %(expected)s" % locals()
        )
コード例 #5
0
    def test_can_filter_by_field(self):
        # the argument to filter for
        filter_args = dict(name='foo1')
        # filter the models
        records_filtered = filter_model(self.model, filter_args)

        # make sure only one record was returned
        assert len(records_filtered) == 1, (
            "More than one record was returned by filter.")

        # pull out the retrieved record
        retrieved_record_name = records_filtered[0].name
        # make sure the first name matches
        expected = 'foo1'
        assert retrieved_record_name == expected, (
            "Got %(retrieved_record_name)s instead of %(expected)s" % locals())
コード例 #6
0
    def test_can_filter_by_contains(self):
        # the argument to filter for
        filter_args = dict(name_in=['foo1', 'foo2'])
        # filter the models
        records_filtered = filter_model(self.model, filter_args)

        # make sure only one record was returned
        assert len(records_filtered) == 2, (
            "More than one record was returned by filter.")

        # figure out the names of the records we retrieved
        retrieved_names = {record.name for record in records_filtered}

        # make sure the first name matches
        expected = {'foo1', 'foo2'}
        assert retrieved_names == expected, (
            "Got %(retrieved_names)s instead of %(expected)s" % locals())
コード例 #7
0
ファイル: test_filter.py プロジェクト: nautilus/nautilus
    def test_can_filter_by_field(self):
        # the argument to filter for
        filter_args = dict(name='foo1')
        # filter the models
        records_filtered = filter_model(self.model, filter_args)

        # make sure only one record was returned
        assert len(records_filtered) == 1, (
            "More than one record was returned by filter."
        )

        # pull out the retrieved record
        retrieved_record_name = records_filtered[0].name
        # make sure the first name matches
        expected = 'foo1'
        assert retrieved_record_name == expected, (
            "Got %(retrieved_record_name)s instead of %(expected)s" % locals()
        )
コード例 #8
0
ファイル: test_filter.py プロジェクト: nautilus/nautilus
    def test_can_filter_by_contains(self):
        # the argument to filter for
        filter_args = dict(name_in=['foo1', 'foo2'])
        # filter the models
        records_filtered = filter_model(self.model, filter_args)

        # make sure only one record was returned
        assert len(records_filtered) == 2, (
            "More than one record was returned by filter."
        )

        # figure out the names of the records we retrieved
        retrieved_names = {record.name for record in records_filtered}

        # make sure the first name matches
        expected = {'foo1', 'foo2'}
        assert retrieved_names == expected, (
            "Got %(retrieved_names)s instead of %(expected)s" % locals()
        )
コード例 #9
0
 def resolve_all_models(self, args, info):
     # filter the model query according to the arguments
     return filter_model(Model, args)