Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
"""Utility unit tests."""

import pytest
from dribdat.utils import unpack_csvlist

def test_unpack_csvlist_empty():
assert unpack_csvlist(None) == []
assert unpack_csvlist("") == []

def test_unpack_csvlist_normal():
assert unpack_csvlist("a,b,c") == ["a", "b", "c"]

def test_unpack_csvlist_whitespace():
assert unpack_csvlist(" a , b,c ") == ["a", "b", "c"]

def test_unpack_csvlist_duplicate():
assert unpack_csvlist("a,b,a,c,b") == ["a", "b", "c"]

def test_unpack_csvlist_custom_separator():
assert unpack_csvlist("a|b|c", sep="|") == ["a", "b", "c"]
assert unpack_csvlist("a;b;a", sep=";") == ["a", "b"]

def test_unpack_csvlist_empty_elements():
assert unpack_csvlist("a,,b") == ["a", "", "b"]
assert unpack_csvlist("a, ,b") == ["a", "", "b"]