Skip to content

Commit

Permalink
Basic utils tests added.
Browse files Browse the repository at this point in the history
  • Loading branch information
idlesign committed Dec 17, 2016
1 parent 04de794 commit 7e50bc9
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions sitetree/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#! -*- encoding: utf-8 -*-
from __future__ import unicode_literals

import pytest
from django.core.exceptions import ImproperlyConfigured


def test_import():

from sitetree.utils import import_project_sitetree_modules

modules = import_project_sitetree_modules()

assert len(modules) == 1
assert modules[0].sitetrees


def test_get_app_n_model():

from sitetree.utils import get_app_n_model

app, model = get_app_n_model('MODEL_TREE')
assert app == 'sitetree'
assert model == 'Tree'

with pytest.raises(ImproperlyConfigured):
get_app_n_model('ALIAS_TRUNK')


def test_import_app_sitetree_module():

from sitetree.utils import import_app_sitetree_module

with pytest.raises(ImportError):
import_app_sitetree_module('sitetre')


def test_import_project_sitetree_modules():

from sitetree import settings
from sitetree.models import Tree
from sitetree.utils import get_model_class

cls = get_model_class('MODEL_TREE')

assert cls is Tree

settings.MODEL_TREE = 'nowhere.Model'

with pytest.raises(ImproperlyConfigured):
get_model_class('MODEL_TREE')

0 comments on commit 7e50bc9

Please sign in to comment.