aktueller Stand mit zwei Frames die beschickt werden können
This commit is contained in:
@@ -0,0 +1,452 @@
|
||||
import unittest
|
||||
import os
|
||||
|
||||
import manage_configs
|
||||
|
||||
|
||||
class TestTOSGroupsFromLocalConfigs(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.config_dir = os.environ.get('CREMIG_CFG')
|
||||
|
||||
def test_get_keywords_of_level_from_local_file(self):
|
||||
"""
|
||||
Test whether the extraction of the different TOS Level works
|
||||
loaded from local config and environment variable
|
||||
if config is changed, test will fail
|
||||
"""
|
||||
|
||||
TOS_CFG = manage_configs.TOSGroupsConfig(self.config_dir)
|
||||
allKeywords = TOS_CFG.get_all_keywords()
|
||||
|
||||
result = ['TOS_Schoenenberger_Produkt', 'TOS_Automation', 'TOS_Maschinenelement', 'TOS_Schoenenberger_Komponenten', 'TOS_Pneumatik', 'TOS_Konfig']
|
||||
level1 = TOS_CFG.get_keywords_of_level(allKeywords, 1)
|
||||
self.assertCountEqual(level1, result)
|
||||
|
||||
def test_get_all_keywords_from_local_file(self):
|
||||
"""
|
||||
Test whether the extraction of the different TOS Level works
|
||||
loaded from local config and environment variable
|
||||
if config is changed, test will fail
|
||||
"""
|
||||
|
||||
TOS_CFG = manage_configs.TOSGroupsConfig(self.config_dir)
|
||||
|
||||
allKeywords = TOS_CFG.get_all_keywords()
|
||||
|
||||
result = {'TOS-Gruppe': 0,
|
||||
'TOS_Schoenenberger_Produkt': 1,
|
||||
'TOS_Automation': 1,
|
||||
'TOS_Maschinenelement': 1,
|
||||
'TOS_Schoenenberger_Komponenten': 1,
|
||||
'TOS_Pneumatik': 1,
|
||||
'TOS_Konfig': 1,
|
||||
'TOS_ILS': 2,
|
||||
'TOS_MAS': 2,
|
||||
'TOS_Spinnereikomponente': 2,
|
||||
'TOS_Betriebsmittel': 2,
|
||||
'TOS_Geruest': 2,
|
||||
'TOS_FremdTransport': 2,
|
||||
'TOS_MAS_Konfig': 2,
|
||||
'TOS_ILS_2': 3,
|
||||
'TOS_ILS_Foerderer': 3,
|
||||
'TOS_Trolley': 3,
|
||||
'TOS_Trolley_Projekte': 3,
|
||||
'TOS_Trolley_Omniflo': 4,
|
||||
'TOS_Trolley_Spinnerei': 4,
|
||||
'TOS_Trolley_ILS': 4,
|
||||
'TOS_Schaltschrank': 2,
|
||||
'TOS_Schalt_Einbau': 2,
|
||||
'TOS_Dezentral': 2,
|
||||
'TOS_Automation_Sensorik': 2,
|
||||
'TOS_Kabel': 2,
|
||||
'TOS_Installation': 2,
|
||||
'TOS_Automation_Sonstiges': 2,
|
||||
'TOS_Verbindungselement': 2,
|
||||
'TOS_Lager': 2,
|
||||
'TOS_Kraft_Drehmoment': 2,
|
||||
'TOS_Sicherungselement': 2,
|
||||
'TOS_Bedienungselement': 2}
|
||||
self.assertCountEqual(allKeywords, result)
|
||||
|
||||
class TestTOSGroupsGeneral(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
||||
self.tos_test_str = """
|
||||
{
|
||||
"root": "TOS-Gruppe",
|
||||
"TOS-Gruppe": {
|
||||
"TOS-level": 1,
|
||||
"children": {
|
||||
"0": "Intern/Referenzgruppe",
|
||||
"1": "Halbzeug",
|
||||
"2": "Verkaufsprodukte",
|
||||
"3": "Schönenberger Produkte",
|
||||
"4": "Automation",
|
||||
"5": "Maschinenelement",
|
||||
"6": "Schönenberger Komponenten",
|
||||
"7": "Pneumatik",
|
||||
"8": "Konfiguration",
|
||||
"9": "."
|
||||
},
|
||||
"reference-ids": {
|
||||
"0": "TOS_Intern_Ref",
|
||||
"1": "TOS_Halbzeug",
|
||||
"2": "TOS_Verkaufsprodukte",
|
||||
"3": "TOS_Schoenenberger_Produkt",
|
||||
"4": "TOS_Automation",
|
||||
"5": "TOS_Maschinenelement",
|
||||
"6": "TOS_Schoenenberger_Komponenten",
|
||||
"7": "TOS_Pneumatik",
|
||||
"8": "TOS_Konfig"
|
||||
}
|
||||
},
|
||||
"TOS_Schoenenberger_Produkt": {
|
||||
"TOS-level": 2,
|
||||
"children": {
|
||||
"30": "ILS IntraLogistikSystem",
|
||||
"31": "MAS Mittenabgehängtes System - OMNIFLO",
|
||||
"32": "Spinnereikomponente",
|
||||
"33": "Betriebsmittel",
|
||||
"34": "Gerüst",
|
||||
"35": "Fremd-Transportsysteme & SSG-Anbauten",
|
||||
"36": "Förderer MAS aktuell Konfiguration",
|
||||
"37": "Frei",
|
||||
"38": "CAD-Übernahme Weiche",
|
||||
"39": "Farbe"
|
||||
},
|
||||
"reference-ids": {
|
||||
"30": "TOS_ILS",
|
||||
"31": "TOS_MAS",
|
||||
"32": "TOS_Spinnereikomponente",
|
||||
"33": "TOS_Betriebsmittel",
|
||||
"34": "TOS_Geruest",
|
||||
"35": "TOS_FremdTransport",
|
||||
"36": "TOS_MAS_Konfig"
|
||||
}
|
||||
},
|
||||
"TOS_ILS": {
|
||||
"TOS-level": 3,
|
||||
"children": {
|
||||
"300": "ILS 2.0",
|
||||
"301": "ILS 3.0",
|
||||
"302": "Förderer"
|
||||
},
|
||||
"reference-ids": {
|
||||
"300": "TOS_ILS_2",
|
||||
"302": "TOS_ILS_Foerderer"
|
||||
}
|
||||
},
|
||||
"TOS_MAS": {
|
||||
"TOS-level": 3,
|
||||
"children": {
|
||||
"310": "Fahrstrecke",
|
||||
"311": "Ein- und Anbaugruppe für Omniflo System",
|
||||
"312": "Verbinder und Kleinteil",
|
||||
"313": "Baugruppe für Aktionen an/mit Trolleys",
|
||||
"314": "Förderer"
|
||||
},
|
||||
"reference-ids": {
|
||||
"310": "TOS_MAS_Fahrstecke"
|
||||
}
|
||||
},
|
||||
"TOS_Spinnereikomponente": {
|
||||
"TOS-level": 3,
|
||||
"children": {
|
||||
"320": "Hülsenreiniger automatisch",
|
||||
"321": "Hülsenreiniger manuell",
|
||||
"322": "Reibradantrieb RA"
|
||||
},
|
||||
"reference-ids": {}
|
||||
},
|
||||
"TOS_Betriebsmittel": {
|
||||
"TOS-level": 3,
|
||||
"children": {
|
||||
"330": "Trolley Standard",
|
||||
"331": "Trolley Projekte"
|
||||
},
|
||||
"reference-ids": {
|
||||
"330": "TOS_Trolley",
|
||||
"331": "TOS_Trolley_Projekte"
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
def test_get_keywords_of_level_from_string(self):
|
||||
"""
|
||||
Test whether the extraction of the different TOS Level works
|
||||
loaded from local config and environment variable
|
||||
"""
|
||||
|
||||
TOS_CFG = manage_configs.TOSGroupsConfig()
|
||||
TOS_CFG.from_json(self.tos_test_str)
|
||||
allKeywords = TOS_CFG.get_all_keywords()
|
||||
|
||||
level0 = TOS_CFG.get_keywords_of_level(allKeywords, 0)
|
||||
self.assertCountEqual(level0, ["TOS-Gruppe"])
|
||||
level1 = TOS_CFG.get_keywords_of_level(allKeywords, 1)
|
||||
self.assertCountEqual(level1, ["TOS_Schoenenberger_Produkt"])
|
||||
level2 = TOS_CFG.get_keywords_of_level(allKeywords, 2)
|
||||
self.assertCountEqual(level2, ["TOS_ILS", "TOS_MAS", "TOS_Spinnereikomponente", "TOS_Betriebsmittel"])
|
||||
|
||||
def test_get_all_keywords_from_string(self):
|
||||
"""
|
||||
Test whether the extraction of the different TOS Level works
|
||||
loaded from local config and environment variable
|
||||
"""
|
||||
|
||||
TOS_CFG = manage_configs.TOSGroupsConfig()
|
||||
TOS_CFG.from_json(self.tos_test_str)
|
||||
|
||||
allKeywords = TOS_CFG.get_all_keywords()
|
||||
|
||||
result = {'TOS-Gruppe': 0,
|
||||
'TOS_Schoenenberger_Produkt': 1,
|
||||
'TOS_ILS': 2,
|
||||
'TOS_MAS': 2,
|
||||
'TOS_Spinnereikomponente': 2,
|
||||
'TOS_Betriebsmittel': 2}
|
||||
self.assertCountEqual(allKeywords, result)
|
||||
|
||||
class TestMaterialien(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
||||
self.materials_str = """
|
||||
{
|
||||
"1.4301": {
|
||||
"Werkstoff": "1.4301 (X5CrNi18-10)",
|
||||
"Werkstofftyp": "Stahl"
|
||||
},
|
||||
"1.4305": {
|
||||
"Werkstoff": "1.4305 (X8CrNiS18-9)",
|
||||
"Werkstofftyp": "Stahl"
|
||||
},
|
||||
"1.4305 / 671": {
|
||||
"Werkstoff": "1.4305 (X8CrNiS18-9)",
|
||||
"Werkstofftyp": "Stahl"
|
||||
},
|
||||
"PA6 GF30": {
|
||||
"Werkstoff": "PA 6 GF 30",
|
||||
"Werkstofftyp": "Kunst-/ Verbundstoff",
|
||||
"Oberfläche": "Masterbatch (Grundfarbe)"
|
||||
},
|
||||
"S235JR galv. verzinkt Fe/Zn 8-15 B": {
|
||||
"Werkstoff": "1.0038 (S235JR) ",
|
||||
"Werkstofftyp": "Stahl",
|
||||
"Oberfläche": "verzinken"
|
||||
},
|
||||
"VA": {
|
||||
"Werkstoff": "false",
|
||||
"Message": "individuell nach Verwendungszweck anhand von Stahlschlüssel anpassen"
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
def test_get_all_materials_from_string(self):
|
||||
"""
|
||||
Test whether all materials are found
|
||||
"""
|
||||
|
||||
TOS_CFG = manage_configs.MaterialTransConfig()
|
||||
TOS_CFG.from_json(self.materials_str)
|
||||
|
||||
allMaterials = TOS_CFG.get_all_materials()
|
||||
|
||||
result = ["1.4301", "1.4305", "1.4305 / 671", "PA6 GF30", "S235JR galv. verzinkt Fe/Zn 8-15 B", "VA"]
|
||||
self.assertCountEqual(allMaterials, result)
|
||||
|
||||
def test_get_material_of_type(self):
|
||||
"""
|
||||
Test whether material of steel, etc. is found
|
||||
"""
|
||||
|
||||
TOS_CFG = manage_configs.MaterialTransConfig()
|
||||
TOS_CFG.from_json(self.materials_str)
|
||||
|
||||
content = TOS_CFG.get_material_of_type("1.4301")
|
||||
self.assertCountEqual(content, { 'Werkstoff': '1.4301 (X5CrNi18-10)', 'Werkstofftyp': 'Stahl'})
|
||||
|
||||
content = TOS_CFG.get_material_of_type("VA")
|
||||
self.assertCountEqual(content, {"Werkstoff": "false", "Message": "individuell nach Verwendungszweck anhand von Stahlschlüssel anpassen"})
|
||||
|
||||
|
||||
class TestWerkstoffeFromLocalConfigs(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.config_dir = os.environ.get('CREMIG_CFG')
|
||||
|
||||
def test_get_wkstoffe_of_type(self):
|
||||
"""
|
||||
get list of steels, aluminum, etc.
|
||||
"""
|
||||
|
||||
WKST_CFG = manage_configs.WerkstoffeConfig(self.config_dir, 'Werkstoff.cfg')
|
||||
|
||||
steels = WKST_CFG.get_werkstoffe_of_name("Stahl")
|
||||
result = ['1.0035 (S185)', '1.0038 (S235JR)', '1.0122 (S235JRC)',
|
||||
'1.0122+C (S235JRC+C)', '1.0330 (DC01)', '1.0401 (C15)',
|
||||
'1.0501 (C35)', '1.0503 (C45)', '1.0503+N (C45+N)',
|
||||
'1.0553 (S355J0)', '1.0577 (S355J2)', '1.0711 (9S20)',
|
||||
'1.0715 (11SMn30)', '1.0715+C (11SMn30+C)', '1.0917 (DX51D+Z)',
|
||||
'1.1191 (C45E)', '1.2842 (90MnCrV8)', '1.4035 (X45CrS13)',
|
||||
'1.4301 (X5CrNi18-10)', '1.4305 (X8CrNiS18-9)',
|
||||
'1.4310 (X10CrNi18-8)', '1.5023 (38Si7)', '1.7131 (16MnCr5)',
|
||||
'siehe Hersteller' ]
|
||||
self.assertCountEqual(steels, result)
|
||||
|
||||
steels = WKST_CFG.get_werkstoffe_of_name("Aluminium")
|
||||
result = [ "EN AW-1050A (3.0255)", "EN AW-2007 (3.1645)", "EN AW-2014-T3 (3.1255-T3)",
|
||||
"EN AW-2014-T4 (3.1255-T4)", "EN AW-6060 (3.3206)",
|
||||
"EN AW-6060-T66 (3.3206-T66)", "EN AW-7075 (3.4365)",
|
||||
"EN AW-6063-T66", 'siehe Hersteller' ]
|
||||
self.assertCountEqual(steels, result)
|
||||
|
||||
class TestWerkstoffe(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
||||
self.wkstoffe = """
|
||||
[Werkstofftyp]
|
||||
Stahl
|
||||
Aluminium
|
||||
Kunst-/ Verbundstoff
|
||||
Schwermetall
|
||||
Festigkeitsklasse
|
||||
siehe Hersteller
|
||||
|
||||
[Stahl]
|
||||
1.0035 (S185)
|
||||
1.0038 (S235JR)
|
||||
1.0122 (S235JRC)
|
||||
1.0122+C (S235JRC+C)
|
||||
1.0330 (DC01)
|
||||
1.0401 (C15)
|
||||
1.0501 (C35)
|
||||
1.0503 (C45)
|
||||
1.0503+N (C45+N)
|
||||
siehe Hersteller
|
||||
|
||||
[Aluminium]
|
||||
EN AW-1050A (3.0255)
|
||||
EN AW-2007 (3.1645)
|
||||
EN AW-2014-T3 (3.1255-T3)
|
||||
EN AW-7075 (3.4365)
|
||||
EN AW-6063-T66
|
||||
siehe Hersteller
|
||||
|
||||
[Kunst-/ Verbundstoff]
|
||||
ABS
|
||||
ASA
|
||||
CR/SBR-A65
|
||||
Hostaform 13031 MB1.5
|
||||
Irogran A87
|
||||
Murtfeldt "S" 1000
|
||||
PA
|
||||
PA 2200
|
||||
PA 2200 SLS
|
||||
POM
|
||||
POM-C
|
||||
POM-H
|
||||
siehe Hersteller
|
||||
"""
|
||||
|
||||
def test_get_wkstoffe_of_type(self):
|
||||
"""
|
||||
get list of steels
|
||||
"""
|
||||
|
||||
WKST_CFG = manage_configs.WerkstoffeConfig()
|
||||
WKST_CFG.from_cfg_str(self.wkstoffe)
|
||||
|
||||
steels = WKST_CFG.get_werkstoffe_of_name("Stahl")
|
||||
|
||||
result = ["1.0035 (S185)", "1.0038 (S235JR)", "1.0122 (S235JRC)",
|
||||
"1.0122+C (S235JRC+C)", "1.0330 (DC01)", "1.0401 (C15)", "1.0501 (C35)",
|
||||
"1.0503 (C45)", "1.0503+N (C45+N)", "siehe Hersteller"]
|
||||
self.assertCountEqual(steels, result)
|
||||
|
||||
class TestAllgmein(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
||||
self.allgemein = """
|
||||
|
||||
[Kategorien]
|
||||
Baugruppe
|
||||
Einzelteil
|
||||
Kaufteil
|
||||
NichtSivas
|
||||
Normteil
|
||||
Schweissbaugruppe
|
||||
|
||||
[Dispogruppe]
|
||||
Fahrstrecke=10
|
||||
Förderer=20
|
||||
Gerüst=30
|
||||
Betriebsmittel=40
|
||||
Automation=50
|
||||
Kleinteil=60
|
||||
Rohmaterial=70
|
||||
Sonstiges Intern=80
|
||||
Baustelleneinrichtung=90
|
||||
Sonderkonstruktionen=100
|
||||
|
||||
[Dispolaufgruppe]
|
||||
Omniflo=10
|
||||
Intra Logistic System + alt-HFS=20
|
||||
Fremd-Transportsysteme + SSG-Anbauten=30
|
||||
Spinnereikomponente=40
|
||||
Automotiv=45
|
||||
Nicht eindeutig, Sonder=50
|
||||
|
||||
[Kalkulationsart]
|
||||
Eigenbau
|
||||
Kaufteil
|
||||
Mischteil
|
||||
"""
|
||||
|
||||
def test_get_allgmein(self):
|
||||
"""
|
||||
get list of sections in allgmein
|
||||
"""
|
||||
|
||||
ALLG_CFG = manage_configs.AllgmeinConfig()
|
||||
ALLG_CFG.from_cfg_str(self.allgemein)
|
||||
|
||||
allg_secs = ALLG_CFG.get_sections()
|
||||
result = ['Kategorien', 'Dispogruppe', 'Dispolaufgruppe', 'Kalkulationsart']
|
||||
self.assertCountEqual(allg_secs, result)
|
||||
|
||||
opts = ALLG_CFG.get_options('Kalkulationsart')
|
||||
result = ['Eigenbau', 'Kaufteil', 'Mischteil']
|
||||
self.assertCountEqual(opts, result)
|
||||
|
||||
opts = ALLG_CFG.get_options('Dispolaufgruppe')
|
||||
result = ['Omniflo', 'Intra Logistic System + alt-HFS',
|
||||
'Fremd-Transportsysteme + SSG-Anbauten',
|
||||
'Spinnereikomponente', 'Automotiv', "Nicht eindeutig, Sonder"]
|
||||
self.assertCountEqual(opts, result)
|
||||
|
||||
val = ALLG_CFG.get_int('Dispolaufgruppe', 'Omniflo')
|
||||
self.assertEqual(val, 10)
|
||||
|
||||
dint = ALLG_CFG.get_dict('Dispogruppe')
|
||||
res = { 'Fahrstrecke':10,
|
||||
'Förderer':20,
|
||||
'Gerüst':30,
|
||||
'Betriebsmittel':40,
|
||||
'Automation':50,
|
||||
'Kleinteil':60,
|
||||
'Rohmaterial':70,
|
||||
'Sonstiges Intern':80,
|
||||
'Baustelleneinrichtung':90,
|
||||
'Sonderkonstruktionen':100,
|
||||
}
|
||||
self.assertCountEqual(dint, res)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user