MCPcopy Create free account
hub / github.com/gitless-vcs/gitless / TestFileStatus

Class TestFileStatus

gitless/tests/test_core.py:433–563  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

431
432
433class TestFileStatus(TestFile):
434
435 def test_status_all(self):
436 st_all = self.curr_b.status()
437 for fp, f_type, exists_at_head, exists_in_wd, modified, _ in st_all:
438 if (fp == UNTRACKED_FP or fp == UNTRACKED_FP_WITH_SPACE or
439 fp == UNTRACKED_DIR_FP or fp == UNTRACKED_DIR_FP_WITH_SPACE or
440 fp == UNTRACKED_DIR_DIR_FP or
441 fp == UNTRACKED_DIR_DIR_FP_WITH_SPACE):
442 self.__assert_type(fp, core.GL_STATUS_UNTRACKED, f_type)
443 self.__assert_field(fp, 'exists_at_head', False, exists_at_head)
444 self.__assert_field(fp, 'modified', True, modified)
445 elif fp == '.gitignore':
446 self.__assert_type(fp, core.GL_STATUS_UNTRACKED, f_type)
447 self.__assert_field(fp, 'exists_at_head', False, exists_at_head)
448 self.__assert_field(fp, 'modified', True, modified)
449 self.__assert_field(fp, 'exists_in_wd', True, exists_in_wd)
450
451 def test_status_equivalence(self):
452 for f_st in self.curr_b.status():
453 self.assertEqual(f_st, self.curr_b.status_file(f_st.fp))
454
455 def test_status_nonexistent_fp(self):
456 self.assertRaises(KeyError, self.curr_b.status_file, NONEXISTENT_FP)
457 self.assertRaises(
458 KeyError, self.curr_b.status_file, NONEXISTENT_FP_WITH_SPACE)
459
460 def test_status_modify(self):
461 utils_lib.write_file(TRACKED_FP, contents='contents')
462 st = self.curr_b.status_file(TRACKED_FP)
463 self.assertTrue(st.modified)
464 utils_lib.write_file(TRACKED_FP, contents=TRACKED_FP_CONTENTS_2)
465 st = self.curr_b.status_file(TRACKED_FP)
466 self.assertFalse(st.modified)
467
468 def test_status_rm(self):
469 os.remove(TRACKED_FP)
470 st = self.curr_b.status_file(TRACKED_FP)
471 self.assertEqual(core.GL_STATUS_TRACKED, st.type)
472 self.assertTrue(st.modified)
473 self.assertTrue(st.exists_at_head)
474 self.assertFalse(st.exists_in_wd)
475
476 utils_lib.write_file(TRACKED_FP, contents=TRACKED_FP_CONTENTS_2)
477 st = self.curr_b.status_file(TRACKED_FP)
478 self.assertEqual(core.GL_STATUS_TRACKED, st.type)
479 self.assertFalse(st.modified)
480 self.assertTrue(st.exists_at_head)
481 self.assertTrue(st.exists_in_wd)
482
483 def test_status_track_rm(self):
484 self.curr_b.track_file(UNTRACKED_FP)
485 st = self.curr_b.status_file(UNTRACKED_FP)
486 self.assertEqual(core.GL_STATUS_TRACKED, st.type)
487 self.assertTrue(st.modified)
488
489 os.remove(UNTRACKED_FP)
490 self.assertRaises(KeyError, self.curr_b.status_file, UNTRACKED_FP)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected