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))
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)
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))
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)
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))
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)
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_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))
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))