~alecu/ubuntuone-storage-protocol/timestamp-server

« back to all changes in this revision

Viewing changes to tests/test_dircontent.py

  • Committer: Tarmac
  • Author(s): Rodney Dawes
  • Date: 2010-11-16 15:10:48 UTC
  • mfrom: (121.1.4 use-packages)
  • Revision ID: tarmac-20101116151048-b0e20j7lorb4yhe1
Switch to using packaged mocker and ubuntuone-dev-tools
Use pyflakes with u1lint and also run pep8
Fix a lot of pylint/pyflakes/pep8 errors

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
#
6
6
# Copyright (C) 2009 Canonical
7
7
#
8
 
# This program is free software: you can redistribute it and/or modify it 
 
8
# This program is free software: you can redistribute it and/or modify it
9
9
# under the terms of the GNU Affero General Public License version 3,
10
10
# as published by the Free Software Foundation.
11
11
#
12
 
# This program is distributed in the hope that it will be useful, but 
13
 
# WITHOUT ANY WARRANTY; without even the implied warranties of 
14
 
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 
 
12
# This program is distributed in the hope that it will be useful, but
 
13
# WITHOUT ANY WARRANTY; without even the implied warranties of
 
14
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15
15
# PURPOSE.  See the GNU Affero General Public License for more details.
16
16
#
17
17
# You should have received a copy of the GNU Affero General Public License
20
20
 
21
21
from __future__ import with_statement
22
22
 
 
23
from cStringIO import StringIO
 
24
from ubuntuone.storageprotocol.dircontent import (
 
25
    parse_dir_content, write_dir_content, DirEntry,
 
26
    normalize_filename, validate_filename, InvalidFilename)
 
27
from ubuntuone.storageprotocol.dircontent_pb2 import (DIRECTORY, FILE)
23
28
from unittest import TestCase
24
 
from ubuntuone.storageprotocol.dircontent import \
25
 
    parse_dir_content, write_dir_content, DirEntry, FILE, DIRECTORY, \
26
 
    normalize_filename, validate_filename, InvalidFilename
27
 
from cStringIO import StringIO
28
29
 
29
30
 
30
31
class TestFilenames(TestCase):
103
104
        """
104
105
        a = DirEntry(name=u"negatory", node_type=FILE, uuid="abcd")
105
106
        b = DirEntry(name=u"beef", node_type=DIRECTORY, uuid="efgh")
106
 
        buffer = StringIO()
107
 
        write_dir_content([a, b], buffer)
108
 
        buffer.seek(0, 0)
109
 
        output_entries = [e for e in parse_dir_content(buffer)]
 
107
        buf = StringIO()
 
108
        write_dir_content([a, b], buf)
 
109
        buf.seek(0, 0)
 
110
        output_entries = [e for e in parse_dir_content(buf)]
110
111
        self.assertEqual(output_entries, [b, a])