tests/svn_helper_test.py
author Lennard de Rijk <ljvderijk@gmail.com>
Fri, 23 Jan 2009 12:00:48 +0000
changeset 920 39badbfb80be
parent 180 a1c6123f9d06
permissions -rw-r--r--
Added the new way to process invites for club_admin only. This patch contains the separability needed to ensure that we can successfully do the access checks we need. Host invites can for the time being only be completed by developers due to the reorganization. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     2
#
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     3
# Copyright 2008 the Melange authors.
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     4
#
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     8
#
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    10
#
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    15
# limitations under the License.
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    16
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    17
"""Tests for the scripts.svn_helper module.
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    18
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    19
For details on running the tests, see:
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    20
  http://code.google.com/p/soc/wiki/TestingGuidelines#Running_the_smoke_tests
63
9b1909e46633 Move tests/ to top level of trunk/. Fix tests to run from new location. Add
Todd Larsen <tlarsen@google.com>
parents: 30
diff changeset
    21
9b1909e46633 Move tests/ to top level of trunk/. Fix tests to run from new location. Add
Todd Larsen <tlarsen@google.com>
parents: 30
diff changeset
    22
This test (and the svn_helper module that it tests) requires the pysvn module.
30
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    23
"""
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    24
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    25
__authors__ = [
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    26
  # alphabetical order by last name, please
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    27
  '"Todd Larsen" <tlarsen@google.com>',
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    28
]
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    29
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    30
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    31
import os
180
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    32
try:
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    33
  import pysvn
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    34
except:
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    35
  pysvn = None
30
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    36
import sys
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    37
import unittest
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    38
180
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    39
if pysvn is not None:
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    40
  from ..scripts import svn_helper
30
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    41
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    42
180
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    43
  class SvnHelperTests(unittest.TestCase):
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    44
    """pysvn wrapper tests for the svn_helper.py module.
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    45
    """
30
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    46
180
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    47
    def setUp(self):
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    48
      self.client = pysvn.Client()
30
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    49
180
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    50
    def testLsFiles(self):
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    51
      """Test if lsFiles() contains only file entries, using the SoC SVN repo.
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    52
      """
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    53
      self.assert_(
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    54
          'svn_helper_test.py' in svn_helper.lsFiles(
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    55
              'http://soc.googlecode.com/svn/trunk/tests', client=self.client))
30
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    56
180
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    57
      self.assert_(
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    58
          'tests/' not in svn_helper.lsFiles(
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    59
              'http://soc.googlecode.com/svn/trunk', client=self.client))
30
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    60
180
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    61
    def testLsDirs(self):
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    62
      """Test if lsDirs() contains only dir entries, using the SoC SVN repo.
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    63
      """
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    64
      self.assert_(
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    65
          'tests/' in svn_helper.lsDirs(
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    66
              'http://soc.googlecode.com/svn/trunk', client=self.client))
30
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    67
180
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    68
      self.assert_(
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    69
          'svn_helper_test.py' not in svn_helper.lsDirs(
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    70
              'http://soc.googlecode.com/svn/trunk/tests', client=self.client))
30
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    71
180
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    72
    def testExists(self):
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    73
      """Test if exists() works on the the SoC SVN repo.
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    74
      """
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    75
      self.assertEqual(
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    76
          True, svn_helper.exists(
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    77
              'http://soc.googlecode.com/svn/trunk', client=self.client))
30
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    78
180
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    79
      self.assertEqual(
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    80
          False, svn_helper.exists(
a1c6123f9d06 Two changes to ease CI:
Augie Fackler <durin42@gmail.com>
parents: 63
diff changeset
    81
              'http://soc.googlecode.com/svn/does_not_exist', client=self.client))