Beispiel #1
0
 def test_basic(self):
     """The graph should be built correctly in simple cases."""
     print graph.build_graph(self.users,
                             self.transactions)
     assert graph.build_graph(self.users,
                              self.transactions) == {3: {1: 5.0},
                                                     2: {},
                                                     1: {}}
Beispiel #2
0
def dashboard():
    graphs = {}
    for group in current_user.groups:
        # get all transactions for this group
        transactions = group.transactions
        this_graph = graph.build_graph(group.members, transactions)
        graphs[group.name] = graph.display_graph(group.members, this_graph)

    return render_template('dash.html', user=current_user,
                           groups=graphs)
Beispiel #3
0
 def test_clear_all(self):
     """Graph should ignore everything that happens before the last
     CLEAR_ALL."""
     self.transactions.extend([
         Trans(group_id=1, kind=CLEAR_ALL),
         Trans(group_id=1, to_id=2, from_id=3, amount=100, kind=DEBT)
         ])
     assert graph.build_graph(self.users,
                              self.transactions) == {3: {},
                                                     2: {3: 100.0},
                                                     1: {}}
Beispiel #4
0
 def test_error(self):
     """Should error if all transactions are not in the same group."""
     self.transactions.append(
         Trans(group_id=2, to_id=2, from_id=3, amount=100, kind=DEBT))
     graph.build_graph(self.users, self.transactions)
Beispiel #5
0
 def test_no_transactions(self):
     """Should return empty dict of users when there are no transactions."""
     graph.build_graph(self.users, []) == {1: {}, 2: {}, 3: {}}