Skip to content

Commit

Permalink
Merge pull request #20 from sumannam/dev/DevOps
Browse files Browse the repository at this point in the history
I created a file (test_main.py) to distinguish between the main.py an…
  • Loading branch information
sumannam authored Dec 30, 2023
2 parents 919ddc7 + 55b7ba0 commit 0c31292
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 59 deletions.
10 changes: 10 additions & 0 deletions projects/simparc/conf.py → projects/simparc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
from pathlib import Path

PROJECT_NAME = "DEVS-Python"
TBASE_FOLDER = ""

if 'win' in sys.platform: # Windows
sys.path.append('D:/Git/DEVS-Python')
sys.path.append('D:/Git/DEVS-Python/projects/simparc')
TBASE_FOLDER = os.path.dirname(os.path.abspath(__file__)) + "\\tbase"
else: # Linux, Unix, MacOS
sys.path.append('.')
TBASE_FOLDER = os.path.dirname(os.path.abspath(__file__)) + "/tbase"


def setDevPath():
current_path = Path.cwd()
Expand Down
2 changes: 1 addition & 1 deletion projects/simparc/coupbase/EF_P.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys

from conf import setDevPath
from projects.simparc.config import setDevPath
setDevPath()

# from pypreprocessor import pypreprocessor
Expand Down
41 changes: 6 additions & 35 deletions projects/simparc/main.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,8 @@
import os
import sys
import time

sys.path.append('D:/Git/DEVS-Python')
sys.path.append('D:/Git/DEVS-Python/projects/simparc')

TBASE_FOLDER = os.path.dirname(os.path.abspath(__file__)) + "\\tbase"

from projects.simparc.mbase.IP import IP
from TEST_ATOMIC_MODELS import TEST_ATOMIC_MODELS

if __name__ == '__main__':
ip = IP()
model_test = TEST_ATOMIC_MODELS()

## 자동 테스트
# json_file = os.path.join(TBASE_FOLDER, 'ip_test_script.json')

# start = time.time()

# model_test.runAutoModelTest(ip, json_file)
# end = time.time()

# print(f"{end - start:.5f} sec")

## 수동 테스트
ip.modelTest(ip)

import config

# 시뮬레이션
# from projects.simparc.EF_P import EF_P
# if __name__ == '__main__':
# ef_p = EF_P()
# ef_p.initialize()
# ef_p.restart()

from projects.simparc.coupbase.EF_P import EF_P
if __name__ == '__main__':
ef_p = EF_P()
ef_p.initialize()
ef_p.restart()
24 changes: 24 additions & 0 deletions projects/simparc/test_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import os
import time

import config

from projects.simparc.mbase.IP import IP
from TEST_ATOMIC_MODELS import TEST_ATOMIC_MODELS

if __name__ == '__main__':
ip = IP()
model_test = TEST_ATOMIC_MODELS()

# 자동 테스트
json_file = os.path.join(config.TBASE_FOLDER, 'ip_test_script.json')

start = time.time()

model_test.runAutoModelTest(ip, json_file)
end = time.time()

print(f"{end - start:.5f} sec")

## 수동 테스트
# ip.modelTest(ip)
8 changes: 8 additions & 0 deletions test/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import os
import sys

if 'win' in sys.platform: # Windows
sys.path.append('D:/Git/DEVS-Python')
sys.path.append('D:/Git/DEVS-Python/projects/simparc')
else: # Linux, Unix, MacOS
sys.path.append('.')
4 changes: 2 additions & 2 deletions test/testEF_P.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

sys.path.append('D:/Git/DEVS-Python')

from projects.simparc.EF_P import EF_P
from projects.simparc.coupbase.EF_P import EF_P

class testEF_P(unittest.TestCase):
def setUp(self):
Expand All @@ -20,4 +20,4 @@ def testAddModels(self):

def testAddInteralCoupling(self):
coupling_list = self.ef_p.getInternalCoupling()
assert coupling_list.coupling_dic == {'EF.out': 'P.in', 'P.out': 'EF.in'}
assert coupling_list.coupling_dic == {'EF.out': ['P.in'], 'P.out': ['EF.in']}
4 changes: 2 additions & 2 deletions test/testPModelTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

sys.path.append('D:/Git/DEVS-Python')

from projects.simparc.P import P
from projects.simparc.mbase.P import P
from src.CONTENT import CONTENT

class testPModelTest(unittest.TestCase):
Expand Down Expand Up @@ -77,7 +77,7 @@ def test_modeltest_p_inject(self):

send_result = self.p.getInjectResult("inject")

assert send_result == "state s = (4 busy g1 5)"
assert send_result == "state s = (5 busy g1 5)"

if __name__ == '__main__':
start = time.time()
Expand Down
2 changes: 1 addition & 1 deletion test/testROOT_CO_ORDINATORS.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
sys.path.append('D:/Git/DEVS-Python')
sys.path.append('D:/Git/DEVS-Python/projects/simparc')

from projects.simparc.EF_P import EF_P
from projects.simparc.coupbase.EF_P import EF_P

class testROOT_CO_ORDINATORS(unittest.TestCase):
def setUp(self):
Expand Down
37 changes: 19 additions & 18 deletions test/test_basic.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
import sys
import unittest

sys.path.append('D:/Git/DEVS-Python')
import config

from testPModelTest import testPModelTest
# from testEF_P import testEF_P
# from testROOT_CO_ORDINATORS import testROOT_CO_ORDINATORS
# from testPModelTest import testPModelTest
from testEF_P import testEF_P
from testROOT_CO_ORDINATORS import testROOT_CO_ORDINATORS

# TO-DO : 테스트 실행 파일을 엔진과 모델 테스트로 분리할 것[Jira-DEVS-41]
if __name__ == '__main__':
test_p0 = unittest.TestLoader().loadTestsFromTestCase(testPModelTest)
test_p1 = unittest.TestLoader().loadTestsFromTestCase(testPModelTest)
test_p2 = unittest.TestLoader().loadTestsFromTestCase(testPModelTest)
test_p3 = unittest.TestLoader().loadTestsFromTestCase(testPModelTest)
test_p4 = unittest.TestLoader().loadTestsFromTestCase(testPModelTest)
# test_p0 = unittest.TestLoader().loadTestsFromTestCase(testPModelTest)
# test_p1 = unittest.TestLoader().loadTestsFromTestCase(testPModelTest)
# test_p2 = unittest.TestLoader().loadTestsFromTestCase(testPModelTest)
# test_p3 = unittest.TestLoader().loadTestsFromTestCase(testPModelTest)
# test_p4 = unittest.TestLoader().loadTestsFromTestCase(testPModelTest)
# test_p5 = unittest.TestLoader().loadTestsFromTestCase(testPModelTest)
# test_p6 = unittest.TestLoader().loadTestsFromTestCase(testPModelTest)
# test_p7 = unittest.TestLoader().loadTestsFromTestCase(testPModelTest)
# test_p8 = unittest.TestLoader().loadTestsFromTestCase(testPModelTest)
# test_p9 = unittest.TestLoader().loadTestsFromTestCase(testPModelTest)
# test_efp = unittest.TestLoader().loadTestsFromTestCase(testEF_P)
# test_root_coordinators = unittest.TestLoader().loadTestsFromTestCase(testROOT_CO_ORDINATORS)
test_efp = unittest.TestLoader().loadTestsFromTestCase(testEF_P)
test_root_coordinators = unittest.TestLoader().loadTestsFromTestCase(testROOT_CO_ORDINATORS)

allTests = unittest.TestSuite()
allTests.addTest(test_p0)
allTests.addTest(test_p1)
allTests.addTest(test_p2)
allTests.addTest(test_p3)
allTests.addTest(test_p4)
# allTests.addTest(test_p0)
# allTests.addTest(test_p1)
# allTests.addTest(test_p2)
# allTests.addTest(test_p3)
# allTests.addTest(test_p4)
# allTests.addTest(test_p5)
# allTests.addTest(test_p6)
# allTests.addTest(test_p7)
# allTests.addTest(test_p8)
# allTests.addTest(test_p9)
# allTests.addTest(test_efp)
# allTests.addTest(test_root_coordinators)
allTests.addTest(test_efp)
allTests.addTest(test_root_coordinators)

unittest.TextTestRunner(verbosity=2, failfast=True).run(allTests)

0 comments on commit 0c31292

Please sign in to comment.