TestRandomNameTitle   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test_name_returns_str() 0 3 2
A test_name_returns_spaced_name() 0 3 2
1
"""Tests for 'random' filters."""
2
3
import re
4
5
from flask_extras.filters import random
6
7
8
class TestRandomChoice:
9
    """All tests for random choice function."""
10
11
    def test_choice_returns_str(self):
12
        """Test the return value for a valid type."""
13
        assert isinstance(random.rand_choice([0, 1, 2, 3]), int)
14
15
16
class TestRandomNameTitle:
17
    """All tests for random title function."""
18
19
    def test_name_returns_str(self):
20
        """Test the return value for a valid type."""
21
        assert isinstance(random.rand_name_title('Chris'), str)
22
23
    def test_name_returns_spaced_name(self):
24
        """Test the return value for a valid value length."""
25
        assert len(random.rand_name_title('Chris').split()) == 2
26
27
28
class TestRandomColor:
29
    """All tests for random color function."""
30
31
    def test_returns_str(self):
32
        """Test the return value for a valid type."""
33
        assert isinstance(random.rand_color(), str)
34
35
    def test_returns_rgba_format(self):
36
        """Test the return value for a valid string format."""
37
        re_rgba = r'rgba\([0-9{0,3}]+, [0-9{0,3}]+, [0-9{0,3}]+, [0-9{0,3}]+\)'
38
        assert re.match(re_rgba, random.rand_color(alpha=10)) is not None
39