Exemple #1
0
    def test_write_nested(self):
        test_values = [
            ('person_1', 'infos', 12),
            ('person_1', 'infos.family', ['ambre', 'justin', 'sophia']),
            ('person_2', 'hobbies', {
                'soccer': True
            }),
            ('person_3', 'infos', {
                'age': '100'
            }),
            ('person_3', 'infos.hobbies', {
                'soccer': True
            }),
            ('person_3', 'infos.hobbies.soccer', [{
                'status': 'young'
            }, 'strong', 'fast']),
        ]

        for id_, path, new_value in test_values:
            self.setUp()
            target = MongoCellTarget(self.mongo_client, INDEX, COLLECTION, id_,
                                     path)
            target.write(new_value)
            self.assertEqual(target.read(), new_value)
            self.tearDown()
Exemple #2
0
    def test_write(self):
        ids = ['person_1', 'person_2', 'person_3', 'person_4', 'unknow_person']

        for id_ in ids:
            self.setUp()
            target = MongoCellTarget(self.mongo_client, INDEX, COLLECTION, id_, 'age')
            target.write('100')
            self.assertEqual(target.read(), '100')
Exemple #3
0
    def test_exists(self):
        test_values = [
            ('person_1', 'surname', False),
            ('person_2', 'surname', True),
            ('person_3', 'surname', True),
            ('unknow_person', 'surname', False),
        ]

        for id_, field, result in test_values:
            target = MongoCellTarget(self.mongo_client, INDEX, COLLECTION, id_, field)
            self.assertEqual(result, target.exists())
Exemple #4
0
    def test_read(self):
        test_values = [
            ('person_1', 'surname', None),
            ('person_2', 'surname', 'Gilmore'),
            ('person_3', 'surname', 'Specter'),
            ('person_4', 'surname', ''),
            ('unknown_person', 'surname', None),
        ]

        for id_, field, result in test_values:
            target = MongoCellTarget(self.mongo_client, INDEX, COLLECTION, id_, field)
            self.assertEqual(result, target.read())
Exemple #5
0
    def test_read_nested(self):
        test_values = [
            ('person_1', 'infos', {'family': 'single'}),
            ('person_1', 'infos.family', 'single'),
            ('person_2', 'family', None),
            ('person_4', 'infos', {'family': {'children': ['jack', 'rose']}}),
            ('person_4', 'infos.family', {'children': ['jack', 'rose']}),
            ('person_4', 'infos.sexe', None),
            ('person_4', 'infos.family.children', ['jack', 'rose']),
        ]

        for id_, path, result in test_values:
            target = MongoCellTarget(self.mongo_client, INDEX, COLLECTION, id_, path)
            self.assertEqual(result, target.read())
Exemple #6
0
    def test_exists_nested(self):
        test_values = [
            ('person_1', 'infos', True),
            ('person_1', 'infos.family', True),
            ('person_2', 'family', False),
            ('person_4', 'infos', True),
            ('person_4', 'infos.family', True),
            ('person_4', 'infos.sexe', False),
            ('person_4', 'infos.family.children', True),
            ('person_4', 'infos.family.aunt', False),
        ]

        for id_, path, result in test_values:
            target = MongoCellTarget(self.mongo_client, INDEX, COLLECTION, id_, path)
            self.assertEqual(result, target.exists())
    def output(self):
        from models.mongo import connect_db

        name = f"shirt_{self.date.strftime(DATESTRFORMAT)}_{self.data['luigi_loc']}"

        return MongoCellTarget(connect_db(MONGO_SERVER, MONGO_PORT),
                               MONGO_DATABASE, 'shirts', name, 'scope')
    def output(self):
        from models.mongo import connect_db

        name = f"images_{self.date.strftime(DATESTRFORMAT)}_{self.loc}"

        return MongoCellTarget(connect_db(MONGO_SERVER, MONGO_PORT),
                               MONGO_DATABASE, 'images', name, 'scope')
    def output(self):
        from models.mongo import connect_db

        idx = Path(self.requires().output().path).stem

        return MongoCellTarget(connect_db(MONGO_SERVER, MONGO_PORT),
                               MONGO_DATABASE, 'trends', idx, 'scope')
Exemple #10
0
    def test_write_nested(self):
        test_values = [
            ('person_1', 'infos', 12),
            ('person_1', 'infos.family', ['ambre', 'justin', 'sophia']),
            ('person_2', 'hobbies', {'soccer': True}),
            ('person_3', 'infos', {'age': '100'}),
            ('person_3', 'infos.hobbies', {'soccer': True}),
            ('person_3', 'infos.hobbies.soccer', [{'status': 'young'}, 'strong', 'fast']),
        ]

        for id_, path, new_value in test_values:
            self.setUp()
            target = MongoCellTarget(self.mongo_client, INDEX, COLLECTION, id_, path)
            target.write(new_value)
            self.assertEqual(target.read(), new_value)
            self.tearDown()
    def output(self):
        from models.mongo import connect_db

        idx = self.shirt.get('_id')
        name = idx.replace('shirt', 'shopify')

        # this needs to go to Mongo in next version
        return MongoCellTarget(connect_db(MONGO_SERVER, MONGO_PORT),
                               MONGO_DATABASE, 'shopify', name, 'scope')
Exemple #12
0
 def output(self):
     return MongoCellTarget(MongoClient(), 'quicksign', 'videos',
                            self.video, 'data')