Example #1
0
    def test_contains_int(self):
        b = Bureau(User)
        agent = User(15)
        b.add(agent)

        assert 15 in b
        assert 16 not in b
Example #2
0
    def test_del_agent(self):
        b = Bureau(User)
        agent = User(0)
        b.add(agent)
        b.remove(0)

        assert agent not in b
        assert 0 not in b._agents
Example #3
0
    def test_add_agent(self):
        b = Bureau(User)
        agent = User(0)
        b.add(agent)

        assert agent in b
        assert 0 in b._agents
        assert b.get(0) == agent
Example #4
0
    def test_export_contents(self):
        b = Bureau(User)
        for i in range(10):
            b.add(User(i))

        export = b.export()
        pprint(export)

        assert b.export()[0] == User(0).export()
        assert b.export()[5] == User(5).export()
Example #5
0
    def test_bureau_stats(self):
        b = Bureau(User)
        b.add(User(0))
        b.add(User(1))
        b.add(User(2))

        for u in b:
            u.ledger.recalculate()

        s = b.stats()
        assert 0 in s.stats
        assert 1 in s.stats
        assert len(s.stats) == 2
Example #6
0
 def test_contains_true(self):
     b = Bureau(User)
     agent = User(15)
     b.add(agent)
     assert agent in b
Example #7
0
    def test_has_true(self):
        b = Bureau(User)
        agent = User(0)
        b.add(agent)

        assert agent in b
Example #8
0
    def test_get_agent(self):
        b = Bureau(User)
        agent = User(0)
        b.add(agent)

        assert b.get(0) == agent
Example #9
0
 def test_add_agent_twice_new(self):
     b = Bureau(User)
     agent = User(0)
     b.add(agent)
     b.add(agent, override=True)
Example #10
0
 def test_add_agent_twice_nonew(self):
     b = Bureau(User)
     agent = User(0)
     b.add(agent)
     with pytest.raises(KeyError):
         b.add(agent, override=False)
Example #11
0
 def test_add_agent_typecheck(self):
     b = Bureau(User)
     agent = Subject(0)
     with pytest.raises(TypeError):
         b.add(agent)
Example #12
0
    def get_bureau(self):
        b = Bureau(Subject)
        for i in range(5):
            b.add(Subject(i))

        return b
Example #13
0
 def test_stats_users(self):
     b = Bureau(User)
     [b.add(User(i)) for i in range(5)]
     [u.ledger.recalculate() for u in b]
     b.stats()
Example #14
0
 def test_stats_subject(self):
     b = Bureau(Subject)
     [b.add(Subject(i)) for i in range(5)]
     [s.ledger.recalculate() for s in b]
     b.stats()
Example #15
0
 def test_idset(self):
     b = Bureau(User)
     [b.add(User(i)) for i in range(5)]
     assert b.idset() == set(range(5))