Select Git revision
design_method.md
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
test_create_id.py 929 B
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Unittests for create_id
"""
import unittest
import plotid.create_id as cid
class TestCreateID(unittest.TestCase):
"""
Class for all unittests of the create_id module.
"""
def test_existence(self):
"""Test if create_id returns a string."""
self.assertIsInstance(cid.create_id('time'), str)
self.assertIsInstance(cid.create_id('random'), str)
def test_errors(self):
""" Test if Errors are raised when id_method is wrong. """
with self.assertRaises(ValueError):
cid.create_id(3)
with self.assertRaises(ValueError):
cid.create_id('h')
def test_length(self):
""" Test if figure_id has the correct length. """
self.assertEqual(len(cid.create_id('time')), 10)
self.assertEqual(len(cid.create_id('random')), 8)
if __name__ == '__main__':
unittest.main()