Ejemplo n.º 1
0
    def test_nodb_all_subpath(self):
        # create dummy bucket and store some objects
        bucket_name = 'dummy_bucket_12345_qwerty'
        self._create_mock_bucket(bucket_name)

        nodb = NoDB(bucket_name)
        nodb.human_readable_indexes = True
        nodb.index = "path"

        jeff = {
            "Name": "Jeff",
            "age": 19,
            "path": "persons/jeff",
            "type": "person"
        }
        michael = {
            "Name": "Michael",
            "age": 19,
            "path": "persons/michael",
            "type": "person"
        }
        car = {"Name": "Acura TSX", "path": "vehicles/car", "type": "vehicle"}

        nodb.save(jeff)
        nodb.save(michael)
        nodb.save(car)

        persons = nodb.all(subpath="persons/")
        self.assertListEqual([jeff, michael], persons)
Ejemplo n.º 2
0
    def test_nodb_all(self):
        # create dummy bucket and store some objects
        bucket_name = 'dummy_bucket_12345_qwerty'
        self._create_mock_bucket(bucket_name)

        nodb = NoDB(bucket_name)
        nodb.index = "Name"

        nodb.save({"Name": "John", "age": 19})
        nodb.save({"Name": "Jane", "age": 20})

        all_objects = nodb.all()
        self.assertListEqual([{"Name": "John", "age": 19}, {"Name": "Jane", "age": 20}], all_objects)
Ejemplo n.º 3
0
    def test_nodb_save_load_all_subpath(self):
        bucket_name = 'noahonnumbers-blog'

        nodb = NoDB(bucket_name)
        nodb.human_readable_indexes = True
        nodb.index = "path"

        jeff = {"Name": "Jeff", "age": 19, "path": "persons/jeff", "type": "person"}
        michael = {"Name": "Michael", "age": 19, "path": "persons/michael", "type": "person"}
        car = {"Name": "Acura TSX", "path": "vehicles/car", "type": "vehicle"}

        nodb.save(jeff)
        nodb.save(michael)
        nodb.save(car)

        persons = nodb.all(subpath="persons/")
        self.assertListEqual([jeff, michael], persons)