Skip to content

Commit

Permalink
#119 add ut for file input (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-oberg authored Mar 26, 2024
1 parent 20c080e commit 523310d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
5 changes: 0 additions & 5 deletions tests/test_example.py

This file was deleted.

25 changes: 25 additions & 0 deletions tests/test_fileInput.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from gv_ui import fileInput
import os
import os.path
import pytest

def test_find_source_path():
result_exist = fileInput.find_source_path('rhopol.cube', 'tests/data/')
result_dne = fileInput.find_source_path('not-real.cube', 'tests/data/')
assert result_exist == 'tests/data/rhopol.cube'
assert result_dne == None

def test_generate_unique_filename():
name_1 = fileInput.generate_unique_filename('rhopol.cube', 'tests/data/')
assert name_1 == 'rhopol_1.cube'

def test_copy_file():
result = fileInput.copy_file('tests/data/rhopol.cube', 'tests/data/copy.cube')
assert result == True
assert os.path.isfile('tests/data/rhopol.cube') == True

os.remove('tests/data/copy.cube')

result = fileInput.copy_file('tests/data/not-real.cube', 'tests/data/copy.cube')
assert result == False
assert os.path.isfile('tests/data/copy.cube') == False

0 comments on commit 523310d

Please sign in to comment.