-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dcf65b0
commit a34518b
Showing
8 changed files
with
188 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from __future__ import annotations | ||
from typing import Any | ||
import pytest | ||
|
||
from ckanext.collection.utils import * | ||
|
||
|
||
class TestCollection: | ||
def test_basic_collection_creation(self): | ||
obj = Collection("", {}) | ||
assert isinstance(obj.columns, Columns) | ||
assert isinstance(obj.pager, ClassicPager) | ||
assert isinstance(obj.filters, Filters) | ||
assert isinstance(obj.data, Data) | ||
assert isinstance(obj.serializer, Serializer) | ||
|
||
def test_custom_instance(self): | ||
data = Data(None) | ||
|
||
collection = Collection("", {}, data_instance=data) | ||
assert collection.data is data | ||
assert data.attached is collection | ||
|
||
def test_custom_factory(self): | ||
custom_factory = Data[Any, Any].with_attributes() | ||
collection = Collection[Any]("", {}, data_factory=custom_factory) | ||
|
||
assert isinstance(collection.data, custom_factory) | ||
|
||
def test_replace_service(self): | ||
collection = Collection("", {}) | ||
data = Data(None) | ||
columns = Columns(None) | ||
|
||
assert collection.data is not data | ||
assert collection.columns is not columns | ||
|
||
collection.replace_service(data) | ||
collection.replace_service(columns) | ||
|
||
assert collection.data is data | ||
assert collection.columns is columns |
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 |
---|---|---|
@@ -1,8 +1,38 @@ | ||
from .collection import Collection | ||
from .collection import Collection, ApiCollection, ModelCollection | ||
from .columns import Columns | ||
from .data import Data | ||
from .data import Data, ModelData, ApiData, ApiListData, ApiSearchData | ||
from .filters import Filters | ||
from .pager import Pager | ||
from .serialize import Serializer | ||
from .pager import Pager, ClassicPager | ||
from .serialize import ( | ||
Serializer, | ||
CsvSerializer, | ||
JsonSerializer, | ||
JsonlSerializer, | ||
ChartJsSerializer, | ||
HtmlSerializer, | ||
TableSerializer, | ||
HtmxTableSerializer, | ||
) | ||
|
||
__all__ = ["Serializer", "Filters", "Pager", "Collection", "Data", "Columns"] | ||
__all__ = [ | ||
"ApiCollection", | ||
"ApiData", | ||
"ApiListData", | ||
"ApiSearchData", | ||
"ChartJsSerializer", | ||
"ClassicPager", | ||
"Collection", | ||
"Columns", | ||
"CsvSerializer", | ||
"Data", | ||
"Filters", | ||
"HtmlSerializer", | ||
"HtmxTableSerializer", | ||
"JsonSerializer", | ||
"JsonlSerializer", | ||
"ModelCollection", | ||
"ModelData", | ||
"Pager", | ||
"Serializer", | ||
"TableSerializer", | ||
] |
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