aboutsummaryrefslogtreecommitdiffstats
path: root/lib/python2.7/site-packages/buildbot-0.8.8-py2.7.egg/buildbot/test/unit/test_changes_svnpoller.py
blob: be288d8daa8e6c609ebca957f6379fccadd29571 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
# This file is part of Buildbot.  Buildbot is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members

from __future__ import with_statement

import os
import xml.dom.minidom
from twisted.internet import defer
from twisted.trial import unittest
from buildbot.test.util import changesource, gpo, compat
from buildbot.changes import svnpoller

# this is the output of "svn info --xml
# svn+ssh://svn.twistedmatrix.com/svn/Twisted/trunk"
prefix_output = """\
<?xml version="1.0"?>
<info>
<entry
   kind="dir"
   path="trunk"
   revision="18354">
<url>svn+ssh://svn.twistedmatrix.com/svn/Twisted/trunk</url>
<repository>
<root>svn+ssh://svn.twistedmatrix.com/svn/Twisted</root>
<uuid>bbbe8e31-12d6-0310-92fd-ac37d47ddeeb</uuid>
</repository>
<commit
   revision="18352">
<author>jml</author>
<date>2006-10-01T02:37:34.063255Z</date>
</commit>
</entry>
</info>
"""

# and this is "svn info --xml svn://svn.twistedmatrix.com/svn/Twisted". I
# think this is kind of a degenerate case.. it might even be a form of error.
prefix_output_2 = """\
<?xml version="1.0"?>
<info>
</info>
"""

# this is the svn info output for a local repository, svn info --xml
# file:///home/warner/stuff/Projects/BuildBot/trees/svnpoller/_trial_temp/test_vc/repositories/SVN-Repository
prefix_output_3 = """\
<?xml version="1.0"?>
<info>
<entry
   kind="dir"
   path="SVN-Repository"
   revision="3">
<url>file:///home/warner/stuff/Projects/BuildBot/trees/svnpoller/_trial_temp/test_vc/repositories/SVN-Repository</url>
<repository>
<root>file:///home/warner/stuff/Projects/BuildBot/trees/svnpoller/_trial_temp/test_vc/repositories/SVN-Repository</root>
<uuid>c0f47ff4-ba1e-0410-96b5-d44cc5c79e7f</uuid>
</repository>
<commit
   revision="3">
<author>warner</author>
<date>2006-10-01T07:37:04.182499Z</date>
</commit>
</entry>
</info>
"""

# % svn info --xml file:///home/warner/stuff/Projects/BuildBot/trees/svnpoller/_trial_temp/test_vc/repositories/SVN-Repository/sample/trunk

prefix_output_4 = """\
<?xml version="1.0"?>
<info>
<entry
   kind="dir"
   path="trunk"
   revision="3">
<url>file:///home/warner/stuff/Projects/BuildBot/trees/svnpoller/_trial_temp/test_vc/repositories/SVN-Repository/sample/trunk</url>
<repository>
<root>file:///home/warner/stuff/Projects/BuildBot/trees/svnpoller/_trial_temp/test_vc/repositories/SVN-Repository</root>
<uuid>c0f47ff4-ba1e-0410-96b5-d44cc5c79e7f</uuid>
</repository>
<commit
   revision="1">
<author>warner</author>
<date>2006-10-01T07:37:02.286440Z</date>
</commit>
</entry>
</info>
"""



# output from svn log on .../SVN-Repository/sample
# (so it includes trunk and branches)
sample_base = ("file:///usr/home/warner/stuff/Projects/BuildBot/trees/misc/" +
               "_trial_temp/test_vc/repositories/SVN-Repository/sample")
sample_logentries = [None] * 6

sample_logentries[5] = """\
<logentry
   revision="6">
<author>warner</author>
<date>2006-10-01T19:35:16.165664Z</date>
<paths>
<path
   action="D">/sample/branch/version.c</path>
</paths>
<msg>revised_to_2</msg>
</logentry>
"""

sample_logentries[4] = """\
<logentry
   revision="5">
<author>warner</author>
<date>2006-10-01T19:35:16.165664Z</date>
<paths>
<path
   action="D">/sample/branch</path>
</paths>
<msg>revised_to_2</msg>
</logentry>
"""

sample_logentries[3] = """\
<logentry
   revision="4">
<author>warner</author>
<date>2006-10-01T19:35:16.165664Z</date>
<paths>
<path
   action="M">/sample/trunk/version.c</path>
</paths>
<msg>revised_to_2</msg>
</logentry>
"""

sample_logentries[2] = """\
<logentry
   revision="3">
<author>warner</author>
<date>2006-10-01T19:35:10.215692Z</date>
<paths>
<path
   action="M">/sample/branch/main.c</path>
</paths>
<msg>commit_on_branch</msg>
</logentry>
"""

sample_logentries[1] = """\
<logentry
   revision="2">
<author>warner</author>
<date>2006-10-01T19:35:09.154973Z</date>
<paths>
<path
   copyfrom-path="/sample/trunk"
   copyfrom-rev="1"
   action="A">/sample/branch</path>
</paths>
<msg>make_branch</msg>
</logentry>
"""

sample_logentries[0] = """\
<logentry
   revision="1">
<author>warner</author>
<date>2006-10-01T19:35:08.642045Z</date>
<paths>
<path
   action="A">/sample</path>
<path
   action="A">/sample/trunk</path>
<path
   action="A">/sample/trunk/subdir/subdir.c</path>
<path
   action="A">/sample/trunk/main.c</path>
<path
   action="A">/sample/trunk/version.c</path>
<path
   action="A">/sample/trunk/subdir</path>
</paths>
<msg>sample_project_files</msg>
</logentry>
"""

sample_info_output = """\
<?xml version="1.0"?>
<info>
<entry
   kind="dir"
   path="sample"
   revision="4">
<url>file:///usr/home/warner/stuff/Projects/BuildBot/trees/misc/_trial_temp/test_vc/repositories/SVN-Repository/sample</url>
<repository>
<root>file:///usr/home/warner/stuff/Projects/BuildBot/trees/misc/_trial_temp/test_vc/repositories/SVN-Repository</root>
<uuid>4f94adfc-c41e-0410-92d5-fbf86b7c7689</uuid>
</repository>
<commit
   revision="4">
<author>warner</author>
<date>2006-10-01T19:35:16.165664Z</date>
</commit>
</entry>
</info>
"""


changes_output_template = """\
<?xml version="1.0"?>
<log>
%s</log>
"""

def make_changes_output(maxrevision):
    # return what 'svn log' would have just after the given revision was
    # committed
    logs = sample_logentries[0:maxrevision]
    assert len(logs) == maxrevision
    logs.reverse()
    output = changes_output_template % ("".join(logs))
    return output

def make_logentry_elements(maxrevision):
    "return the corresponding logentry elements for the given revisions"
    doc = xml.dom.minidom.parseString(make_changes_output(maxrevision))
    return doc.getElementsByTagName("logentry")

def split_file(path):
    pieces = path.split("/")
    if pieces[0] == "branch":
        return dict(branch="branch", path="/".join(pieces[1:]))
    if pieces[0] == "trunk":
        return dict(path="/".join(pieces[1:]))
    raise RuntimeError("there shouldn't be any files like %r" % path)


class TestSVNPoller(gpo.GetProcessOutputMixin,
                    changesource.ChangeSourceMixin,
                    unittest.TestCase):

    def setUp(self):
        self.setUpGetProcessOutput()
        return self.setUpChangeSource()

    def tearDown(self):
        return self.tearDownChangeSource()

    def attachSVNPoller(self, *args, **kwargs):
        s = svnpoller.SVNPoller(*args, **kwargs)
        self.attachChangeSource(s)
        return s

    def add_svn_command_result(self, command, result):
        self.expectCommands(
                gpo.Expect('svn', command).stdout(result))


    # tests

    def test_describe(self):
        s = self.attachSVNPoller('file://')
        self.assertSubstring("SVNPoller", s.describe())

    def test_strip_svnurl(self):
        base = "svn+ssh://svn.twistedmatrix.com/svn/Twisted/trunk"
        s = self.attachSVNPoller(base + "/")
        self.failUnlessEqual(s.svnurl, base)

    def do_test_get_prefix(self, base, output, expected):
        s = self.attachSVNPoller(base)
        self.expectCommands(gpo.Expect('svn', 'info', '--xml', '--non-interactive', base).stdout(output))
        d = s.get_prefix()
        def check(prefix):
            self.failUnlessEqual(prefix, expected)
            self.assertAllCommandsRan()
        d.addCallback(check)
        return d

    def test_get_prefix_1(self):
        base = "svn+ssh://svn.twistedmatrix.com/svn/Twisted/trunk"
        return self.do_test_get_prefix(base, prefix_output, 'trunk')

    def test_get_prefix_2(self):
        base = "svn+ssh://svn.twistedmatrix.com/svn/Twisted"
        return self.do_test_get_prefix(base, prefix_output_2, '')

    def test_get_prefix_3(self):
        base = ("file:///home/warner/stuff/Projects/BuildBot/trees/" +
                "svnpoller/_trial_temp/test_vc/repositories/SVN-Repository")
        return self.do_test_get_prefix(base, prefix_output_3, '')

    def test_get_prefix_4(self):
        base = ("file:///home/warner/stuff/Projects/BuildBot/trees/" +
                "svnpoller/_trial_temp/test_vc/repositories/SVN-Repository/sample/trunk")
        return self.do_test_get_prefix(base, prefix_output_3, 'sample/trunk')

    def test_log_parsing(self):
        s = self.attachSVNPoller('file:///foo')
        output = make_changes_output(4)
        entries = s.parse_logs(output)
        # no need for elaborate assertions here; this is minidom's logic
        self.assertEqual(len(entries), 4)

    def test_get_new_logentries(self):
        s = self.attachSVNPoller('file:///foo')
        entries = make_logentry_elements(4)

        s.last_change = 4
        new = s.get_new_logentries(entries)
        self.assertEqual(s.last_change, 4)
        self.assertEqual(len(new), 0)

        s.last_change = 3
        new = s.get_new_logentries(entries)
        self.assertEqual(s.last_change, 4)
        self.assertEqual(len(new), 1)

        s.last_change = 1
        new = s.get_new_logentries(entries)
        self.assertEqual(s.last_change, 4)
        self.assertEqual(len(new), 3)

        # special case: if last_change is None, then no new changes are queued
        s.last_change = None
        new = s.get_new_logentries(entries)
        self.assertEqual(s.last_change, 4)
        self.assertEqual(len(new), 0)

    def test_create_changes(self):
        base = ("file:///home/warner/stuff/Projects/BuildBot/trees/" +
                "svnpoller/_trial_temp/test_vc/repositories/SVN-Repository/sample")
        s = self.attachSVNPoller(base, split_file=split_file)
        s._prefix = "sample"

        logentries = dict(zip(xrange(1, 7), reversed(make_logentry_elements(6))))
        changes = s.create_changes(reversed([ logentries[3], logentries[2] ]))
        self.failUnlessEqual(len(changes), 2)
        # note that parsing occurs in reverse
        self.failUnlessEqual(changes[0]['branch'], "branch")
        self.failUnlessEqual(changes[0]['revision'], '2')
        self.failUnlessEqual(changes[0]['project'], '')
        self.failUnlessEqual(changes[0]['repository'], base)
        self.failUnlessEqual(changes[1]['branch'], "branch")
        self.failUnlessEqual(changes[1]['files'], ["main.c"])
        self.failUnlessEqual(changes[1]['revision'], '3')
        self.failUnlessEqual(changes[1]['project'], '')
        self.failUnlessEqual(changes[1]['repository'], base)

        changes = s.create_changes([ logentries[4] ])
        self.failUnlessEqual(len(changes), 1)
        self.failUnlessEqual(changes[0]['branch'], None)
        self.failUnlessEqual(changes[0]['revision'], '4')
        self.failUnlessEqual(changes[0]['files'], ["version.c"])

        # r5 should *not* create a change as it's a branch deletion
        changes = s.create_changes([ logentries[5] ])
        self.failUnlessEqual(len(changes), 0)

        # r6 should create a change as it's not deleting an entire branch
        changes = s.create_changes([ logentries[6] ])
        self.failUnlessEqual(len(changes), 1)
        self.failUnlessEqual(changes[0]['branch'], 'branch')
        self.failUnlessEqual(changes[0]['revision'], '6')
        self.failUnlessEqual(changes[0]['files'], ["version.c"])

    def makeInfoExpect(self):
        return  gpo.Expect('svn', 'info', '--xml', '--non-interactive', sample_base,
                '--username=dustin', '--password=bbrocks')

    def makeLogExpect(self):
        return gpo.Expect('svn', 'log', '--xml', '--verbose', '--non-interactive',
                '--username=dustin', '--password=bbrocks',
                '--limit=100', sample_base)
    def test_create_changes_overriden_project(self):
        def custom_split_file(path):
            f = split_file(path)
            if f:
                f["project"] = "overriden-project"
                f["repository"] = "overriden-repository"
                f["codebase"] = "overriden-codebase"
            return f

        base = ("file:///home/warner/stuff/Projects/BuildBot/trees/" +
                "svnpoller/_trial_temp/test_vc/repositories/SVN-Repository/sample")
        s = self.attachSVNPoller(base, split_file=custom_split_file)
        s._prefix = "sample"

        logentries = dict(zip(xrange(1, 7), reversed(make_logentry_elements(6))))
        changes = s.create_changes(reversed([ logentries[3], logentries[2] ]))
        self.failUnlessEqual(len(changes), 2)

        # note that parsing occurs in reverse
        self.failUnlessEqual(changes[0]['branch'], "branch")
        self.failUnlessEqual(changes[0]['revision'], '2')
        self.failUnlessEqual(changes[0]['project'], "overriden-project")
        self.failUnlessEqual(changes[0]['repository'], "overriden-repository")
        self.failUnlessEqual(changes[0]['codebase'], "overriden-codebase")

        self.failUnlessEqual(changes[1]['branch'], "branch")
        self.failUnlessEqual(changes[1]['files'], ["main.c"])
        self.failUnlessEqual(changes[1]['revision'], '3')
        self.failUnlessEqual(changes[1]['project'], "overriden-project")
        self.failUnlessEqual(changes[1]['repository'], "overriden-repository")
        self.failUnlessEqual(changes[1]['codebase'], "overriden-codebase")

    def test_poll(self):
        s = self.attachSVNPoller(sample_base, split_file=split_file,
                svnuser='dustin', svnpasswd='bbrocks')

        d = defer.succeed(None)


        self.expectCommands(
                self.makeInfoExpect().stdout(sample_info_output),
                self.makeLogExpect().stdout(make_changes_output(1)),
                self.makeLogExpect().stdout(make_changes_output(1)),
                self.makeLogExpect().stdout(make_changes_output(2)),
                self.makeLogExpect().stdout(make_changes_output(4)),
                )
        # fire it the first time; it should do nothing
        d.addCallback(lambda _ : s.poll())
        def check_first(_):
            # no changes generated on the first iteration
            self.assertEqual(self.changes_added, [])
            self.failUnlessEqual(s.last_change, 1)
        d.addCallback(check_first)

        # now fire it again, nothing changing
        d.addCallback(lambda _ : s.poll())
        def check_second(_):
            self.assertEqual(self.changes_added, [])
            self.failUnlessEqual(s.last_change, 1)
        d.addCallback(check_second)

        # and again, with r2 this time
        d.addCallback(lambda _ : s.poll())
        def check_third(_):
            self.assertEqual(len(self.changes_added), 1)
            c = self.changes_added[0]
            self.failUnlessEqual(c['branch'], "branch")
            self.failUnlessEqual(c['revision'], '2')
            self.failUnlessEqual(c['files'], ['']) # signals a new branch
            self.failUnlessEqual(c['comments'], "make_branch")
            self.failUnlessEqual(c['src'], "svn")
            self.failUnlessEqual(s.last_change, 2)
        d.addCallback(check_third)

        # and again with both r3 and r4 appearing together
        def setup_fourth(_):
            self.changes_added = []
        d.addCallback(setup_fourth)
        d.addCallback(lambda _ : s.poll())
        def check_fourth(_):
            self.assertEqual(len(self.changes_added), 2)
            c = self.changes_added[0]
            self.failUnlessEqual(c['branch'], "branch")
            self.failUnlessEqual(c['revision'], '3')
            self.failUnlessEqual(c['files'], ["main.c"])
            self.failUnlessEqual(c['comments'], "commit_on_branch")
            self.failUnlessEqual(c['src'], "svn")
            c = self.changes_added[1]
            self.failUnlessEqual(c['branch'], None)
            self.failUnlessEqual(c['revision'], '4')
            self.failUnlessEqual(c['files'], ["version.c"])
            self.failUnlessEqual(c['comments'], "revised_to_2")
            self.failUnlessEqual(c['src'], "svn")
            self.failUnlessEqual(s.last_change, 4)
            self.assertAllCommandsRan()
        d.addCallback(check_fourth)

        return d

    @compat.usesFlushLoggedErrors
    def test_poll_get_prefix_exception(self):
        s = self.attachSVNPoller(sample_base, split_file=split_file,
                svnuser='dustin', svnpasswd='bbrocks')

        self.expectCommands(
                self.makeInfoExpect().stderr("error"))
        d = s.poll()
        @d.addCallback
        def check(_):
            # should have logged the RuntimeError, but not errback'd from poll
            self.assertEqual(len(self.flushLoggedErrors(IOError)), 1)
            self.assertAllCommandsRan()
        return d

    @compat.usesFlushLoggedErrors
    def test_poll_get_logs_exception(self):
        s = self.attachSVNPoller(sample_base, split_file=split_file,
                svnuser='dustin', svnpasswd='bbrocks')
        s._prefix = "abc" # skip the get_prefix stuff

        self.expectCommands(
                self.makeLogExpect().stderr("some error"))
        d = s.poll()
        @d.addCallback
        def check(_):
            # should have logged the RuntimeError, but not errback'd from poll
            self.assertEqual(len(self.flushLoggedErrors(IOError)), 1)
            self.assertAllCommandsRan()
        return d

    def test_cachepath_empty(self):
        cachepath = os.path.abspath('revcache')
        if os.path.exists(cachepath):
            os.unlink(cachepath)
        s = self.attachSVNPoller(sample_base, cachepath=cachepath)
        self.assertEqual(s.last_change, None)

    def test_cachepath_full(self):
        cachepath = os.path.abspath('revcache')
        with open(cachepath, "w") as f:
            f.write('33')
        s = self.attachSVNPoller(sample_base, cachepath=cachepath)
        self.assertEqual(s.last_change, 33)

        s.last_change = 44
        s.finished_ok(None)
        with open(cachepath) as f:
            self.assertEqual(f.read().strip(), '44')

    @compat.usesFlushLoggedErrors
    def test_cachepath_bogus(self):
        cachepath = os.path.abspath('revcache')
        with open(cachepath, "w") as f:
            f.write('nine')
        s = self.attachSVNPoller(sample_base, cachepath=cachepath)
        self.assertEqual(s.last_change, None)
        self.assertEqual(s.cachepath, None)
        # it should have called log.err once with a ValueError
        self.assertEqual(len(self.flushLoggedErrors(ValueError)), 1)

    def test_constructor_pollinterval(self):
        self.attachSVNPoller(sample_base, pollinterval=100) # just don't fail!
        
    def test_extra_args(self):
        extra_args = ['--no-auth-cache',]
        base = "svn+ssh://svn.twistedmatrix.com/svn/Twisted/trunk"

        s = self.attachSVNPoller(svnurl=base, extra_args=extra_args)
        self.failUnlessEqual(s.extra_args, extra_args)
        
class TestSplitFile(unittest.TestCase):
    def test_split_file_alwaystrunk(self):
        self.assertEqual(svnpoller.split_file_alwaystrunk('foo'), dict(path='foo'))

    def test_split_file_branches_trunk(self):
        self.assertEqual(
                svnpoller.split_file_branches('trunk/'),
                (None, ''))

    def test_split_file_branches_trunk_subdir(self):
        self.assertEqual(
                svnpoller.split_file_branches('trunk/subdir/'),
                (None, 'subdir/'))

    def test_split_file_branches_trunk_subfile(self):
        self.assertEqual(
                svnpoller.split_file_branches('trunk/subdir/file.c'),
                (None, 'subdir/file.c'))

    def test_split_file_branches_trunk_invalid(self):
        # file named trunk (not a directory):
        self.assertEqual(
                svnpoller.split_file_branches('trunk'),
                None)

    def test_split_file_branches_branch(self):
        self.assertEqual(
                svnpoller.split_file_branches('branches/1.5.x/'),
                ('branches/1.5.x', ''))

    def test_split_file_branches_branch_subdir(self):
        self.assertEqual(
                svnpoller.split_file_branches('branches/1.5.x/subdir/'),
                ('branches/1.5.x', 'subdir/'))

    def test_split_file_branches_branch_subfile(self):
        self.assertEqual(
                svnpoller.split_file_branches('branches/1.5.x/subdir/file.c'),
                ('branches/1.5.x', 'subdir/file.c'))

    def test_split_file_branches_branch_invalid(self):
        # file named branches/1.5.x (not a directory):
        self.assertEqual(
                svnpoller.split_file_branches('branches/1.5.x'),
                None)

    def test_split_file_branches_otherdir(self):
        # other dirs are ignored:
        self.assertEqual(
                svnpoller.split_file_branches('tags/testthis/subdir/'),
                None)

    def test_split_file_branches_otherfile(self):
        # other files are ignored:
        self.assertEqual(
                svnpoller.split_file_branches('tags/testthis/subdir/file.c'),
                None)

    def test_split_file_projects_branches(self):
        self.assertEqual(
                svnpoller.split_file_projects_branches('buildbot/trunk/subdir/file.c'),
                dict(project='buildbot', path='subdir/file.c'))
        self.assertEqual(
                svnpoller.split_file_projects_branches('buildbot/branches/1.5.x/subdir/file.c'),
                dict(project='buildbot', branch='branches/1.5.x', path='subdir/file.c'))
        # tags are ignored:
        self.assertEqual(
                svnpoller.split_file_projects_branches('buildbot/tags/testthis/subdir/file.c'),
                None)