示例#1
0
  def test_move_directory(self):
    d = new_file(self.user, self.project, path="/dir/", save=True)
    f = new_file(self.user, self.project, path="/dir/f1.txt", save=True)

    self.login()
    response, data = self.putJSON(self.base_url("move"), query_string={"path": "/dir/"}, data={"path": "/moved_dir/"})
    self.assertStatus(200, response)

    with self.assertRaises(NotFoundError):
      f.reload()

    with self.assertRaises(NotFoundError):
      d.reload()

    self.assertFalse(os.path.exists(f.fspath))
    self.assertFalse(os.path.exists(d.fspath))

    d = File.get_by_project_path(self.project, "/moved_dir/")
    f = File.get_by_project_path(self.project, "/moved_dir/f1.txt")
    self._c.append(d)

    self.assertEquals(1, len(list(d.children)))
    self.assertEquals("hello world", f.content)

    self.assertTrue(os.path.exists(d.fspath))
    self.assertTrue(os.path.exists(f.fspath))
示例#2
0
    def test_move_directory(self):
        d = new_file(self.user, self.project, path="/dir/", save=True)
        f = new_file(self.user, self.project, path="/dir/f1.txt", save=True)

        self.login()
        response, data = self.putJSON(self.base_url("move"),
                                      query_string={"path": "/dir/"},
                                      data={"path": "/moved_dir/"})
        self.assertStatus(200, response)

        with self.assertRaises(NotFoundError):
            f.reload()

        with self.assertRaises(NotFoundError):
            d.reload()

        self.assertFalse(os.path.exists(f.fspath))
        self.assertFalse(os.path.exists(d.fspath))

        d = File.get_by_project_path(self.project, "/moved_dir/")
        f = File.get_by_project_path(self.project, "/moved_dir/f1.txt")
        self._c.append(d)

        self.assertEquals(1, len(list(d.children)))
        self.assertEquals("hello world", f.content)

        self.assertTrue(os.path.exists(d.fspath))
        self.assertTrue(os.path.exists(f.fspath))
示例#3
0
    def test_create_file_missing_intermediate_directories(self):
        with self.assertRaises(NotFoundError):
            new_file(self.user,
                     self.project,
                     path="/does/not/exist.txt",
                     save=True)

        with self.assertRaises(NotFoundError):
            File.get_by_project_path(self.project, "/does/not/exists.txt")
示例#4
0
    def test_delete_file(self):
        f = new_file(self.user, self.project, save=True)
        fspath = f.fspath
        self.assertTrue(os.path.exists(fspath))

        f.delete()
        self.assertFalse(os.path.exists(fspath))

        with self.assertRaises(NotFoundError):
            File.get(f.key)
示例#5
0
    def test_delete_directory(self):
        d = new_directory(self.user, self.project, save=True)
        fspath = d.fspath
        self.assertTrue(os.path.exists(fspath))

        d.delete()
        self.assertFalse(os.path.exists(fspath))

        with self.assertRaises(NotFoundError):
            File.get(d.key)
示例#6
0
  def test_delete_directory(self):
    d = new_directory(self.user, self.project, save=True)
    fspath = d.fspath
    self.assertTrue(os.path.exists(fspath))

    d.delete()
    self.assertFalse(os.path.exists(fspath))

    with self.assertRaises(NotFoundError):
      File.get(d.key)
示例#7
0
  def test_delete_file(self):
    f = new_file(self.user, self.project, save=True)
    fspath = f.fspath
    self.assertTrue(os.path.exists(fspath))

    f.delete()
    self.assertFalse(os.path.exists(fspath))

    with self.assertRaises(NotFoundError):
      File.get(f.key)
示例#8
0
  def test_delete_directory_with_subtree(self):
    d = new_directory(self.user, self.project, path="/directory/", save=True)
    fspath = d.fspath
    self.assertTrue(os.path.exists(fspath))

    f1 = new_file(self.user, self.project, path="/directory/file1.txt", save=True)
    f2 = new_file(self.user, self.project, path="/directory/file2.txt", save=True)
    d1 = new_directory(self.user, self.project, path="/directory/d1/", save=True)
    f3 = new_file(self.user, self.project, path="/directory/d1/file3.txt", save=True)

    d.delete()
    self.assertFalse(os.path.exists(f1.fspath))
    self.assertFalse(os.path.exists(f2.fspath))
    self.assertFalse(os.path.exists(d1.fspath))
    self.assertFalse(os.path.exists(f3.fspath))

    with self.assertRaises(NotFoundError):
      File.get(f1.key)

    with self.assertRaises(NotFoundError):
      File.get(f2.key)

    with self.assertRaises(NotFoundError):
      File.get(d1.key)

    with self.assertRaises(NotFoundError):
      File.get(f3.key)
示例#9
0
  def test_move_within_directory(self):
    new_directory(self.user, self.project, path="/dir/", save=True)
    d1 = new_directory(self.user, self.project, path="/dir/one/", save=True)

    old_fspath = d1.fspath
    d1.move("/dir/two/")

    with self.assertRaises(NotFoundError):
      File.get_by_project_path(self.project, "/dir/one/")

    self.assertFalse(os.path.exists(old_fspath))
    self.assertTrue(os.path.exists(d1.fspath))

    d1_g = File.get_by_project_path(self.project, "/dir/two/")
    self.assertEquals(d1.fspath, d1_g.fspath)
示例#10
0
  def test_update_file_content(self):
    f = new_file(self.user, self.project, save=True)
    f.update_content("yay!")
    now = f.date
    g = File.get_by_project_path(self.project, f.path)

    self.assertEquals("yay!", g.content)
    self.assertNotEquals(now, g.date)
示例#11
0
    def test_update_file_content(self):
        f = new_file(self.user, self.project, save=True)
        f.update_content("yay!")
        now = f.date
        g = File.get_by_project_path(self.project, f.path)

        self.assertEquals("yay!", g.content)
        self.assertNotEquals(now, g.date)
示例#12
0
    def test_move_within_directory(self):
        new_directory(self.user, self.project, path="/dir/", save=True)
        d1 = new_directory(self.user,
                           self.project,
                           path="/dir/one/",
                           save=True)

        old_fspath = d1.fspath
        d1.move("/dir/two/")

        with self.assertRaises(NotFoundError):
            File.get_by_project_path(self.project, "/dir/one/")

        self.assertFalse(os.path.exists(old_fspath))
        self.assertTrue(os.path.exists(d1.fspath))

        d1_g = File.get_by_project_path(self.project, "/dir/two/")
        self.assertEquals(d1.fspath, d1_g.fspath)
示例#13
0
    def test_move_fail_with_non_existing_directories(self):
        new_directory(self.user, self.project, path="/dir/", save=True)
        d1 = new_directory(self.user, self.project, path="/dir/d1/", save=True)
        new_file(self.user, self.project, path="/dir/d1/test.txt", save=True)

        with self.assertRaises(NotFoundError):
            d1.move("/dir/not/d2/")

        self.assertTrue(d1.fspath.rstrip("/").endswith("d1"))

        d11 = File.get_by_project_path(self.project, "/dir/d1/")
        self.assertTrue(os.path.exists(d11.fspath))

        with self.assertRaises(NotFoundError):
            File.get_by_project_path(self.project, "/dir1/d2/")

        with self.assertRaises(NotFoundError):
            File.get_by_project_path(self.project, "/dir1/d2/test.txt")
示例#14
0
  def test_move_fail_with_non_existing_directories(self):
    new_directory(self.user, self.project, path="/dir/", save=True)
    d1 = new_directory(self.user, self.project, path="/dir/d1/", save=True)
    new_file(self.user, self.project, path="/dir/d1/test.txt", save=True)

    with self.assertRaises(NotFoundError):
      d1.move("/dir/not/d2/")

    self.assertTrue(d1.fspath.rstrip("/").endswith("d1"))

    d11 = File.get_by_project_path(self.project, "/dir/d1/")
    self.assertTrue(os.path.exists(d11.fspath))

    with self.assertRaises(NotFoundError):
      File.get_by_project_path(self.project, "/dir1/d2/")

    with self.assertRaises(NotFoundError):
      File.get_by_project_path(self.project, "/dir1/d2/test.txt")
示例#15
0
  def test_create_file_security(self):
    f = File.create(data={
      "project": self.project,
      "path": "/../../../../evil/path"
    })

    self.assertTrue(".." not in f.fspath)
    self.assertEquals("/evil/path", f.path)

    self.assertEquals(os.path.join(File.FILES_FOLDER, self.project.key, "evil/path"), f.fspath)
示例#16
0
文件: utils.py 项目: Siecje/projecto
def new_directory(user, project, **kwargs):
  save = kwargs.pop("save", False)
  kwargs["author"] = user
  kwargs["project"] = project
  kwargs["path"] = kwargs.get("path", "/testdir/")
  f = File.create(data=kwargs)

  if save:
    f.save()
  return f
示例#17
0
def new_directory(user, project, **kwargs):
    save = kwargs.pop("save", False)
    kwargs["author"] = user
    kwargs["project"] = project
    kwargs["path"] = kwargs.get("path", "/testdir/")
    f = File.create(data=kwargs)

    if save:
        f.save()
    return f
示例#18
0
  def test_lsroot(self):
    new_directory(self.user, self.project, path="/dir1/", save=True)
    new_file(self.user, self.project, path="/test.file", save=True)
    new_file(self.user, self.project, path="/dir1/test1.txt", save=True)

    children = list(File.lsroot(self.project))
    self.assertEquals(2, len(children))

    paths = [c.path for c in children]
    self.assertTrue("/dir1/" in paths)
    self.assertTrue("/test.file" in paths)
示例#19
0
文件: utils.py 项目: Siecje/projecto
def new_file(user, project, **kwargs):
  save = kwargs.pop("save", False)
  kwargs["author"] = user
  kwargs["project"] = project
  kwargs["path"] = kwargs.get("path", "/testfile.txt")
  kwargs["file"] = kwargs.get("file", FileStorage(StringIO("hello world"), "testfile.txt"))
  f = File.create(data=kwargs)

  if save:
    f.save()
  return f
示例#20
0
    def test_lsroot(self):
        new_directory(self.user, self.project, path="/dir1/", save=True)
        new_file(self.user, self.project, path="/test.file", save=True)
        new_file(self.user, self.project, path="/dir1/test1.txt", save=True)

        children = list(File.lsroot(self.project))
        self.assertEquals(2, len(children))

        paths = [c.path for c in children]
        self.assertTrue("/dir1/" in paths)
        self.assertTrue("/test.file" in paths)
示例#21
0
  def test_get_file(self):
    f = new_file(self.user, self.project, save=True)

    g = File.get_by_project_path(self.project, f.path)
    self.assertEquals(f.key, g.key)
    self.assertEquals(f.author.key, g.author.key)
    self.assertEquals(f.project.key, g.project.key)
    self.assertEquals(f.fspath, g.fspath)
    self.assertEquals(f.path, g.path)
    self.assertFalse(g.is_directory)

    self.assertEquals("hello world", g.content)
示例#22
0
  def test_create_directory(self):
    self.login()
    response = self.post(self.base_url(), query_string={"path": "/test_dir/"})
    _, data = self._get_json_from_response(response)

    self.assertStatus(200, response)

    d = File.get_by_project_path(self.project, "/test_dir/")
    self._c.append(d)
    self.assertTrue(os.path.exists(d.fspath))
    self.assertEquals(self.user.key, d.author.key)
    self.assertEquals(self.project.key, d.project.key)
示例#23
0
def new_file(user, project, **kwargs):
    save = kwargs.pop("save", False)
    kwargs["author"] = user
    kwargs["project"] = project
    kwargs["path"] = kwargs.get("path", "/testfile.txt")
    kwargs["file"] = kwargs.get(
        "file", FileStorage(StringIO("hello world"), "testfile.txt"))
    f = File.create(data=kwargs)

    if save:
        f.save()
    return f
示例#24
0
    def test_create_file_security(self):
        f = File.create(data={
            "project": self.project,
            "path": "/../../../../evil/path"
        })

        self.assertTrue(".." not in f.fspath)
        self.assertEquals("/evil/path", f.path)

        self.assertEquals(
            os.path.join(File.FILES_FOLDER, self.project.key, "evil/path"),
            f.fspath)
示例#25
0
    def test_get_file(self):
        f = new_file(self.user, self.project, save=True)

        g = File.get_by_project_path(self.project, f.path)
        self.assertEquals(f.key, g.key)
        self.assertEquals(f.author.key, g.author.key)
        self.assertEquals(f.project.key, g.project.key)
        self.assertEquals(f.fspath, g.fspath)
        self.assertEquals(f.path, g.path)
        self.assertFalse(g.is_directory)

        self.assertEquals("hello world", g.content)
示例#26
0
    def test_create_directory(self):
        f = File.create(data={"project": self.project, "path": "/directory/"})

        fspath = os.path.join(File.FILES_FOLDER, self.project.key,
                              "directory") + "/"
        self.assertEquals(fspath, f.fspath)
        self.assertFalse(os.path.exists(fspath))

        f.save()

        self.assertTrue(os.path.exists(fspath))
        self.assertTrue(os.path.isdir(fspath))
示例#27
0
    def test_create_directory(self):
        self.login()
        response = self.post(self.base_url(),
                             query_string={"path": "/test_dir/"})
        _, data = self._get_json_from_response(response)

        self.assertStatus(200, response)

        d = File.get_by_project_path(self.project, "/test_dir/")
        self._c.append(d)
        self.assertTrue(os.path.exists(d.fspath))
        self.assertEquals(self.user.key, d.author.key)
        self.assertEquals(self.project.key, d.project.key)
示例#28
0
    def test_get_directory(self):
        d = new_directory(self.user, self.project, save=True)
        g = File.get_by_project_path(self.project, d.path)

        self.assertEquals(d.key, g.key)
        self.assertEquals(d.author.key, g.author.key)
        self.assertEquals(d.project.key, g.project.key)
        self.assertEquals(d.fspath, g.fspath)
        self.assertEquals(d.path, g.path)
        self.assertTrue(g.is_directory)

        with self.assertRaises(AttributeError):
            g.content
示例#29
0
  def test_get_directory(self):
    d = new_directory(self.user, self.project, save=True)
    g = File.get_by_project_path(self.project, d.path)

    self.assertEquals(d.key, g.key)
    self.assertEquals(d.author.key, g.author.key)
    self.assertEquals(d.project.key, g.project.key)
    self.assertEquals(d.fspath, g.fspath)
    self.assertEquals(d.path, g.path)
    self.assertTrue(g.is_directory)

    with self.assertRaises(AttributeError):
      g.content
示例#30
0
  def test_create_directory(self):
    f = File.create(data={
      "project": self.project,
      "path": "/directory/"
    })

    fspath = os.path.join(File.FILES_FOLDER, self.project.key, "directory") + "/"
    self.assertEquals(fspath, f.fspath)
    self.assertFalse(os.path.exists(fspath))

    f.save()

    self.assertTrue(os.path.exists(fspath))
    self.assertTrue(os.path.isdir(fspath))
示例#31
0
  def test_create_file(self):
    self.login()
    response = self.post(self.base_url(), query_string={"path": "/test_file.txt"}, data={"file": test_file("meh")})
    _, data = self._get_json_from_response(response)

    self.assertStatus(200, response)
    self.assertTrue("date" in data)

    fspath = os.path.join(File.FILES_FOLDER, self.project.key, "test_file.txt")
    self.assertTrue(os.path.exists(fspath))
    with open(fspath) as f:
      self.assertEquals("hello world", f.read())

    f = File.get_by_project_path(self.project, "/test_file.txt")
    self._c.append(f)
    self.assertEquals(self.user.key, f.author.key)
    self.assertEquals(self.project.key, f.project.key)
示例#32
0
  def test_move_file(self):
    f = new_file(self.user, self.project, path="/test.txt", save=True)

    self.login()
    response, data = self.putJSON(self.base_url("move"), query_string={"path": "/test.txt"}, data={"path": "/test_moved.txt"})
    self.assertStatus(200, response)

    with self.assertRaises(NotFoundError):
      f.reload()

    self.assertFalse(os.path.exists(f.fspath))

    fspath = os.path.join(File.FILES_FOLDER, self.project.key, "test_moved.txt")
    self.assertTrue(os.path.exists(fspath))

    f = File.get_by_project_path(self.project, "/test_moved.txt")
    self._c.append(f)
示例#33
0
    def test_delete_directory_with_subtree(self):
        d = new_directory(self.user,
                          self.project,
                          path="/directory/",
                          save=True)
        fspath = d.fspath
        self.assertTrue(os.path.exists(fspath))

        f1 = new_file(self.user,
                      self.project,
                      path="/directory/file1.txt",
                      save=True)
        f2 = new_file(self.user,
                      self.project,
                      path="/directory/file2.txt",
                      save=True)
        d1 = new_directory(self.user,
                           self.project,
                           path="/directory/d1/",
                           save=True)
        f3 = new_file(self.user,
                      self.project,
                      path="/directory/d1/file3.txt",
                      save=True)

        d.delete()
        self.assertFalse(os.path.exists(f1.fspath))
        self.assertFalse(os.path.exists(f2.fspath))
        self.assertFalse(os.path.exists(d1.fspath))
        self.assertFalse(os.path.exists(f3.fspath))

        with self.assertRaises(NotFoundError):
            File.get(f1.key)

        with self.assertRaises(NotFoundError):
            File.get(f2.key)

        with self.assertRaises(NotFoundError):
            File.get(d1.key)

        with self.assertRaises(NotFoundError):
            File.get(f3.key)
示例#34
0
    def test_create_file(self):
        self.login()
        response = self.post(self.base_url(),
                             query_string={"path": "/test_file.txt"},
                             data={"file": test_file("meh")})
        _, data = self._get_json_from_response(response)

        self.assertStatus(200, response)
        self.assertTrue("date" in data)

        fspath = os.path.join(File.FILES_FOLDER, self.project.key,
                              "test_file.txt")
        self.assertTrue(os.path.exists(fspath))
        with open(fspath) as f:
            self.assertEquals("hello world", f.read())

        f = File.get_by_project_path(self.project, "/test_file.txt")
        self._c.append(f)
        self.assertEquals(self.user.key, f.author.key)
        self.assertEquals(self.project.key, f.project.key)
示例#35
0
  def test_create_file(self):
    f = File.create(data={
      "project": self.project,
      "path": "/newfile.txt",
      "file": FileStorage(*test_file("newfile.txt"))
    })
    self.assertEquals("{}`{}".format(self.project.key, "/newfile.txt"), f.key)
    fspath = os.path.join(File.FILES_FOLDER, self.project.key, "newfile.txt")
    self.assertEquals(fspath, f.fspath)
    self.assertFalse(os.path.exists(fspath))

    f.save()

    self.assertEquals("/newfile.txt", f.path)
    self.assertTrue(os.path.exists(fspath))

    with open(fspath) as fi:
      c = fi.read().strip()

    self.assertEquals("hello world", c)
示例#36
0
    def test_move_file(self):
        f = new_file(self.user, self.project, path="/test.txt", save=True)

        self.login()
        response, data = self.putJSON(self.base_url("move"),
                                      query_string={"path": "/test.txt"},
                                      data={"path": "/test_moved.txt"})
        self.assertStatus(200, response)

        with self.assertRaises(NotFoundError):
            f.reload()

        self.assertFalse(os.path.exists(f.fspath))

        fspath = os.path.join(File.FILES_FOLDER, self.project.key,
                              "test_moved.txt")
        self.assertTrue(os.path.exists(fspath))

        f = File.get_by_project_path(self.project, "/test_moved.txt")
        self._c.append(f)
示例#37
0
    def test_create_file(self):
        f = File.create(
            data={
                "project": self.project,
                "path": "/newfile.txt",
                "file": FileStorage(*test_file("newfile.txt"))
            })
        self.assertEquals("{}`{}".format(self.project.key, "/newfile.txt"),
                          f.key)
        fspath = os.path.join(File.FILES_FOLDER, self.project.key,
                              "newfile.txt")
        self.assertEquals(fspath, f.fspath)
        self.assertFalse(os.path.exists(fspath))

        f.save()

        self.assertEquals("/newfile.txt", f.path)
        self.assertTrue(os.path.exists(fspath))

        with open(fspath) as fi:
            c = fi.read().strip()

        self.assertEquals("hello world", c)
示例#38
0
    def test_move_directory_with_subtree(self):
        d = new_directory(self.user,
                          self.project,
                          path="/directory1/",
                          save=True)
        f1 = new_file(self.user,
                      self.project,
                      path="/directory1/file1.txt",
                      save=True)
        f2 = new_file(self.user,
                      self.project,
                      path="/directory1/file2.txt",
                      save=True)
        d1 = new_directory(self.user,
                           self.project,
                           path="/directory1/d1/",
                           save=True)
        f3 = new_file(self.user,
                      self.project,
                      path="/directory1/d1/file3.txt",
                      save=True)

        old_key = d.key
        old_fspath = d.fspath

        d.move("/moved_directory1/")

        self.assertNotEquals(old_fspath, d.fspath)
        self.assertNotEquals(old_key, d.key)

        self.assertFalse(os.path.exists(old_fspath))
        self.assertFalse(os.path.exists(f1.fspath))
        self.assertFalse(os.path.exists(f2.fspath))
        self.assertFalse(os.path.exists(d1.fspath))
        self.assertFalse(os.path.exists(f3.fspath))

        with self.assertRaises(NotFoundError):
            File.get(old_key)

        with self.assertRaises(NotFoundError):
            File.get(f1.key)

        with self.assertRaises(NotFoundError):
            File.get(f2.key)

        with self.assertRaises(NotFoundError):
            File.get(d1.key)

        with self.assertRaises(NotFoundError):
            File.get(f3.key)

        f1 = File.get_by_project_path(d.project, "/moved_directory1/file1.txt")
        f2 = File.get_by_project_path(d.project, "/moved_directory1/file2.txt")
        d1 = File.get_by_project_path(d.project, "/moved_directory1/d1/")
        f3 = File.get_by_project_path(d.project,
                                      "/moved_directory1/d1/file3.txt")

        self.assertTrue(os.path.exists(f1.fspath))
        self.assertTrue(os.path.exists(f2.fspath))
        self.assertTrue(os.path.exists(d1.fspath))
        self.assertTrue(os.path.exists(f3.fspath))

        with open(f1.fspath) as f:
            self.assertEquals("hello world", f.read().strip())

        with open(f2.fspath) as f:
            self.assertEquals("hello world", f.read().strip())

        with open(f3.fspath) as f:
            self.assertEquals("hello world", f.read().strip())
示例#39
0
  def test_create_file_missing_intermediate_directories(self):
    with self.assertRaises(NotFoundError):
      new_file(self.user, self.project, path="/does/not/exist.txt", save=True)

    with self.assertRaises(NotFoundError):
      File.get_by_project_path(self.project, "/does/not/exists.txt")
示例#40
0
  def test_move_directory_with_subtree(self):
    d = new_directory(self.user, self.project, path="/directory1/", save=True)
    f1 = new_file(self.user, self.project, path="/directory1/file1.txt", save=True)
    f2 = new_file(self.user, self.project, path="/directory1/file2.txt", save=True)
    d1 = new_directory(self.user, self.project, path="/directory1/d1/", save=True)
    f3 = new_file(self.user, self.project, path="/directory1/d1/file3.txt", save=True)

    old_key = d.key
    old_fspath = d.fspath

    d.move("/moved_directory1/")

    self.assertNotEquals(old_fspath, d.fspath)
    self.assertNotEquals(old_key, d.key)

    self.assertFalse(os.path.exists(old_fspath))
    self.assertFalse(os.path.exists(f1.fspath))
    self.assertFalse(os.path.exists(f2.fspath))
    self.assertFalse(os.path.exists(d1.fspath))
    self.assertFalse(os.path.exists(f3.fspath))

    with self.assertRaises(NotFoundError):
      File.get(old_key)

    with self.assertRaises(NotFoundError):
      File.get(f1.key)

    with self.assertRaises(NotFoundError):
      File.get(f2.key)

    with self.assertRaises(NotFoundError):
      File.get(d1.key)

    with self.assertRaises(NotFoundError):
      File.get(f3.key)

    f1 = File.get_by_project_path(d.project, "/moved_directory1/file1.txt")
    f2 = File.get_by_project_path(d.project, "/moved_directory1/file2.txt")
    d1 = File.get_by_project_path(d.project, "/moved_directory1/d1/")
    f3 = File.get_by_project_path(d.project, "/moved_directory1/d1/file3.txt")

    self.assertTrue(os.path.exists(f1.fspath))
    self.assertTrue(os.path.exists(f2.fspath))
    self.assertTrue(os.path.exists(d1.fspath))
    self.assertTrue(os.path.exists(f3.fspath))

    with open(f1.fspath) as f:
      self.assertEquals("hello world", f.read().strip())

    with open(f2.fspath) as f:
      self.assertEquals("hello world", f.read().strip())

    with open(f3.fspath) as f:
      self.assertEquals("hello world", f.read().strip())