Ejemplo n.º 1
0
 def test_saves_to_filepath(self):
     temp_name = self.get_temp_file_name()
     self.assertFalse(os.path.exists(temp_name))
     a_nfile = NFile(temp_name)
     self.assertFalse(os.path.exists(a_nfile._file_path))
     a_nfile.save("empty content")
     self.assertTrue(os.path.exists(a_nfile._file_path))
 def test_saves_to_filepath(self):
     temp_name = self.get_temp_file_name()
     self.assertFalse(os.path.exists(temp_name))
     a_nfile = NFile(temp_name)
     self.assertFalse(os.path.exists(a_nfile._file_path))
     a_nfile.save("empty content")
     self.assertTrue(os.path.exists(a_nfile._file_path))
Ejemplo n.º 3
0
 def test_actual_content_is_saved(self):
     file_content = "empty content"
     temp_name = self.get_temp_file_name()
     self.assertFalse(os.path.exists(temp_name))
     a_nfile = NFile(temp_name)
     a_nfile.save(file_content)
     a_file = open(temp_name, "r")
     a_file_content = a_file.read()
     self.assertEqual(a_file_content, file_content)
 def test_actual_content_is_saved(self):
     file_content = "empty content"
     temp_name = self.get_temp_file_name()
     self.assertFalse(os.path.exists(temp_name))
     a_nfile = NFile(temp_name)
     a_nfile.save(file_content)
     a_file = open(temp_name, "r")
     a_file_content = a_file.read()
     self.assertEqual(a_file_content, file_content)
Ejemplo n.º 5
0
 def test_copy_flag_saves_to_path_only(self):
     temp_name = self.get_temp_file_name()
     temp_name_path = self.get_temp_file_name()
     #Since we cant assure the two paths are differents we do this
     temp_name_path = u"%s_really_unique" % temp_name_path
     self._trash_files.append(temp_name_path)
     self.assertNotEqual(temp_name, temp_name_path)
     a_nfile = NFile(temp_name)
     a_nfile.save("empty content", path=temp_name_path)
     self.assertFalse(os.path.exists(temp_name))
     self.assertTrue(os.path.exists(temp_name_path))
Ejemplo n.º 6
0
 def test_copy_flag_prevets_filepath_change(self):
     temp_name = self.get_temp_file_name()
     temp_name_path = self.get_temp_file_name()
     #Since we cant assure the two paths are differents we do this
     temp_name_path = u"%s_really_unique" % temp_name_path
     self._trash_files.append(temp_name_path)
     self.assertNotEqual(temp_name, temp_name_path)
     a_nfile = NFile(temp_name)
     self.assertNotEqual(temp_name_path, a_nfile._file_path)
     a_nfile.save("empty content", path=temp_name_path, copy=True)
     self.assertNotEqual(temp_name_path, a_nfile._file_path)
Ejemplo n.º 7
0
 def test_path_is_set_as_new_filepath(self):
     temp_name = self.get_temp_file_name()
     temp_name_path = self.get_temp_file_name()
     #Since we cant assure the two paths are differents we do this
     temp_name_path = u"%s_really_unique" % temp_name_path
     self._trash_files.append(temp_name_path)
     self.assertNotEqual(temp_name, temp_name_path)
     a_nfile = NFile(temp_name)
     self.assertNotEqual(temp_name_path, a_nfile._file_path)
     a_nfile.save("empty content", path=temp_name_path)
     self.assertEqual(temp_name_path, a_nfile._file_path)
 def test_copy_flag_saves_to_path_only(self):
     temp_name = self.get_temp_file_name()
     temp_name_path = self.get_temp_file_name()
     #Since we cant assure the two paths are differents we do this
     temp_name_path = u"%s_really_unique" % temp_name_path
     self._trash_files.append(temp_name_path)
     self.assertNotEqual(temp_name, temp_name_path)
     a_nfile = NFile(temp_name)
     a_nfile.save("empty content", path=temp_name_path)
     self.assertFalse(os.path.exists(temp_name))
     self.assertTrue(os.path.exists(temp_name_path))
Ejemplo n.º 9
0
 def test_copy_flag_prevets_filepath_change(self):
     temp_name = self.get_temp_file_name()
     temp_name_path = self.get_temp_file_name()
     #Since we cant assure the two paths are differents we do this
     temp_name_path = u"%s_really_unique" % temp_name_path
     self._trash_files.append(temp_name_path)
     self.assertNotEqual(temp_name, temp_name_path)
     a_nfile = NFile(temp_name)
     self.assertNotEqual(temp_name_path, a_nfile._file_path)
     a_nfile.save("empty content", path=temp_name_path, copy=True)
     self.assertNotEqual(temp_name_path, a_nfile._file_path)
Ejemplo n.º 10
0
 def test_path_is_set_as_new_filepath(self):
     temp_name = self.get_temp_file_name()
     temp_name_path = self.get_temp_file_name()
     #Since we cant assure the two paths are differents we do this
     temp_name_path = u"%s_really_unique" % temp_name_path
     self._trash_files.append(temp_name_path)
     self.assertNotEqual(temp_name, temp_name_path)
     a_nfile = NFile(temp_name)
     self.assertNotEqual(temp_name_path, a_nfile._file_path)
     a_nfile.save("empty content", path=temp_name_path)
     self.assertEqual(temp_name_path, a_nfile._file_path)
Ejemplo n.º 11
0
 def test_creates_if_doesnt_exist(self):
     temp_name = self.get_temp_file_name()
     self.assertFalse(os.path.exists(temp_name))
     a_nfile = NFile(temp_name)
     a_nfile.save("empty content")
     self.assertTrue(os.path.exists(temp_name))
Ejemplo n.º 12
0
 def test_creates_if_doesnt_exist(self):
     temp_name = self.get_temp_file_name()
     self.assertFalse(os.path.exists(temp_name))
     a_nfile = NFile(temp_name)
     a_nfile.save("empty content")
     self.assertTrue(os.path.exists(temp_name))