Skip to content

Commit

Permalink
Added depth and propert tests for "add"
Browse files Browse the repository at this point in the history
  • Loading branch information
jfthuong committed Dec 29, 2020
1 parent 79d2b98 commit e6423b9
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
6 changes: 4 additions & 2 deletions svn/local.py
Expand Up @@ -29,11 +29,13 @@ def __init__(self, path_, *args, **kwargs):
def __repr__(self):
return '<SVN(LOCAL) %s>' % self.path

def add(self, rel_path, do_include_parents=False):
def add(self, rel_path, do_include_parents=False, depth=None):
args = [rel_path]

if do_include_parents is True:
if do_include_parents:
args.append('--parents')
if depth:
args += svn.common.get_depth_options(depth)

self.run_command(
'add',
Expand Down
42 changes: 42 additions & 0 deletions tests/test_local.py
@@ -1,5 +1,6 @@
import os
from shutil import rmtree
from svn.exception import SvnException
import unittest

import svn.constants
Expand Down Expand Up @@ -89,6 +90,47 @@ def test_cleanup(self):
with svn.test_support.temp_checkout() as (_, lc):
lc.cleanup()

def test_add(self):
with svn.test_support.temp_repo():
with svn.test_support.temp_checkout() as (_, lc):
dir1 = "d1"
dir12 = os.path.join(dir1, "d2")
dir123 = os.path.join(dir12, "d3")
dir124 = os.path.join(dir12, "d4")
for dir_ in [dir1, dir12, dir123, dir124]:
if os.path.isdir(dir_):
rmtree(dir_)
os.mkdir(dir_)

added = "added"
f12 = os.path.join(dir12, "f12")
f123_1 = os.path.join(dir123, "f123.1")
f123_2 = os.path.join(dir123, "f123.2")
f124 = os.path.join(dir124, "f124")
for file in [added, f12, f123_1, f123_2, f124]:
with open(file, 'w') as f:
pass

lc.add(dir1, depth="empty")
self.assertRaises(SvnException, lc.info, dir12)
lc.run_command("revert", [dir1])

lc.add(added)
info = lc.info(added)
self.assertEqual(info["wcinfo_schedule"], "add")

lc.add(f124, do_include_parents=True)
for path in [f124, dir124]:
info = lc.info(path)
self.assertEqual(info["wcinfo_schedule"], "add")

lc.add(dir123, depth="infinity")
for path in [f123_1, f123_2]:
info = lc.info(path)
self.assertEqual(info["wcinfo_schedule"], "add")



def test_commit(self):
with svn.test_support.temp_repo():
with svn.test_support.temp_checkout() as (_, lc):
Expand Down

0 comments on commit e6423b9

Please sign in to comment.