Repository navigation
feat: Add not found errors to the file manager #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c75b2a3
feat: Add not found errors to the file manager
joamag 76fb9b6
test: Remove GridFS tests that require pymongo
joamag 6971b2a
feat: Add raise_e to the file manager list
joamag aa26f20
feat: Answer file manager not found errors with 404
joamag File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| #!/usr/bin/python | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| # Hive Colony Framework | ||
| # Copyright (c) 2008-2024 Hive Solutions Lda. | ||
| # | ||
| # This file is part of Hive Colony Framework. | ||
| # | ||
| # Hive Colony Framework is free software: you can redistribute it and/or modify | ||
| # it under the terms of the Apache License as published by the Apache | ||
| # Foundation, either version 2.0 of the License, or (at your option) any | ||
| # later version. | ||
| # | ||
| # Hive Colony Framework is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # Apache License for more details. | ||
| # | ||
| # You should have received a copy of the Apache License along with | ||
| # Hive Colony Framework. If not, see <http://www.apache.org/licenses/>. | ||
|
|
||
| __author__ = "João Magalhães <joamag@hive.pt>" | ||
| """ The author(s) of the module """ | ||
|
|
||
| __copyright__ = "Copyright (c) 2008-2024 Hive Solutions Lda." | ||
| """ The copyright for the module """ | ||
|
|
||
| __license__ = "Apache License, Version 2.0" | ||
| """ The license for the module """ | ||
|
|
||
|
|
||
| class MockConnection(object): | ||
| """ | ||
| Mock connection, holding the (engine) file connection | ||
| that is used by the file engine operations. | ||
| """ | ||
|
|
||
| def __init__(self, file_connection): | ||
| self.file_connection = file_connection |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| #!/usr/bin/python | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| # Hive Colony Framework | ||
| # Copyright (c) 2008-2024 Hive Solutions Lda. | ||
| # | ||
| # This file is part of Hive Colony Framework. | ||
| # | ||
| # Hive Colony Framework is free software: you can redistribute it and/or modify | ||
| # it under the terms of the Apache License as published by the Apache | ||
| # Foundation, either version 2.0 of the License, or (at your option) any | ||
| # later version. | ||
| # | ||
| # Hive Colony Framework is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # Apache License for more details. | ||
| # | ||
| # You should have received a copy of the Apache License along with | ||
| # Hive Colony Framework. If not, see <http://www.apache.org/licenses/>. | ||
|
|
||
| __author__ = "João Magalhães <joamag@hive.pt>" | ||
| """ The author(s) of the module """ | ||
|
|
||
| __copyright__ = "Copyright (c) 2008-2024 Hive Solutions Lda." | ||
| """ The copyright for the module """ | ||
|
|
||
| __license__ = "Apache License, Version 2.0" | ||
| """ The license for the module """ | ||
|
|
||
| import shutil | ||
| import tempfile | ||
|
|
||
| import colony | ||
|
|
||
| from . import mocks | ||
| from . import system | ||
|
|
||
|
|
||
| class FileFSTest(colony.Test): | ||
| """ | ||
| The file FS infra-structure test class, responsible | ||
| for the returning of the associated tests. | ||
| """ | ||
|
|
||
| def get_bundle(self): | ||
| return (FileFSTestCase,) | ||
|
|
||
| def set_up(self, test_case): | ||
| colony.Test.set_up(self, test_case) | ||
|
|
||
| def tear_down(self, test_case): | ||
| colony.Test.tear_down(self, test_case) | ||
|
|
||
|
|
||
| class FileFSTestCase(colony.ColonyTestCase): | ||
| """ | ||
| The file FS test case, verifying the file engine operations | ||
| against a temporary directory used as the base path. | ||
| """ | ||
|
|
||
| @staticmethod | ||
| def get_description(): | ||
| return "File FS test case" | ||
|
|
||
| def setUp(self): | ||
| colony.ColonyTestCase.setUp(self) | ||
| self.temp_path = tempfile.mkdtemp() | ||
| self.connection = mocks.MockConnection( | ||
| system.FsConnection("default", self.temp_path) | ||
| ) | ||
|
|
||
| def tearDown(self): | ||
| shutil.rmtree(self.temp_path, ignore_errors=True) | ||
| colony.ColonyTestCase.tearDown(self) | ||
|
|
||
| def test_exists(self): | ||
| self.plugin.put_data(self.connection, b"hello", "images/hello.txt") | ||
|
|
||
| self.assertEqual(self.plugin.exists(self.connection, "images/hello.txt"), True) | ||
| self.assertEqual(self.plugin.exists(self.connection, "/images/hello.txt"), True) | ||
| self.assertEqual( | ||
| self.plugin.exists(self.connection, "images/missing.txt"), False | ||
| ) | ||
|
|
||
| # verifies that a directory is considered to exist, so that its | ||
| # retrieval as a file fails with the error of the file system (not | ||
| # being reported as a file that does not exist) | ||
| self.assertEqual(self.plugin.exists(self.connection, "images"), True) | ||
| self.assertRaises(IOError, self.plugin.get, self.connection, "images") | ||
|
|
||
| def test_exists_directory(self): | ||
| self.plugin.put_data(self.connection, b"hello", "images/hello.txt") | ||
|
|
||
| self.assertEqual(self.plugin.exists_directory(self.connection, "images"), True) | ||
| self.assertEqual(self.plugin.exists_directory(self.connection, "/images"), True) | ||
| self.assertEqual(self.plugin.exists_directory(self.connection, "images/"), True) | ||
| self.assertEqual(self.plugin.exists_directory(self.connection, ""), True) | ||
| self.assertEqual( | ||
| self.plugin.exists_directory(self.connection, "missing"), False | ||
| ) | ||
|
|
||
| # verifies that a file is not considered to be a directory, so | ||
| # that its listing is reported as a directory that does not exist | ||
| self.assertEqual( | ||
| self.plugin.exists_directory(self.connection, "images/hello.txt"), False | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.