Пример #1
0
 def fields(self, other=None):
     own_fields = Fields(date_times=self.date_time_fields,
                         dates=self.date_fields,
                         encrypted=self.encrypted_fields)
     if other:
         own_fields = own_fields.merge(other)
     if own_fields.is_empty():
         return None
     return self._return_fields(own_fields)
Пример #2
0
    def test_count_date_time_fields(self):
        self.wrapper.count('col', fields=Fields(date_times=['field1', 'field2']))

        self.session.call.assert_called_once_with('mdstudio.db.endpoint.count', {
            'collection': 'col',
            'fields': {
                'datetime': ['field1', 'field2']
            }
        }, claims={'connectionType': 'user'})
Пример #3
0
    def test_insert_many_date_time_fields(self):
        self.wrapper.insert_many('col', [{'test': 8}, {'test4': 4}], fields=Fields(date_times=['field1', 'field2']))

        self.session.call.assert_called_once_with('mdstudio.db.endpoint.insert_many', {
            'collection': 'col',
            'insert': [{'test': 8}, {'test4': 4}],
            'fields': {
                'datetime': ['field1', 'field2']
            }
        }, claims={'connectionType': 'user'})
Пример #4
0
    def test_delete_many_date_time_fields(self):
        self.wrapper.delete_many('col', {'test': 10}, fields=Fields(date_times=['field1', 'field2']))

        self.session.call.assert_called_once_with('mdstudio.db.endpoint.delete_many', {
            'collection': 'col',
            'filter': {'test': 10},
            'fields': {
                'datetime': ['field1', 'field2']
            }
        }, claims={'connectionType': 'user'})
Пример #5
0
    def test_find_one_and_delete_date_time(self):
        self.wrapper.find_one_and_delete('col', {'_id': 50}, fields=Fields(date_times=['field1', 'field2']))

        self.session.call.assert_called_once_with('mdstudio.db.endpoint.find_one_and_delete', {
            'collection': 'col',
            'filter': {'_id': 50},
            'fields': {
                'datetime': ['field1', 'field2']
            }
        }, claims={'connectionType': 'user'})
Пример #6
0
    def test_replace_one_date_time_fields(self):
        self.wrapper.replace_one('col', {'_id': 5}, {'test': 8}, fields=Fields(date_times=['field1', 'field2']))

        self.session.call.assert_called_once_with('mdstudio.db.endpoint.replace_one', {
            'collection': 'col',
            'filter': {'_id': 5},
            'replacement': {'test': 8},
            'upsert': False,
            'fields': {
                'datetime': ['field1', 'field2']
            }
        }, claims={'connectionType': 'user'})
Пример #7
0
    def test_make_cursor(self):
        documents = [
            {
                'test': False
            },
            {
                'test': True
            }
        ]
        d = {
            'cursorId': 1234,
            'alive': False,
            'results': documents
        }

        db = SessionDatabaseWrapper(mock.MagicMock())
        db.make_cursor(d, Fields()).addCallback(self.assertIsInstance, Cursor)
        self.assertIsInstance(db.make_cursor(d, Fields()), Deferred)

        docs = yield db.make_cursor(d, Fields()).to_list()

        self.assertEqual(docs, documents)