-
-
Notifications
You must be signed in to change notification settings - Fork 694
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added datasette.get_database() method
Refs #576
- Loading branch information
Showing
5 changed files
with
42 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
""" | ||
Tests for the datasette.app.Datasette class | ||
""" | ||
from .fixtures import app_client | ||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def datasette(app_client): | ||
return app_client.ds | ||
|
||
|
||
def test_get_database(datasette): | ||
db = datasette.get_database("fixtures") | ||
assert "fixtures" == db.name | ||
with pytest.raises(KeyError): | ||
datasette.get_database("missing") | ||
|
||
|
||
def test_get_database_no_argument(datasette): | ||
# Returns the first available database: | ||
db = datasette.get_database() | ||
assert "fixtures" == db.name |