Example #1
0
 def test_update(self, mock_update):
     wrapped_doc = IndexedFile(
         **{
             'name': 'folder1',
             'system': 'test.system',
             'path': '/path/to/folder',
             'format': 'folder'
         })
     base = BaseESResource(wrapped_doc=wrapped_doc)
     base.update(**{'name': 'folder2'})
     mock_update.assert_called_with(**{'name': 'folder2'})
Example #2
0
    def test_to_dict(self, mock_to_dict):
        wrapped_doc = IndexedFile(
            **{
                'name': 'folder1',
                'system': 'test.system',
                'path': '/path/to/folder',
                'format': 'folder'
            })
        base = BaseESResource(wrapped_doc=wrapped_doc)

        base.to_dict()
        mock_to_dict.assert_called_with()
Example #3
0
    def test_wrap(self, mock_update):
        wrapped_doc = IndexedFile(
            **{
                'name': 'folder1',
                'system': 'test.system',
                'path': '/path/to/folder',
                'format': 'folder'
            })
        base = BaseESResource(wrapped_doc=wrapped_doc)
        self.assertEqual(base._wrapped, wrapped_doc)

        base_with_kwargs = BaseESResource(wrapped_doc=wrapped_doc,
                                          **{'name': 'folder2'})
        mock_update.assert_called_with(**{'name': 'folder2'})
Example #4
0
    def test_getter_and_setter(self):
        wrapped_doc = IndexedFile(
            **{
                'name': 'folder1',
                'system': 'test.system',
                'path': '/path/to/folder',
                'format': 'folder'
            })
        base = BaseESResource(wrapped_doc=wrapped_doc)

        base.name = 'folder2'
        self.assertEqual(base.name, 'folder2')
        self.assertEqual(base._wrapped.name, 'folder2')

        base.newAttr = 'this attr is not in the wrapped doc'
        self.assertEqual(base.newAttr, 'this attr is not in the wrapped doc')
        self.assertFalse(hasattr(base._wrapped, 'newAttr'))
Example #5
0
    def test_init(self, mock_wrap):
        wrapped_doc = IndexedFile(
            **{
                'name': 'folder1',
                'system': 'test.system',
                'path': '/path/to/folder',
                'format': 'folder'
            })

        BaseESResource(wrapped_doc=wrapped_doc)
        mock_wrap.assert_called_with(wrapped_doc)