Beispiel #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()
Beispiel #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')
Beispiel #3
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())
Beispiel #4
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())
Beispiel #5
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()