コード例 #1
0
 def test_path_not_starting_with_slash(self):
     text = "'foo' is not an absolute path @ data['values'][0]"
     try:
         cwd = os.getcwd()
         os.chdir(self.dir.path)
         self.dir.makedir('foo')
         with ShouldFailSchemaWith(text):
             Plugin.schema(dict(type='paths', values=['foo']))
     finally:
         os.chdir(cwd)
コード例 #2
0
    def test_write_contents_file(self):
        contents = {
            '/b':   ('r-x-wx---', 'looong', 'group'),
            '/a/d': ('rw-r-x---', 'short', 'grouuuup'),
            '/a/c': ('rwxr-x---', 'x', 'y'),
        }

        contents_path = self.dir.getpath('contents.txt')
        Plugin.write_contents_file(contents, contents_path)

        compare("""\
rwxr-x--- x      y        /a/c
rw-r-x--- short  grouuuup /a/d
r-x-wx--- looong group    /b
""", self.dir.read(contents_path))
コード例 #3
0
 def test_schema_ok(self):
     p1 = self.dir.write('foo', b'f')
     p2 = self.dir.write('bar', b'b')
     compare(
         dict(type='paths', values=[p1, p2], repo='config'),
         Plugin.schema(
             dict(type='paths', values=[p1, p2], repo='config')
         ))
コード例 #4
0
    def test_read_contents_file(self):
        path = self.dir.write('contents.txt', '''\
r-x-wx--- x y /foo/bar
rwxr-x--- a b /baz/bob
''')

        contents = Plugin.read_contents_file(path)

        compare(contents, {
            '/foo/bar': ('r-x-wx---', 'x', 'y'),
            '/baz/bob': ('rwxr-x---', 'a', 'b'),
        })
コード例 #5
0
 def test_path_not_there(self):
     bad_path = self.dir.getpath('bad')
     text = "'%s' does not exist @ data['values'][0]" % bad_path
     with ShouldFailSchemaWith(text):
         Plugin.schema(dict(type='paths', values=[bad_path]))
コード例 #6
0
 def test_path_not_string(self):
     text = "expected str @ data['values'][0]"
     with ShouldFailSchemaWith(text):
         Plugin.schema(dict(type='paths', values=[1]))
コード例 #7
0
 def test_no_paths(self):
     text = "length of value must be at least 1 for dictionary value " \
            "@ data['values']"
     with ShouldFailSchemaWith(text):
         Plugin.schema(dict(type='paths', values=[]))
コード例 #8
0
 def test_name_supplied(self):
     text = "not a valid value for dictionary value @ data['name']"
     with ShouldFailSchemaWith(text):
         Plugin.schema(dict(type='paths', name='foo'))
コード例 #9
0
 def test_schema_extra_keys(self):
     with ShouldFailSchemaWith("extra keys not allowed @ data['foo']"):
         Plugin.schema(dict(type='paths', foo='bar'))
コード例 #10
0
 def test_schema_wrong_type(self):
     text = "not a valid value for dictionary value @ data['type']"
     with ShouldFailSchemaWith(text):
         Plugin.schema(dict(type='bar', values=['/']))
コード例 #11
0
 def test_path_not_there(self):
     text = "invalid list value @ data['values'][0]"
     with ShouldFailSchemaWith(text):
         Plugin.schema(dict(type='paths', values=[self.dir.getpath('bad')]))
コード例 #12
0
 def test_path_not_starting_with_slash(self):
     text = "invalid list value @ data['values'][0]"
     with ShouldFailSchemaWith(text):
         Plugin.schema(dict(type='paths', values=['foo']))