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)
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') ))
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]))
def test_path_not_string(self): text = "expected str @ data['values'][0]" with ShouldFailSchemaWith(text): Plugin.schema(dict(type='paths', values=[1]))
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=[]))
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'))
def test_schema_extra_keys(self): with ShouldFailSchemaWith("extra keys not allowed @ data['foo']"): Plugin.schema(dict(type='paths', foo='bar'))
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=['/']))
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')]))
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']))