scripts/tests/svn_helper_test.py
author Todd Larsen <tlarsen@google.com>
Wed, 21 May 2008 16:27:35 +0000
changeset 31 8b43c541afa7
parent 30 636baa95715c
permissions -rw-r--r--
First iteration of a "prototype" Melange app, along with an initial Person Profile view. Patch by: Augie Fackler (with some additions by Todd Larsen) Review by: Todd Larsen Review issue: 46 Review URL: http://codereviews.googleopensourceprograms.com/46
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
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    21
"""
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    22
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    23
__authors__ = [
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    24
  # 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
    25
  '"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
    26
]
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    27
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
import os
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    30
import pysvn
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    31
import sys
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    32
import unittest
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    33
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    34
from .. import svn_helper
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    35
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    36
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    37
class SvnHelperTests(unittest.TestCase):
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    38
  """pysvn wrapper tests for the svn_helper.py module.
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    39
  """
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    40
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    41
  def setUp(self):
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    42
    self.client = pysvn.Client()
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    43
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    44
  def testLsFiles(self):
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    45
    """Test if lsFiles() contains only file entries, using the SoC SVN repo.
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    46
    """
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    47
    self.assert_(
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    48
        'svn_helper_test.py' in svn_helper.lsFiles(
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    49
            self.client, '%strunk/scripts/tests' % svn_helper.DEF_SVN_REPO))
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    50
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    51
    self.assert_(
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    52
        'tests/' not in svn_helper.lsFiles(
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    53
            self.client, '%strunk/scripts' % svn_helper.DEF_SVN_REPO))
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    54
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    55
  def testLsDirs(self):
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    56
    """Test if lsDirs() contains only dir entries, using the SoC SVN repo.
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    57
    """
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    58
    self.assert_(
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    59
        'tests/' in svn_helper.lsDirs(
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    60
            self.client, '%strunk/scripts' % svn_helper.DEF_SVN_REPO))
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    61
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    62
    self.assert_(
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    63
        'svn_helper_test.py' not in svn_helper.lsDirs(
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    64
            self.client, '%strunk/scripts' % svn_helper.DEF_SVN_REPO))
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    65
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    66
  def testExists(self):
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    67
    """Test if exists() works on the the SoC SVN repo.
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    68
    """
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    69
    self.assertEqual(
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    70
        True, svn_helper.exists(self.client,
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    71
                                svn_helper.DEF_SVN_REPO + 'trunk'))
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    72
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    73
    self.assertEqual(
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    74
        False, svn_helper.exists(self.client,
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    75
                                 svn_helper.DEF_SVN_REPO + 'does_not_exist'))