tests/svn_helper_test.py
author Pawel Solyga <Pawel.Solyga@gmail.com>
Sat, 13 Sep 2008 22:53:07 +0000
changeset 142 d88c7dbea0e8
parent 63 9b1909e46633
child 180 a1c6123f9d06
permissions -rw-r--r--
Forgot to change widgets to custom_widgets import in home.py after changing the name of soc/views/helpers/widgets.py file.
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
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    32
import pysvn
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    33
import sys
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    34
import unittest
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    35
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
    36
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
    37
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    38
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    39
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
    40
  """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
    41
  """
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    42
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    43
  def setUp(self):
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    44
    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
    45
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    46
  def testLsFiles(self):
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    47
    """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
    48
    """
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    49
    self.assert_(
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    50
        'svn_helper_test.py' in svn_helper.lsFiles(
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
    51
            '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
    52
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    53
    self.assert_(
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    54
        'tests/' not in svn_helper.lsFiles(
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
    55
            '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
    56
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    57
  def testLsDirs(self):
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    58
    """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
    59
    """
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    60
    self.assert_(
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    61
        'tests/' in svn_helper.lsDirs(
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
    62
            '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
    63
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    64
    self.assert_(
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    65
        'svn_helper_test.py' not in svn_helper.lsDirs(
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
    66
            '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
    67
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    68
  def testExists(self):
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    69
    """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
    70
    """
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    71
    self.assertEqual(
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
    72
        True, svn_helper.exists(
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
    73
            '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
    74
636baa95715c Helper module used by utility and tool scripts to access svn repositories.
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    75
    self.assertEqual(
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
    76
        False, svn_helper.exists(
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
    77
            'http://soc.googlecode.com/svn/does_not_exist', client=self.client))