~ubuntu-branches/ubuntu/utopic/calendarserver/utopic

« back to all changes in this revision

Viewing changes to calendarserver/tap/test/test_util.py

  • Committer: Package Import Robot
  • Author(s): Rahul Amaram
  • Date: 2012-05-29 18:12:12 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20120529181212-mxjdfncopy6vou0f
Tags: 3.2+dfsg-1
* New upstream release
* Moved from using cdbs to dh sequencer
* Modified calenderserver init.d script based on /etc/init.d/skeleton script
* Removed ldapdirectory.patch as the OpenLDAP directory service has been 
  merged upstream
* Moved package to section "net" as calendarserver is more service than 
  library (Closes: #665859)
* Changed Architecture of calendarserver package to any as the package
  now includes compiled architecture dependent Python extensions
* Unowned files are no longer left on the system upon purging
  (Closes: #668731)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
##
 
2
# Copyright (c) 2007-2010 Apple Inc. All rights reserved.
 
3
#
 
4
# Licensed under the Apache License, Version 2.0 (the "License");
 
5
# you may not use this file except in compliance with the License.
 
6
# You may obtain a copy of the License at
 
7
#
 
8
# http://www.apache.org/licenses/LICENSE-2.0
 
9
#
 
10
# Unless required by applicable law or agreed to in writing, software
 
11
# distributed under the License is distributed on an "AS IS" BASIS,
 
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
# See the License for the specific language governing permissions and
 
14
# limitations under the License.
 
15
##
 
16
 
 
17
from calendarserver.tap.util import computeProcessCount, directoryFromConfig
 
18
from twistedcaldav.test.util import TestCase
 
19
from twistedcaldav.config import config
 
20
from twistedcaldav.directory.augment import AugmentXMLDB
 
21
 
 
22
class ProcessCountTestCase(TestCase):
 
23
 
 
24
    def test_count(self):
 
25
 
 
26
        data = (
 
27
            # minimum, perCPU, perGB, cpu, memory (in GB), expected:
 
28
            (0, 1, 1, 0, 0, 0),
 
29
            (1, 2, 2, 0, 0, 1),
 
30
            (1, 2, 1, 1, 1, 1),
 
31
            (1, 2, 2, 1, 1, 2),
 
32
            (1, 2, 2, 2, 1, 2),
 
33
            (1, 2, 2, 1, 2, 2),
 
34
            (1, 2, 2, 2, 2, 4),
 
35
            (4, 1, 2, 8, 2, 4),
 
36
            (6, 2, 2, 2, 2, 6),
 
37
            (1, 2, 1, 4, 99, 8),
 
38
 
 
39
            (2, 1, 2, 2, 2, 2), # 2 cores, 2GB = 2
 
40
            (2, 1, 2, 2, 4, 2), # 2 cores, 4GB = 2
 
41
            (2, 1, 2, 8, 6, 8), # 8 cores, 6GB = 8
 
42
            (2, 1, 2, 8, 16, 8), # 8 cores, 16GB = 8
 
43
        )
 
44
 
 
45
        for min, perCPU, perGB, cpu, mem, expected in data:
 
46
            mem *= (1024 * 1024 * 1024)
 
47
 
 
48
            self.assertEquals(
 
49
                expected,
 
50
                computeProcessCount(min, perCPU, perGB, cpuCount=cpu, memSize=mem)
 
51
            )
 
52
 
 
53
class UtilTestCase(TestCase):
 
54
 
 
55
    def test_directoryFromConfig(self):
 
56
        """
 
57
        Ensure augments service is on by default
 
58
        """
 
59
        dir = directoryFromConfig(config)
 
60
        for service in dir._recordTypes.values():
 
61
            # all directory services belonging to the aggregate have
 
62
            # augmentService set to AugmentXMLDB
 
63
            if hasattr(service, "augmentService"):
 
64
                self.assertTrue(isinstance(service.augmentService, AugmentXMLDB))