Skip to content

Commit

Permalink
Add NYGrid unit test
Browse files Browse the repository at this point in the history
A unit test for NYGrid has been created to verify instantiation and simple attributes checks. The test function 'test_nygrid_obj' is implemented to ensure that the NYGrid can be correctly instantiated, and the start and end datetime are set correctly.
  • Loading branch information
boyuan276 committed Jan 31, 2024
1 parent 3143778 commit 3c31600
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/test_nygrid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import os
from datetime import datetime
from nygrid.nygrid import NYGrid
import pytest

# Set up directories
cwd = os.getcwd()
if 'tests' in cwd:
parent_dir = os.path.dirname(cwd)
data_dir = os.path.join(parent_dir, 'data')
else:
data_dir = os.path.join(cwd, 'data')

grid_data_dir = os.path.join(data_dir, 'grid')
if not os.path.exists(grid_data_dir):
raise FileNotFoundError('Grid data directory not found.')

start_datetime = datetime(2018, 1, 1, 0, 0, 0)
end_datetime = datetime(2018, 1, 2, 0, 0, 0)


def test_nygrid_obj():
nygrid_sim = NYGrid(grid_data_dir,
start_datetime=start_datetime.strftime('%m-%d-%Y %H'),
end_datetime=end_datetime.strftime('%m-%d-%Y %H'),
dcline_prop=None,
esr_prop=None,
vre_prop=None,
verbose=True)

assert nygrid_sim is not None
assert isinstance(nygrid_sim, NYGrid)
assert nygrid_sim.start_datetime == start_datetime
assert nygrid_sim.end_datetime == end_datetime

0 comments on commit 3c31600

Please sign in to comment.