Skip to content

Commit

Permalink
Merge pull request #55 from aerispaha/vc-fix-01
Browse files Browse the repository at this point in the history
Version control tests, bug fix
  • Loading branch information
aerispaha authored Jun 19, 2019
2 parents fcda7db + 015bc23 commit 9889ec1
Show file tree
Hide file tree
Showing 10 changed files with 231 additions and 300 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SWMMIO
*v0.3.5.dev0*
*v0.3.5.dev1*

[![Build status](https://ci.appveyor.com/api/projects/status/qywujm5w2wm0y2tv/branch/master?svg=true)](https://ci.appveyor.com/project/aerispaha/swmmio/branch/master)
[![Build Status](https://travis-ci.com/aerispaha/swmmio.svg?branch=master)](https://travis-ci.com/aerispaha/swmmio)
Expand Down
209 changes: 0 additions & 209 deletions README.rst

This file was deleted.

2 changes: 1 addition & 1 deletion swmmio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
'''Python SWMM Input/Output Tools'''


VERSION_INFO = (0, 3, 5, 'dev0')
VERSION_INFO = (0, 3, 5, 'dev1')
__version__ = '.'.join(map(str, VERSION_INFO))
__author__ = 'Adam Erispaha'
__copyright__ = 'Copyright (c) 2016'
Expand Down
1 change: 1 addition & 0 deletions swmmio/tests/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
MODEL_XSECTION_ALT_02 = os.path.join(DATA_PATH, 'alt_test2.inp')
MODEL_XSECTION_ALT_03 = os.path.join(DATA_PATH, 'alt_test3.inp')
MODEL_BLANK = os.path.join(DATA_PATH, 'blank_model.inp')
BUILD_INSTR_01 = os.path.join(DATA_PATH, 'test_build_instructions_01.txt')

df_test_coordinates_csv = os.path.join(DATA_PATH, 'df_test_coordinates.csv')
OUTFALLS_MODIFIED = os.path.join(DATA_PATH, 'outfalls_modified_10.csv')
24 changes: 24 additions & 0 deletions swmmio/tests/data/test_build_instructions_01.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"Parent Models": {
"Baseline": {
"C:\\PROJECTCODE\\swmmio\\swmmio\\tests\\data\\baseline_test.inp": "18-10-12 18:11"
},
"Alternatives": {
"C:\\PROJECTCODE\\swmmio\\swmmio\\tests\\data\\alt_test3.inp": "18-10-12 18:11"
}
},
"Log": {
"test_version_id": "cool comments"
}
}
====================================================================================================

[JUNCTIONS]
;; InvertElev MaxDepth InitDepth SurchargeDepth PondedArea ; Comment Origin
dummy_node1 -15.0 30.0 0 0 0 ; Altered alt_test3.inp
dummy_node5 -6.96 15.0 0 0 73511 ; Altered alt_test3.inp

[CONDUITS]
;; InletNode OutletNode Length ManningN InletOffset OutletOffset InitFlow MaxFlow ; Comment Origin
pipe5 dummy_node6 dummy_node5 666 0.013000000000000001 0 0 0 0 ; Altered alt_test3.inp

36 changes: 34 additions & 2 deletions swmmio/tests/test_dataframes.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,41 @@
from swmmio.tests.data import (MODEL_FULL_FEATURES_PATH, MODEL_FULL_FEATURES__NET_PATH,
MODEL_BROWARD_COUNTY_PATH, MODEL_XSECTION_ALT_01, df_test_coordinates_csv,
MODEL_FULL_FEATURES_XY)
BUILD_INSTR_01, MODEL_XSECTION_ALT_01, df_test_coordinates_csv,
MODEL_FULL_FEATURES_XY, DATA_PATH)
import swmmio
from swmmio import create_dataframeINP
import pandas as pd
import pytest
import shutil
import os

def makedirs(newdir):
"""
replicate this in Py2 campatible way
os.makedirs(temp_vc_dir_02, exist_ok=True)
"""
if os.path.exists(newdir):
shutil.rmtree(newdir)
os.makedirs(newdir)


def test_create_dataframeBI():

# m = swmmio.Model(MODEL_BROWARD_COUNTY_PATH)
bi_juncs = swmmio.create_dataframeBI(BUILD_INSTR_01, section='[JUNCTIONS]')

assert bi_juncs.loc['dummy_node1', 'InvertElev'] == pytest.approx(-15, 0.01)
assert bi_juncs.loc['dummy_node5', 'InvertElev'] == pytest.approx(-6.96, 0.01)

# test with spaces in path
temp_dir_01 = os.path.join(DATA_PATH, 'path with spaces')
makedirs(temp_dir_01)
shutil.copy(BUILD_INSTR_01, temp_dir_01)
BUILD_INSTR_01_spaces = os.path.join(temp_dir_01, BUILD_INSTR_01)

bi_juncs = swmmio.create_dataframeBI(BUILD_INSTR_01_spaces, section='[JUNCTIONS]')
assert bi_juncs.loc['dummy_node1', 'InvertElev'] == pytest.approx(-15, 0.01)
assert bi_juncs.loc['dummy_node5', 'InvertElev'] == pytest.approx(-6.96, 0.01)
shutil.rmtree(temp_dir_01)


def test_create_dataframeRPT():
Expand Down
Loading

0 comments on commit 9889ec1

Please sign in to comment.