piknik

Unnamed repository; edit this file 'description' to name the repository.
Info | Log | Files | Refs | README | LICENSE

test_basic.py (3158B)


      1 # standard imports
      2 import unittest
      3 import logging
      4 
      5 # external imports
      6 import shep
      7 
      8 # local imports
      9 from piknik import (
     10         Basket,
     11         Issue,
     12         )
     13 from piknik.error import DeadIssue
     14 
     15 # tests imports
     16 from tests.common import debug_out
     17 from tests.common import TestStates
     18 
     19 logging.basicConfig(level=logging.DEBUG)
     20 logg = logging.getLogger()
     21 
     22 
     23 class TestBasic(unittest.TestCase):
     24 
     25     def setUp(self):
     26         self.b = Basket(TestStates())
     27 
     28     
     29     def test_issue_basic(self):
     30         o = Issue('The first issue')
     31         v = self.b.add(o)
     32         self.assertEqual(v, str(o.id))
     33         r = self.b.get(v)
     34         self.assertEqual(r, o)
     35 
     36 
     37     def test_list(self):
     38         o = Issue('The first issue')
     39         self.b.add(o)
     40         o = Issue('The second issue')
     41         self.b.add(o)
     42         r = self.b.list('proposed')
     43         self.assertEqual(len(r), 2)
     44 
     45 
     46     def test_progres(self):
     47         o = Issue('The first issue')
     48         v = self.b.add(o)
     49         self.b.advance(v)
     50         self.b.advance(v)
     51         self.b.advance(v)
     52         self.b.advance(v)
     53         self.b.advance(v)
     54         with self.assertRaises(DeadIssue):
     55             self.b.advance(v)
     56             
     57 
     58     def test_list_jump(self):
     59         o = Issue('The first issue')
     60         v = self.b.add(o)
     61         o_two = Issue('The second issue')
     62         v_two = self.b.add(o_two)
     63         self.b.advance(v_two)
     64         o_three = Issue('The second issue')
     65         self.b.add(o_three)
     66         self.b.state_doing(v)
     67 
     68         r = self.b.list('proposed')
     69         self.assertEqual(len(r), 1)
     70 
     71         r = self.b.list('backlog')
     72         self.assertEqual(len(r), 1)
     73 
     74         r = self.b.list('doing')
     75         self.assertEqual(len(r), 1)
     76 
     77 
     78     def test_jump(self):
     79         o = Issue('The first issue')
     80         v = self.b.add(o)
     81         self.b.state_doing(v)
     82         r = self.b.list('doing')
     83         self.assertEqual(len(r), 1)
     84         self.b.state_review(v)
     85         r = self.b.list('review')
     86         self.assertEqual(len(r), 1)
     87         self.b.state_backlog(v)
     88         r = self.b.list('backlog')
     89         self.assertEqual(len(r), 1)
     90         self.b.state_finish(v)
     91         r = self.b.list('finished')
     92         self.assertEqual(len(r), 1)
     93 
     94 
     95     def test_magic_unblock(self):
     96         o = Issue('The first issue')
     97         v = self.b.add(o)
     98         self.b.advance(v)
     99         self.b.advance(v)
    100         self.b.block(v)
    101         self.assertIn(v, self.b.blocked())
    102         self.b.advance(v)
    103         self.assertNotIn(v, self.b.blocked())
    104 
    105 
    106     def test_no_resurrect(self):
    107         o = Issue('The first issue')
    108         v = self.b.add(o)
    109         self.b.state_finish(v)
    110         with self.assertRaises(DeadIssue):
    111             self.b.state_doing(v)
    112 
    113 
    114     def test_states_list(self):
    115         r = self.b.states()
    116         self.assertEqual(len(r), 7)
    117 
    118 
    119     def test_alias(self):
    120         o = Issue('The first issue', alias="first")
    121         issue_id = o.id
    122         v = self.b.add(o)
    123         o = self.b.get("first")
    124         self.assertEqual(o.id, issue_id)
    125         self.b.state_finish(issue_id)
    126         with self.assertRaises(FileNotFoundError):
    127             o = self.b.get("first")
    128 
    129 if __name__ == '__main__':
    130     unittest.main()