Changeset - a9320f18b399
[Not reviewed]
default
0 2 0
Branko Majic (branko) - 10 years ago 2013-11-09 13:59:22
branko@majic.rs
Noticket: Add more logic to the distinct colour generation. Add some extra tests for this.
2 files changed with 23 insertions and 0 deletions:
0 comments (0 inline, 0 general)
conntrackt/tests/test_utils.py
Show inline comments
 
@@ -139,6 +139,23 @@ class GetDistinctColorsTest(TestCase):
 
        equal = abs(colors[0].hsl["h"] + 1 - colors[12].hsl["h"] - reference) < delta
 
        self.assertEqual(True, equal)
 

	
 
    def test_zero_count(self):
 
        """
 
        Tests if an empty list is returned in case the requested count is 0.
 
        """
 

	
 
        colors = utils.get_distinct_colors(0)
 

	
 
        self.assertIsInstance(colors, list)
 
        self.assertEqual(len(colors), 0)
 

	
 
    def test_negative_count(self):
 
        """
 
        Tests if proper exception is raised in case a negative count is passed.
 
        """
 

	
 
        self.assertRaisesRegexp(ValueError, "^Count must be a non-negative integer value\.$", utils.get_distinct_colors, -10)
 

	
 

	
 
class GenerateProjectDiagramTest(TestCase):
 
    """
conntrackt/utils.py
Show inline comments
 
@@ -104,6 +104,12 @@ def get_distinct_colors(count, start=pal
 
        List of distinct palette.Color instances.
 
    """
 

	
 
    # If zero is passed as count, return empty list.
 
    if count == 0:
 
        return []
 
    elif count < 0:
 
        raise ValueError("Count must be a non-negative integer value.")
 

	
 
    # Read the HSL from provided Color.
 
    hue, sat, lum = start.hsl["h"], start.hsl["s"], start.hsl["l"]
 

	
0 comments (0 inline, 0 general)