test_dep.py (1434B)
1 # standard imports 2 import unittest 3 import logging 4 import json 5 6 # local imports 7 from piknik import Basket 8 from piknik import Issue 9 from piknik.identity import Identity 10 from piknik.error import UnknownIdentityError 11 from piknik.error import ExistsError 12 13 # tests imports 14 from tests.common import TestStates 15 16 logging.basicConfig(level=logging.DEBUG) 17 logg = logging.getLogger() 18 19 20 class TestAssign(unittest.TestCase): 21 22 def setUp(self): 23 self.alice = 'F3FAF668E82EF5124D5187BAEF26F4682343F692' 24 self.bob = 'F645E047EE5BC4E2824C94DB42DC91CFA8ABA02B' 25 26 27 def test_dep_basic(self): 28 one = Issue('foo') 29 one.dep('bar') 30 one.dep('baz') 31 with self.assertRaises(ExistsError): 32 one.dep('bar') 33 one.undep('bar') 34 self.assertEqual(len(one.dependencies), 1) 35 36 37 def test_dep_alias(self): 38 one = Issue('foo', alias='inky') 39 two = Issue('bar', alias='pinky') 40 three = Issue('baz') 41 self.b = Basket(TestStates()) 42 issue_id_one = self.b.add(one) 43 issue_id_two = self.b.add(two) 44 issue_id_three = self.b.add(three) 45 self.b.dep('inky', 'pinky') 46 self.b.dep(issue_id_three, 'inky') 47 48 with self.assertRaises(ExistsError): 49 self.b.dep(issue_id_one, 'pinky') 50 51 with self.assertRaises(ExistsError): 52 self.b.dep(issue_id_three, issue_id_one) 53 54 55 if __name__ == '__main__': 56 unittest.main()