Passed
Pull Request — master (#110)
by Michel
01:01
created

tests.test_column_dt   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 11
eloc 22
dl 0
loc 42
rs 10
c 0
b 0
f 0

5 Functions

Rating   Name   Duplication   Size   Complexity  
A test_init_with_default_params() 0 6 3
A test_with_filter_ok() 0 6 2
A test_with_valid_nulls_order() 0 6 2
A test_with_invalid_search_method() 0 4 2
A test_with_invalid_nulls_order() 0 4 2
1
import pytest
2
3
from datatables import ColumnDT
4
5
from .models import User
6
7
8
def test_init_with_default_params():
9
    """Return column with given default params."""
10
    col = ColumnDT(User.id)
11
12
    if not (col.nulls_order is None or col.search_method == 'string_contains'):
13
        raise AssertionError()
14
15
16
def test_with_filter_ok():
17
    """Return column with a specific filter."""
18
    col = ColumnDT(User.name, search_method='like')
19
20
    if col.search_method != 'like':
21
        raise AssertionError()
22
23
24
def test_with_valid_nulls_order():
25
    """Return column with a specific filter."""
26
    col = ColumnDT(User.name, nulls_order='nullslast')
27
28
    if col.nulls_order != 'nullslast':
29
        raise AssertionError()
30
31
32
def test_with_invalid_nulls_order():
33
    """Return column with a specific filter."""
34
    with pytest.raises(ValueError):
35
        ColumnDT(User.name, nulls_order='invalid')
36
37
38
def test_with_invalid_search_method():
39
    """Return column with a specific filter."""
40
    with pytest.raises(ValueError):
41
        ColumnDT(User.name, search_method='invalid')
42