-
Notifications
You must be signed in to change notification settings - Fork 23
Fix 142 #143
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
Open
JanCaha
wants to merge
6
commits into
master
Choose a base branch
from
fix-142
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fix 142 #143
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7f2bf9e
either get mp as MerginProject or string with path to it
JanCaha 3d28eab
explicitly convert to string
JanCaha bf10188
always store project id in db_comment
JanCaha bc55030
check that project id in DB and project ID are the same, otherwise ra…
JanCaha 373c2c3
better cleanup prior and after tests
JanCaha 2ead57e
test that changing project raises correct error
JanCaha 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,7 @@ | |
| API_USER = os.environ.get("TEST_API_USERNAME") | ||
| USER_PWD = os.environ.get("TEST_API_PASSWORD") | ||
| WORKSPACE = os.environ.get("TEST_API_WORKSPACE") | ||
| TMP_DIR = tempfile.gettempdir() | ||
| TMP_DIR = os.path.join(tempfile.gettempdir(), "dbsync_test") | ||
| TEST_DATA_DIR = os.path.join( | ||
| os.path.dirname(os.path.realpath(__file__)), | ||
| "test_data", | ||
|
|
@@ -167,7 +167,7 @@ def init_sync_from_geopackage(mc, project_name, source_gpkg_path, ignored_tables | |
| dbsync_init(mc) | ||
|
|
||
|
|
||
| @pytest.fixture(scope="function") | ||
| @pytest.fixture(scope="session") | ||
| def mc(): | ||
| assert SERVER_URL and API_USER and USER_PWD | ||
| # assert SERVER_URL and SERVER_URL.rstrip('/') != 'https://app.merginmaps.com/' and API_USER and USER_PWD | ||
|
|
@@ -299,3 +299,37 @@ def init_sync_from_db(mc: MerginClient, project_name: str, path_sql_file: str, i | |
| ) | ||
|
|
||
| dbsync_init(mc) | ||
|
|
||
|
|
||
| def _clean_workspace(mc: MerginClient, workspace: str) -> None: | ||
| """Immediately delete all projects in the test workspace.""" | ||
|
|
||
| projects = mc.projects_list(only_namespace=workspace) | ||
|
|
||
| for project in projects: | ||
| mc.delete_project_now(f"{workspace}/{project['name']}") | ||
|
|
||
|
|
||
| @pytest.fixture(autouse=True, scope="session") | ||
| def clean_workspace(mc: MerginClient): | ||
| """Delete all projects in the test workspace prior and after test session.""" | ||
|
|
||
| _clean_workspace(mc, WORKSPACE) | ||
| yield | ||
| _clean_workspace(mc, WORKSPACE) | ||
|
|
||
|
|
||
| def _remove_dir(dir_path: str) -> None: | ||
| """Remove directory if it exists.""" | ||
|
|
||
| if os.path.exists(dir_path): | ||
| shutil.rmtree(dir_path) | ||
|
|
||
|
|
||
| @pytest.fixture(autouse=True, scope="session") | ||
| def clean_test_dir(): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how about having only one cleanup fixture and merge this one with other cleanup? |
||
| """Remove and recreate temporary directory for test files. Remove it after test session.""" | ||
| _remove_dir(TMP_DIR) | ||
| os.makedirs(TMP_DIR) | ||
| yield | ||
| _remove_dir(TMP_DIR) | ||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is new info in db comment and we need at least one successful run can't this fail for existing set ups?