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

Class TestFileCheckout

gitless/tests/test_core.py:349–430  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

347
348
349class TestFileCheckout(TestFile):
350
351 def __assert_checkout_head(self, *fps):
352 root = self.repo.root
353 for fp in fps:
354 utils_lib.write_file(fp, contents='contents')
355 self.curr_b.checkout_file(
356 os.path.relpath(fp, root), self.repo.revparse_single('HEAD'))
357 self.assertEqual(TRACKED_FP_CONTENTS_2, utils_lib.read_file(fp))
358
359 @assert_no_side_effects(
360 TRACKED_FP, TRACKED_FP_WITH_SPACE,
361 TRACKED_DIR_FP, TRACKED_DIR_FP_WITH_SPACE,
362 TRACKED_DIR_DIR_FP, TRACKED_DIR_DIR_FP_WITH_SPACE)
363 def test_checkout_head(self):
364 self.__assert_checkout_head(
365 TRACKED_FP, TRACKED_FP_WITH_SPACE,
366 TRACKED_DIR_FP, TRACKED_DIR_FP_WITH_SPACE,
367 TRACKED_DIR_DIR_FP, TRACKED_DIR_DIR_FP_WITH_SPACE)
368
369 @assert_no_side_effects(
370 TRACKED_FP, TRACKED_FP_WITH_SPACE,
371 TRACKED_DIR_FP, TRACKED_DIR_FP_WITH_SPACE,
372 TRACKED_DIR_DIR_FP, TRACKED_DIR_DIR_FP_WITH_SPACE)
373 def test_checkout_head_relative(self):
374 os.chdir(DIR)
375 self.__assert_checkout_head(os.path.relpath(TRACKED_DIR_FP, DIR))
376 self.__assert_checkout_head(os.path.relpath(TRACKED_DIR_FP_WITH_SPACE, DIR))
377 os.chdir(DIR)
378 self.__assert_checkout_head(os.path.relpath(TRACKED_DIR_DIR_FP, DIR_DIR))
379 self.__assert_checkout_head(
380 os.path.relpath(TRACKED_DIR_DIR_FP_WITH_SPACE, DIR_DIR))
381
382 def __assert_checkout_not_head(self, *fps):
383 root = self.repo.root
384 for fp in fps:
385 utils_lib.write_file(fp, contents='contents')
386 self.curr_b.checkout_file(
387 os.path.relpath(fp, root), self.repo.revparse_single('HEAD^'))
388 self.assertEqual(TRACKED_FP_CONTENTS_1, utils_lib.read_file(fp))
389
390 def test_checkout_not_head(self):
391 self.__assert_checkout_not_head(
392 TRACKED_FP, TRACKED_FP_WITH_SPACE,
393 TRACKED_DIR_FP, TRACKED_DIR_FP_WITH_SPACE,
394 TRACKED_DIR_DIR_FP, TRACKED_DIR_DIR_FP_WITH_SPACE)
395
396 def test_checkout_not_head_relative(self):
397 os.chdir(DIR)
398 self.__assert_checkout_not_head(os.path.relpath(TRACKED_DIR_FP, DIR))
399 self.__assert_checkout_not_head(
400 os.path.relpath(TRACKED_DIR_FP_WITH_SPACE, DIR))
401 os.chdir(DIR)
402 self.__assert_checkout_not_head(
403 os.path.relpath(TRACKED_DIR_DIR_FP, DIR_DIR))
404 self.__assert_checkout_not_head(
405 os.path.relpath(TRACKED_DIR_DIR_FP_WITH_SPACE, DIR_DIR))
406

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected