Skip to content
Snippets Groups Projects
tests.py 1.08 KiB
Newer Older
  • Learn to ignore specific revisions
  • from django.test import SimpleTestCase
    
    Todd Dembrey's avatar
    Todd Dembrey committed
    from django.forms import Form
    
    Todd Dembrey's avatar
    Todd Dembrey committed
    
    
    from .workflow import Workflow, Stage
    
    class TestWorkflowCreation(SimpleTestCase):
    
        def test_can_create_workflow(self):
            name = 'single_stage'
    
    Todd Dembrey's avatar
    Todd Dembrey committed
            stage = Stage('stage_name', Form())
    
            workflow = Workflow(name, stage)
    
            self.assertEqual(workflow.name, name)
    
            self.assertCountEqual(workflow.stages, [stage])
    
        def test_stages_required_for_workflow(self):
            name = 'single_stage'
            with self.assertRaises(ValueError):
                Workflow(name)
    
        def test_can_iterate_through_workflow(self):
    
    Todd Dembrey's avatar
    Todd Dembrey committed
            stage1 = Stage('stage_one', Form())
            stage2 = Stage('stage_two', Form())
    
            workflow = Workflow('two_stage', stage1, stage2)
            for stage, check in zip(workflow, [stage1, stage2]):
                self.assertEqual(stage, check)
    
    
    
    class TestStageCreation(SimpleTestCase):
        def test_can_create_stage(self):
            name = 'the_stage'
    
    Todd Dembrey's avatar
    Todd Dembrey committed
            form = Form()
            stage = Stage(name, form)
    
            self.assertEqual(stage.name, name)
    
    Todd Dembrey's avatar
    Todd Dembrey committed
            self.assertEqual(stage.form, form)