forked from my8100/scrapydweb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support customizing DATA_PATH (my8100#78)
- Loading branch information
Showing
10 changed files
with
98 additions
and
50 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 was deleted.
Oops, something went wrong.
This file contains 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,23 @@ | ||
# coding: utf-8 | ||
import os | ||
import re | ||
|
||
from scrapydweb.vars import APSCHEDULER_DATABASE_URI, DATA_PATH, DATABASE_PATH, ROOT_DIR | ||
|
||
|
||
def test_option_data_path(app): | ||
data_path = os.environ.get('DATA_PATH', '') | ||
if data_path and os.environ.get('TEST_ON_CIRCLECI', 'False').lower() == 'true': | ||
assert not os.path.isdir(os.path.join(ROOT_DIR, 'data', 'database')) | ||
assert os.path.isdir(os.path.join(data_path or DATA_PATH, 'database')) | ||
|
||
|
||
def test_option_database_url(app): | ||
database_url = os.environ.get('DATABASE_URL', 'sqlite:///' + DATABASE_PATH) | ||
assert APSCHEDULER_DATABASE_URI.startswith(database_url) | ||
assert app.config['SQLALCHEMY_DATABASE_URI'].startswith(database_url) | ||
for value in app.config['SQLALCHEMY_BINDS'].values(): | ||
assert value.startswith(database_url) | ||
|
||
m = re.match(r'sqlite:///(.+)$', database_url) | ||
assert os.path.isdir(m.group(1) if m else DATABASE_PATH) |