-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathtest_UnifiedCleaner.py
More file actions
45 lines (38 loc) · 1.76 KB
/
test_UnifiedCleaner.py
File metadata and controls
45 lines (38 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
##############################################################################
# Developed by: Matthew Bone
# Last Updated: 30/07/2021
# Updated by: Matthew Bone
#
# Contact Details:
# Bristol Composites Institute (BCI)
# Department of Aerospace Engineering - University of Bristol
# Queen's Building - University Walk
# Bristol, BS8 1TR
# U.K.
# Email - matthew.bone@bristol.ac.uk
#
# File Description:
# A unit test file designed for PyTest. This tests the clean function is capable
# of unifying two data files and cutting down a coefficient file.
##############################################################################
import os
from LammpsUnifiedCleaner import file_unifier
from LammpsTreatmentFuncs import clean_data
from LammpsSearchFuncs import get_data, find_sections
def test_unified_cleaner():
path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'Test_Cases/Cleaner/Methane_Ethane/') # Allows for relative pathing in pytest
file_unifier(path, 'system.in.settings', ['pre-system.data', 'post-system.data'])
# Load cleaned pre-system
with open('cleanedpre-system.data', 'r') as f:
data = f.readlines()
data = clean_data(data)
sectionIndex = find_sections(data)
atoms = get_data('Atoms', data, sectionIndex)
matchAtomsCount = int(data[1].split()[0]) == len(atoms)
# Load cleaned settings
with open('cleanedsystem.in.settings', 'r') as f:
settings = f.readlines()
# Number of coeffs, number of sections (+1 for end of file), last section name, number of bond coeffs, number of atoms in header and number in Atoms section
checkValues = [len(settings), len(sectionIndex), data[sectionIndex[-2]], int(data[7][0]), matchAtomsCount]
expected = [8, 5, 'Angles', 3, True]
assert checkValues == expected