示例#1
0
  def test_init(self):
    os.chdir(self.root_temp_dir)
    init.init()
    os.chdir('.pygit')

    # Read index object
    index_object = utils.read_object_from_file(globalVars.index_file_name)
    assert isinstance(index_object, set) == True
示例#2
0
def test_read_and_write_object_from_file():
  _, file_path = tempfile.mkstemp()
  temp_list = [1, 2, 'aksjdhf']
  utils.write_object_to_file(file_path, temp_list)
  temp_list_from_disk = utils.read_object_from_file(file_path)

  assert all([i == j for (i, j) in zip(temp_list_from_disk, temp_list)]) == True

  os.remove(file_path)
示例#3
0
  def test_add_happy_state(self):
    os.chdir(self.root_temp_dir + '/one')
    os.chdir('.pygit')

    index_set = utils.read_object_from_file(globalVars.index_file_name)
    assert len(index_set) == 0

    os.chdir('../')
    f = open('temp_touch.file', 'a')
    f.close()
    temp_file_name = 'temp_touch.file'
    add.add(temp_file_name)

    os.chdir('.pygit')
    index_set = utils.read_object_from_file(globalVars.index_file_name)

    assert len(index_set) == 1
    assert temp_file_name in index_set