from debtgraph import DebtGraph
from nose.tools import raises

class TestInit():
    """Initialization should occur properly."""
    def test_string_init(self):
        """Should correctly initialize a graph from a list of names."""
        dg = DebtGraph(["a","b","c"])
        assert dg.graph == {"a": {},"b": {},"c": {}}

    def test_dict_init(self):
        """Should correctly initialize a graph from a dictionary."""
        dg = DebtGraph({"a":{"b":20},"b":{}})
        assert dg.graph == {"a":{"b":20},"b":{}}

class TestRemove():
    """Graph manipulation methods should work properly."""
    @classmethod
    def setUp(self):
        """Set up a test DebtGraph."""
        self.dg = DebtGraph(
            {"alice": {"bob": 20, "charlie":5},
             "bob": {"alice":10},
             "charlie": {}})

    def test_remove_normal(self):
        """Should remove debt correctly."""
        self.dg.remove("alice","bob",5)
        assert self.dg.graph == {"alice": {"bob": 15, "charlie":5},
                                 "bob": {"alice":10},
                                 "charlie": {}}

    def test_remove_deletion(self):
        """Should delete the node if more debt is removed than exists."""
        self.dg.remove("alice","bob",25)
        assert self.dg.graph == {"alice": {"charlie":5},
                                 "bob": {"alice":10},
                                 "charlie": {}}

    @raises(KeyError)
    def test_remove_error(self):
        """Should throw an error when trying to remove a nonexistant debt."""
        self.dg.remove("charlie","bob",4)


class TestForgive

@@ -527,14 +527,20 @@
 Test
-Remove
+Manipulation
 ():%0A
@@ -816,16 +816,30 @@
 : %7B%7D%7D)%0A%0A
+    #removal%0A%0A
     def 
@@ -1610,23 +1610,429 @@
 4)%0A%0A
-%0Aclass TestF
+    #forgiveness%0A%0A    def test_forgive_normal(self):%0A        %22%22%22Test that the forgive method works properly.%22%22%22%0A        self.dg.forgive(%22bob%22,%22alice%22)%0A        assert self.dg.graph == %7B%22alice%22: %7B%22bob%22: 20, %22charlie%22:5%7D,%0A                                 %22bob%22: %7B%7D,%0A                                 %22charlie%22: %7B%7D%7D%0A%0A    @raises(KeyError)%0A    def test_f
 orgive
+_error(self):%0A        self.dg.forgive(%22bob%22,%22charlie%22)%0A%0A    # addition
 %0A

Add tests for forgiveness.