54 lines
1.6 KiB
Python
54 lines
1.6 KiB
Python
from associations.admin import AssociationTypeColumn
|
|
from associations.models import AssociationPage
|
|
from tests.conftest import AssociationPageFactory
|
|
|
|
|
|
def test_associationpage_persists_via_factory(association_index):
|
|
page = AssociationPageFactory(
|
|
parent=association_index,
|
|
title="EDB-gjengen",
|
|
excerpt="WOW FLINKE",
|
|
association_type=AssociationPage.AssociationType.UTVALG,
|
|
)
|
|
|
|
reloaded = AssociationPage.objects.get(pk=page.pk)
|
|
assert reloaded.title == "EDB-gjengen"
|
|
assert reloaded.excerpt == "WOW FLINKE"
|
|
assert reloaded.association_type == "utvalg"
|
|
|
|
|
|
def test_association_type_column_renders_forening_display(association_index):
|
|
page = AssociationPageFactory(
|
|
parent=association_index,
|
|
association_type=AssociationPage.AssociationType.FORENING,
|
|
)
|
|
column = AssociationTypeColumn("association_type")
|
|
|
|
assert column.get_value(page) == "Forening"
|
|
|
|
|
|
def test_association_type_column_renders_utvalg_display(association_index):
|
|
page = AssociationPageFactory(
|
|
parent=association_index,
|
|
association_type=AssociationPage.AssociationType.UTVALG,
|
|
)
|
|
column = AssociationTypeColumn("association_type")
|
|
|
|
assert column.get_value(page) == "Utvalg"
|
|
|
|
|
|
def test_graphql_association_index_query(association_index, graphql_post):
|
|
response, body = graphql_post(
|
|
"""
|
|
query {
|
|
associationIndex {
|
|
title
|
|
}
|
|
}
|
|
"""
|
|
)
|
|
|
|
assert response.status_code == 200
|
|
assert "errors" not in body, body
|
|
assert body["data"]["associationIndex"]["title"] == association_index.title
|