Beispiel #1
0
    def normalCollection_test(self):
        one = gateModel.create(**baseData)
        two = gateModel.create(**newData)
        parts = [two, one]

        collection = RethinkCollection(gateModel)

        results = collection.fetch()
        assert len(results) == 2
        for model in range(len(results)):
            bit = parts[model]
            model = results[model]

            assert model.id == bit.id
            assert model.what == bit.what

        one.delete()
        two.delete()
    def normalCollection_test(self):
        one = gateModel.create(**baseData)
        two = gateModel.create(**newData)
        parts = [two, one]

        collection = RethinkCollection(gateModel)

        results = collection.fetch()
        assert len(results) == 2
        for model in range(len(results)):
            bit = parts[model]
            model = results[model]

            assert model.id == bit.id
            assert model.what == bit.what

        one.delete()
        two.delete()
Beispiel #3
0
    def joinCollection_test(self):
        one = gateModel.create(**baseData)
        two = gateModel.create(**newData)

        three = episodeModel.create(**classmethodData)
        four = episodeModel.create(**secondJoinData)

        collection = RethinkCollection(gateModel)
        collection.joinOnAs(episodeModel, "episodes", "epi")

        results = collection.fetch()
        assert len(results) == 2
        for result in results:
            assert result.epi
            assert result.epi.id == result.episodes

        one.delete()
        two.delete()
        three.delete()
        four.delete()
    def joinCollection_test(self):
        one = gateModel.create(**baseData)
        two = gateModel.create(**newData)

        three = episodeModel.create(**classmethodData)
        four = episodeModel.create(**secondJoinData)

        collection = RethinkCollection(gateModel)
        collection.joinOnAs(episodeModel, "episodes", "epi")

        results = collection.fetch()
        assert len(results) == 2
        for result in results:
            assert result.epi
            assert result.epi.id == result.episodes

        one.delete()
        two.delete()
        three.delete()
        four.delete()
    def orderBy_test(self):
        one = gateModel.create(**baseData)
        two = gateModel.create(**newData)

        three = episodeModel.create(**classmethodData)
        four = episodeModel.create(**secondJoinData)

        collection = RethinkCollection(gateModel)
        collection.orderBy('episodes', 'asc')
        results = collection.fetch()
        assert results[0].episodes < results[1].episodes

        collection = RethinkCollection(gateModel)
        collection.orderBy('episodes')
        results = collection.fetch()
        assert results[0].episodes > results[1].episodes

        one.delete()
        two.delete()
        three.delete()
        four.delete()
Beispiel #6
0
    def orderBy_test(self):
        one = gateModel.create(**baseData)
        two = gateModel.create(**newData)

        three = episodeModel.create(**classmethodData)
        four = episodeModel.create(**secondJoinData)

        collection = RethinkCollection(gateModel)
        collection.orderBy('episodes', 'asc')
        results = collection.fetch()
        assert results[0].episodes < results[1].episodes

        collection = RethinkCollection(gateModel)
        collection.orderBy('episodes')
        results = collection.fetch()
        assert results[0].episodes > results[1].episodes

        one.delete()
        two.delete()
        three.delete()
        four.delete()
    def limit_test(self):
        one = gateModel.create(**baseData)
        two = gateModel.create(**newData)
        three = gateModel.create(**newData2)

        limitValue = 2

        collection = RethinkCollection(gateModel)
        collection.limit(limitValue)
        results = collection.fetch()

        assert len(results) <= limitValue

        if limitValue > 1:
            collection = RethinkCollection(gateModel)
            collection.orderBy('episodes', 'asc').limit(limitValue)
            results = collection.fetch()
            assert results[0].episodes < results[1].episodes

            collection = RethinkCollection(gateModel)
            collection.orderBy('episodes', 'asc').offset(1).limit(limitValue)
            results = collection.fetch()
            assert results[0].episodes < results[1].episodes

        one.delete()
        two.delete()
        three.delete()
    def offset_test(self):
        one = gateModel.create(**baseData)
        two = gateModel.create(**newData)
        three = gateModel.create(**newData2)

        offsetValue = 1

        collection = RethinkCollection(gateModel)
        results = collection.fetch()
        totalRows = len(results)

        collection.offset(offsetValue)
        results = collection.fetch()
        offsetRows = len(results)

        assert offsetRows == (totalRows - offsetValue)

        collection = RethinkCollection(gateModel)
        collection.orderBy('episodes').offset(offsetValue)
        results = collection.fetch()
        if len(results) > 1:
            assert results[0].episodes > results[1].episodes

        one.delete()
        two.delete()
        three.delete()