Пример #1
0
    def test_diskquota(self):
        basic = Plan(diskquota=100 * handy.MEGA)

        u = User(plan=basic)
        assert u.diskquota == 100 * handy.MEGA

        u.diskextra = 50 * handy.MEGA
        assert u.diskquota == 150 * handy.MEGA
Пример #2
0
    def test_diskquota(self):
        basic = Plan(diskquota = 100 * handy.MEGA)
        
        u = User(plan=basic)
        assert u.diskquota == 100 * handy.MEGA

        u.diskextra = 50 * handy.MEGA
        assert u.diskquota == 150 * handy.MEGA
Пример #3
0
def makePerson(username, domain):
    user = User(username="******",
                plan=Plan(name="script"),
                diskusing=3000000,
                server=Server(name="mockium"))
    dom = user.domains << Domain(domain=domain)
    dom.site = user.sites << Site(domain=dom)
    dom.rules << EmailRule(virtuser='******', mailto=EmailRule.BOUNCE)
    dom.rules << EmailRule(virtuser=username, mailto="~")
    return user
Пример #4
0
    def test_UpdateUserCommand(self):
        fred = self.clerk.store(User(username="******"))
        script = self.clerk.store(Plan(name="script"))

        cmd = admin.UpdateUserCommand()
        req = {
            'status': 'locked',
            'plan': 'script',
            'diskextra': '10',
            'bandextra': '20',
            'boxextra': '0',
            'dbextra': '0',
            '_clerk': self.clerk,
            '_sess': self.sess,
        }
        self.assertRaises(Redirect, cmd.invoke, **req)
        assert fred.status == req['status']
        assert fred.plan.name == req['plan']
        assert fred.diskextra == int(req['diskextra'])
        assert fred.bandextra == int(req['bandextra'])
Пример #5
0
    def test_JumpCommand(self):

        wanda = User(username="******")
        wanda.domains << Domain(domain="wtempy.com")
        self.clerk.store(wanda)

        invoke = lambda jumpto: (cmd.invoke(
            _sess=self.sess, _clerk=self.clerk, jumpto=jumpto))

        # searching for wanda should succeed:
        cmd = admin.JumpCommand()
        self.assertRaises(Redirect, invoke, jumpto="wanda")
        assert self.sess["username"] == "wanda"

        # but since there's no one else, another search should fail:
        self.assertRaises(AssertionError, invoke, jumpto="invalid")

        # you should also be able to look her up by domain:
        del self.sess["username"]
        self.assertRaises(Redirect, invoke, jumpto="wtempy.com")
        assert self.sess["username"] == "wanda"
Пример #6
0
    def test_IsPasswdCommand(self):

        u = self.clerk.store(User(username="******"))

        class MockBeaker:
            def ispasswd(self, username, password):
                return True

        class MockUser(User):
            def ispasswd(self, pwd):
                return pwd == "good"

        def mockLoadUser(u, c):
            return MockUser()

        cmd = admin.IsPasswdCommand()
        cmd.loadUser = mockLoadUser

        model = cmd.invoke(self.clerk, u, password="******")
        assert model["message"] == "yes"
        model = cmd.invoke(self.clerk, u, password="******")
        assert model["message"] == "no"
Пример #7
0
 def test_account(self):
     u = User()
     u.account = Account()
Пример #8
0
 def test_remote(self):
     s = Server(name="mockium")
     assert User(server=s).getMySQL()
     assert User(server=s).getBeaker()
Пример #9
0
 def test_dbquota(self):
     script = Plan(dbquota=2)
     self.assertEquals(User(plan=script).dbquota, 2)
     self.assertEquals(User(plan=script, dbextra=2).dbquota, 4)
Пример #10
0
 def test_bandquota(self):
     basic = Plan(boxquota=2)
     self.assertEquals(User(plan=basic).boxquota, 2)
     self.assertEquals(User(plan=basic, boxextra=2).boxquota, 4)
Пример #11
0
 def test_bandrule(self):
     u = User()
     u.bandrule = "charge"
     u.bandrule = "disable"
     self.assertRaises(ValueError, u.__setattr__, *("bandrule", "garbage"))
Пример #12
0
    def test_bandquota(self):
        basic = Plan(bandquota=2 * handy.GIGA)
        self.assertEquals(User(plan=basic).bandquota, 2 * handy.GIGA)

        shell = Plan(bandquota=5 * handy.GIGA)
        self.assertEquals(User(plan=shell).bandquota, 5 * handy.GIGA)
Пример #13
0
 def test_account(self):
     u = User()
     u.account = Account()
Пример #14
0
 def test_bandrule(self):
     u = User()
     u.bandrule = "charge"
     u.bandrule = "disable"
     self.assertRaises(ValueError, u.__setattr__, *("bandrule", "garbage"))