mirror of
https://github.com/fhswf/aki_prj23_transparenzregister.git
synced 2025-05-13 12:58:45 +02:00
Added Tests
Co-authored-by: Tristan Nolde <TrisNol@users.noreply.github.com>
This commit is contained in:
parent
410b690873
commit
e5769b3c25
@ -20,7 +20,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 37,
|
"execution_count": 5,
|
||||||
"id": "b6eea59adeae27d4",
|
"id": "b6eea59adeae27d4",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"ExecuteTime": {
|
"ExecuteTime": {
|
||||||
@ -36,7 +36,7 @@
|
|||||||
"'c:\\\\Users\\\\trimr\\\\Projekte\\\\aki_prj23_transparenzregister'"
|
"'c:\\\\Users\\\\trimr\\\\Projekte\\\\aki_prj23_transparenzregister'"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 37,
|
"execution_count": 5,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "execute_result"
|
"output_type": "execute_result"
|
||||||
}
|
}
|
||||||
@ -53,7 +53,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 38,
|
"execution_count": 6,
|
||||||
"id": "eb9498d3",
|
"id": "eb9498d3",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
@ -71,7 +71,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 39,
|
"execution_count": 7,
|
||||||
"id": "6a317af6",
|
"id": "6a317af6",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
@ -92,7 +92,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 40,
|
"execution_count": 8,
|
||||||
"id": "2d17651a",
|
"id": "2d17651a",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@ -102,7 +102,7 @@
|
|||||||
"'SELECT to_company.id AS id_company_to, to_company.name AS name_company_to, relation.relation AS relation_type, from_company.name AS name_company_from, from_company.id AS id_company_from \\nFROM company AS to_company JOIN (relation JOIN company_relation ON relation.id = company_relation.id) ON relation.company_id = to_company.id JOIN company AS from_company ON company_relation.company2_id = from_company.id'"
|
"'SELECT to_company.id AS id_company_to, to_company.name AS name_company_to, relation.relation AS relation_type, from_company.name AS name_company_from, from_company.id AS id_company_from \\nFROM company AS to_company JOIN (relation JOIN company_relation ON relation.id = company_relation.id) ON relation.company_id = to_company.id JOIN company AS from_company ON company_relation.company2_id = from_company.id'"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 40,
|
"execution_count": 8,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "execute_result"
|
"output_type": "execute_result"
|
||||||
}
|
}
|
||||||
@ -150,183 +150,48 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 42,
|
"execution_count": 12,
|
||||||
"id": "444cd402",
|
"id": "444cd402",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"text/html": [
|
|
||||||
"<div>\n",
|
|
||||||
"<style scoped>\n",
|
|
||||||
" .dataframe tbody tr th:only-of-type {\n",
|
|
||||||
" vertical-align: middle;\n",
|
|
||||||
" }\n",
|
|
||||||
"\n",
|
|
||||||
" .dataframe tbody tr th {\n",
|
|
||||||
" vertical-align: top;\n",
|
|
||||||
" }\n",
|
|
||||||
"\n",
|
|
||||||
" .dataframe thead th {\n",
|
|
||||||
" text-align: right;\n",
|
|
||||||
" }\n",
|
|
||||||
"</style>\n",
|
|
||||||
"<table border=\"1\" class=\"dataframe\">\n",
|
|
||||||
" <thead>\n",
|
|
||||||
" <tr style=\"text-align: right;\">\n",
|
|
||||||
" <th></th>\n",
|
|
||||||
" <th>id_company_to</th>\n",
|
|
||||||
" <th>name_company_to</th>\n",
|
|
||||||
" <th>relation_type</th>\n",
|
|
||||||
" <th>name_company_from</th>\n",
|
|
||||||
" <th>id_company_from</th>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" </thead>\n",
|
|
||||||
" <tbody>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>0</th>\n",
|
|
||||||
" <td>5</td>\n",
|
|
||||||
" <td>2. Schaper Objekt GmbH & Co. Kiel KG</td>\n",
|
|
||||||
" <td>KOMMANDITIST</td>\n",
|
|
||||||
" <td>Multi-Center Warenvertriebs GmbH</td>\n",
|
|
||||||
" <td>2213</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>1</th>\n",
|
|
||||||
" <td>32</td>\n",
|
|
||||||
" <td>Alb-Windkraft GmbH & Co. KG</td>\n",
|
|
||||||
" <td>KOMMANDITIST</td>\n",
|
|
||||||
" <td>EnBW Windkraftprojekte GmbH</td>\n",
|
|
||||||
" <td>845</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>2</th>\n",
|
|
||||||
" <td>34</td>\n",
|
|
||||||
" <td>Anneliese Köster GmbH & Co. KG</td>\n",
|
|
||||||
" <td>KOMMANDITIST</td>\n",
|
|
||||||
" <td>INDUS Holding Aktiengesellschaft</td>\n",
|
|
||||||
" <td>1903</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>3</th>\n",
|
|
||||||
" <td>74</td>\n",
|
|
||||||
" <td>AURELIUS Equity Opportunities SE & Co. KGaA</td>\n",
|
|
||||||
" <td>HAFTENDER_GESELLSCHAFTER</td>\n",
|
|
||||||
" <td>AURELIUS Management SE</td>\n",
|
|
||||||
" <td>163</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>4</th>\n",
|
|
||||||
" <td>77</td>\n",
|
|
||||||
" <td>Aurelius KG</td>\n",
|
|
||||||
" <td>HAFTENDER_GESELLSCHAFTER</td>\n",
|
|
||||||
" <td>Aurelius Verwaltungs GmbH</td>\n",
|
|
||||||
" <td>80</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>...</th>\n",
|
|
||||||
" <td>...</td>\n",
|
|
||||||
" <td>...</td>\n",
|
|
||||||
" <td>...</td>\n",
|
|
||||||
" <td>...</td>\n",
|
|
||||||
" <td>...</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>573</th>\n",
|
|
||||||
" <td>3137</td>\n",
|
|
||||||
" <td>Zalando BTD 011 SE & Co. KG</td>\n",
|
|
||||||
" <td>HAFTENDER_GESELLSCHAFTER</td>\n",
|
|
||||||
" <td>Zalando SE</td>\n",
|
|
||||||
" <td>3112</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>574</th>\n",
|
|
||||||
" <td>3137</td>\n",
|
|
||||||
" <td>Zalando BTD 011 SE & Co. KG</td>\n",
|
|
||||||
" <td>KOMMANDITIST</td>\n",
|
|
||||||
" <td>Zalando Operations GmbH</td>\n",
|
|
||||||
" <td>3103</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>575</th>\n",
|
|
||||||
" <td>3138</td>\n",
|
|
||||||
" <td>zLabels Creation & Sales GmbH & Co. KG</td>\n",
|
|
||||||
" <td>HAFTENDER_GESELLSCHAFTER</td>\n",
|
|
||||||
" <td>zLabels GmbH</td>\n",
|
|
||||||
" <td>3113</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>576</th>\n",
|
|
||||||
" <td>3145</td>\n",
|
|
||||||
" <td>Zalando Customer Care International SE & Co. KG</td>\n",
|
|
||||||
" <td>HAFTENDER_GESELLSCHAFTER</td>\n",
|
|
||||||
" <td>Zalando SE</td>\n",
|
|
||||||
" <td>3112</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>577</th>\n",
|
|
||||||
" <td>3145</td>\n",
|
|
||||||
" <td>Zalando Customer Care International SE & Co. KG</td>\n",
|
|
||||||
" <td>KOMMANDITIST</td>\n",
|
|
||||||
" <td>Zalando Operations GmbH</td>\n",
|
|
||||||
" <td>3103</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" </tbody>\n",
|
|
||||||
"</table>\n",
|
|
||||||
"<p>578 rows × 5 columns</p>\n",
|
|
||||||
"</div>"
|
|
||||||
],
|
|
||||||
"text/plain": [
|
"text/plain": [
|
||||||
" id_company_to name_company_to \\\n",
|
"[{'id_company_to': 2,\n",
|
||||||
"0 5 2. Schaper Objekt GmbH & Co. Kiel KG \n",
|
" 'name_company_to': '1. Staiger Grundstücksverwaltung GmbH & Co. KG',\n",
|
||||||
"1 32 Alb-Windkraft GmbH & Co. KG \n",
|
" 'relation_type': 'HAFTENDER_GESELLSCHAFTER',\n",
|
||||||
"2 34 Anneliese Köster GmbH & Co. KG \n",
|
" 'name_company_from': 'Staiger I. Verwaltung-GmbH',\n",
|
||||||
"3 74 AURELIUS Equity Opportunities SE & Co. KGaA \n",
|
" 'id_company_from': 3226},\n",
|
||||||
"4 77 Aurelius KG \n",
|
" {'id_company_to': 3,\n",
|
||||||
".. ... ... \n",
|
" 'name_company_to': '1 A Autenrieth Kunststofftechnik GmbH & Co. KG',\n",
|
||||||
"573 3137 Zalando BTD 011 SE & Co. KG \n",
|
" 'relation_type': 'HAFTENDER_GESELLSCHAFTER',\n",
|
||||||
"574 3137 Zalando BTD 011 SE & Co. KG \n",
|
" 'name_company_from': 'Autenrieth Verwaltungs-GmbH',\n",
|
||||||
"575 3138 zLabels Creation & Sales GmbH & Co. KG \n",
|
" 'id_company_from': 3324},\n",
|
||||||
"576 3145 Zalando Customer Care International SE & Co. KG \n",
|
" {'id_company_to': 5,\n",
|
||||||
"577 3145 Zalando Customer Care International SE & Co. KG \n",
|
" 'name_company_to': '2. Schaper Objekt GmbH & Co. Kiel KG',\n",
|
||||||
"\n",
|
" 'relation_type': 'KOMMANDITIST',\n",
|
||||||
" relation_type name_company_from \\\n",
|
" 'name_company_from': 'Multi-Center Warenvertriebs GmbH',\n",
|
||||||
"0 KOMMANDITIST Multi-Center Warenvertriebs GmbH \n",
|
" 'id_company_from': 2213},\n",
|
||||||
"1 KOMMANDITIST EnBW Windkraftprojekte GmbH \n",
|
" {'id_company_to': 6,\n",
|
||||||
"2 KOMMANDITIST INDUS Holding Aktiengesellschaft \n",
|
" 'name_company_to': 'AASP Filmproduktionsgesellschaft mbH & Co. Leonie KG',\n",
|
||||||
"3 HAFTENDER_GESELLSCHAFTER AURELIUS Management SE \n",
|
" 'relation_type': 'INHABER',\n",
|
||||||
"4 HAFTENDER_GESELLSCHAFTER Aurelius Verwaltungs GmbH \n",
|
" 'name_company_from': 'ABN AMRO Structured Products Gesellschaft für Fondsbeteiligungen mbH',\n",
|
||||||
".. ... ... \n",
|
" 'id_company_from': 3332},\n",
|
||||||
"573 HAFTENDER_GESELLSCHAFTER Zalando SE \n",
|
" {'id_company_to': 6,\n",
|
||||||
"574 KOMMANDITIST Zalando Operations GmbH \n",
|
" 'name_company_to': 'AASP Filmproduktionsgesellschaft mbH & Co. Leonie KG',\n",
|
||||||
"575 HAFTENDER_GESELLSCHAFTER zLabels GmbH \n",
|
" 'relation_type': 'KOMMANDITIST',\n",
|
||||||
"576 HAFTENDER_GESELLSCHAFTER Zalando SE \n",
|
" 'name_company_from': 'Kallang GmbH',\n",
|
||||||
"577 KOMMANDITIST Zalando Operations GmbH \n",
|
" 'id_company_from': 3316}]"
|
||||||
"\n",
|
|
||||||
" id_company_from \n",
|
|
||||||
"0 2213 \n",
|
|
||||||
"1 845 \n",
|
|
||||||
"2 1903 \n",
|
|
||||||
"3 163 \n",
|
|
||||||
"4 80 \n",
|
|
||||||
".. ... \n",
|
|
||||||
"573 3112 \n",
|
|
||||||
"574 3103 \n",
|
|
||||||
"575 3113 \n",
|
|
||||||
"576 3112 \n",
|
|
||||||
"577 3103 \n",
|
|
||||||
"\n",
|
|
||||||
"[578 rows x 5 columns]"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 42,
|
"execution_count": 12,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "execute_result"
|
"output_type": "execute_result"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"company_relations = pd.read_sql_query(str(relations_company_query), session.bind)\n",
|
"company_relations = pd.read_sql_query(str(relations_company_query), session.bind)\n",
|
||||||
"company_relations"
|
"company_relations.head().to_dict(orient=\"records\")"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -339,7 +204,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 43,
|
"execution_count": 14,
|
||||||
"id": "52af1d30",
|
"id": "52af1d30",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
@ -385,194 +250,58 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 45,
|
"execution_count": 15,
|
||||||
"id": "c78b3e65",
|
"id": "c78b3e65",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"text/html": [
|
|
||||||
"<div>\n",
|
|
||||||
"<style scoped>\n",
|
|
||||||
" .dataframe tbody tr th:only-of-type {\n",
|
|
||||||
" vertical-align: middle;\n",
|
|
||||||
" }\n",
|
|
||||||
"\n",
|
|
||||||
" .dataframe tbody tr th {\n",
|
|
||||||
" vertical-align: top;\n",
|
|
||||||
" }\n",
|
|
||||||
"\n",
|
|
||||||
" .dataframe thead th {\n",
|
|
||||||
" text-align: right;\n",
|
|
||||||
" }\n",
|
|
||||||
"</style>\n",
|
|
||||||
"<table border=\"1\" class=\"dataframe\">\n",
|
|
||||||
" <thead>\n",
|
|
||||||
" <tr style=\"text-align: right;\">\n",
|
|
||||||
" <th></th>\n",
|
|
||||||
" <th>id_company</th>\n",
|
|
||||||
" <th>name_company</th>\n",
|
|
||||||
" <th>relation_type</th>\n",
|
|
||||||
" <th>id_person</th>\n",
|
|
||||||
" <th>lastname</th>\n",
|
|
||||||
" <th>firstname</th>\n",
|
|
||||||
" <th>date_of_birth</th>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" </thead>\n",
|
|
||||||
" <tbody>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>0</th>\n",
|
|
||||||
" <td>1</td>\n",
|
|
||||||
" <td>0 10 24 Telefondienste GmbH</td>\n",
|
|
||||||
" <td>GESCHAEFTSFUEHRER</td>\n",
|
|
||||||
" <td>1</td>\n",
|
|
||||||
" <td>Tetau</td>\n",
|
|
||||||
" <td>Nicolas</td>\n",
|
|
||||||
" <td>1971-01-02</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>1</th>\n",
|
|
||||||
" <td>1</td>\n",
|
|
||||||
" <td>0 10 24 Telefondienste GmbH</td>\n",
|
|
||||||
" <td>PROKURIST</td>\n",
|
|
||||||
" <td>2</td>\n",
|
|
||||||
" <td>Dammast</td>\n",
|
|
||||||
" <td>Lutz</td>\n",
|
|
||||||
" <td>1966-12-06</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>2</th>\n",
|
|
||||||
" <td>2</td>\n",
|
|
||||||
" <td>1. Staiger Grundstücksverwaltung GmbH & Co. KG</td>\n",
|
|
||||||
" <td>KOMMANDITIST</td>\n",
|
|
||||||
" <td>3</td>\n",
|
|
||||||
" <td>Tutsch</td>\n",
|
|
||||||
" <td>Rosemarie</td>\n",
|
|
||||||
" <td>1941-10-09</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>3</th>\n",
|
|
||||||
" <td>2</td>\n",
|
|
||||||
" <td>1. Staiger Grundstücksverwaltung GmbH & Co. KG</td>\n",
|
|
||||||
" <td>KOMMANDITIST</td>\n",
|
|
||||||
" <td>4</td>\n",
|
|
||||||
" <td>Staiger</td>\n",
|
|
||||||
" <td>Marc</td>\n",
|
|
||||||
" <td>1969-10-22</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>4</th>\n",
|
|
||||||
" <td>2</td>\n",
|
|
||||||
" <td>1. Staiger Grundstücksverwaltung GmbH & Co. KG</td>\n",
|
|
||||||
" <td>KOMMANDITIST</td>\n",
|
|
||||||
" <td>5</td>\n",
|
|
||||||
" <td>Staiger</td>\n",
|
|
||||||
" <td>Michaela</td>\n",
|
|
||||||
" <td>1971-03-03</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>...</th>\n",
|
|
||||||
" <td>...</td>\n",
|
|
||||||
" <td>...</td>\n",
|
|
||||||
" <td>...</td>\n",
|
|
||||||
" <td>...</td>\n",
|
|
||||||
" <td>...</td>\n",
|
|
||||||
" <td>...</td>\n",
|
|
||||||
" <td>...</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>14891</th>\n",
|
|
||||||
" <td>3144</td>\n",
|
|
||||||
" <td>Wohnungsbaugesellschaft mit beschränkter Haftu...</td>\n",
|
|
||||||
" <td>GESCHAEFTSFUEHRER</td>\n",
|
|
||||||
" <td>878</td>\n",
|
|
||||||
" <td>Weirich</td>\n",
|
|
||||||
" <td>Torsten</td>\n",
|
|
||||||
" <td>1975-07-21</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>14892</th>\n",
|
|
||||||
" <td>3144</td>\n",
|
|
||||||
" <td>Wohnungsbaugesellschaft mit beschränkter Haftu...</td>\n",
|
|
||||||
" <td>GESCHAEFTSFUEHRER</td>\n",
|
|
||||||
" <td>1840</td>\n",
|
|
||||||
" <td>Brusinski</td>\n",
|
|
||||||
" <td>Bastian</td>\n",
|
|
||||||
" <td>1980-10-29</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>14893</th>\n",
|
|
||||||
" <td>3145</td>\n",
|
|
||||||
" <td>Zalando Customer Care International SE & Co. KG</td>\n",
|
|
||||||
" <td>PROKURIST</td>\n",
|
|
||||||
" <td>9359</td>\n",
|
|
||||||
" <td>Pape</td>\n",
|
|
||||||
" <td>Ute</td>\n",
|
|
||||||
" <td>1978-12-13</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>14894</th>\n",
|
|
||||||
" <td>3146</td>\n",
|
|
||||||
" <td>zebotec GmbH</td>\n",
|
|
||||||
" <td>GESCHAEFTSFUEHRER</td>\n",
|
|
||||||
" <td>9628</td>\n",
|
|
||||||
" <td>Neff</td>\n",
|
|
||||||
" <td>Werner</td>\n",
|
|
||||||
" <td>1981-11-24</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" <tr>\n",
|
|
||||||
" <th>14895</th>\n",
|
|
||||||
" <td>3146</td>\n",
|
|
||||||
" <td>zebotec GmbH</td>\n",
|
|
||||||
" <td>GESCHAEFTSFUEHRER</td>\n",
|
|
||||||
" <td>9629</td>\n",
|
|
||||||
" <td>Morris</td>\n",
|
|
||||||
" <td>Richard</td>\n",
|
|
||||||
" <td>1971-01-02</td>\n",
|
|
||||||
" </tr>\n",
|
|
||||||
" </tbody>\n",
|
|
||||||
"</table>\n",
|
|
||||||
"<p>14896 rows × 7 columns</p>\n",
|
|
||||||
"</div>"
|
|
||||||
],
|
|
||||||
"text/plain": [
|
"text/plain": [
|
||||||
" id_company name_company \\\n",
|
"[{'id_company': 1,\n",
|
||||||
"0 1 0 10 24 Telefondienste GmbH \n",
|
" 'name_company': '0 10 24 Telefondienste GmbH',\n",
|
||||||
"1 1 0 10 24 Telefondienste GmbH \n",
|
" 'relation_type': 'GESCHAEFTSFUEHRER',\n",
|
||||||
"2 2 1. Staiger Grundstücksverwaltung GmbH & Co. KG \n",
|
" 'id_person': 1,\n",
|
||||||
"3 2 1. Staiger Grundstücksverwaltung GmbH & Co. KG \n",
|
" 'lastname': 'Tetau',\n",
|
||||||
"4 2 1. Staiger Grundstücksverwaltung GmbH & Co. KG \n",
|
" 'firstname': 'Nicolas',\n",
|
||||||
"... ... ... \n",
|
" 'date_of_birth': datetime.date(1971, 1, 2)},\n",
|
||||||
"14891 3144 Wohnungsbaugesellschaft mit beschränkter Haftu... \n",
|
" {'id_company': 1,\n",
|
||||||
"14892 3144 Wohnungsbaugesellschaft mit beschränkter Haftu... \n",
|
" 'name_company': '0 10 24 Telefondienste GmbH',\n",
|
||||||
"14893 3145 Zalando Customer Care International SE & Co. KG \n",
|
" 'relation_type': 'PROKURIST',\n",
|
||||||
"14894 3146 zebotec GmbH \n",
|
" 'id_person': 2,\n",
|
||||||
"14895 3146 zebotec GmbH \n",
|
" 'lastname': 'Dammast',\n",
|
||||||
"\n",
|
" 'firstname': 'Lutz',\n",
|
||||||
" relation_type id_person lastname firstname date_of_birth \n",
|
" 'date_of_birth': datetime.date(1966, 12, 6)},\n",
|
||||||
"0 GESCHAEFTSFUEHRER 1 Tetau Nicolas 1971-01-02 \n",
|
" {'id_company': 2,\n",
|
||||||
"1 PROKURIST 2 Dammast Lutz 1966-12-06 \n",
|
" 'name_company': '1. Staiger Grundstücksverwaltung GmbH & Co. KG',\n",
|
||||||
"2 KOMMANDITIST 3 Tutsch Rosemarie 1941-10-09 \n",
|
" 'relation_type': 'KOMMANDITIST',\n",
|
||||||
"3 KOMMANDITIST 4 Staiger Marc 1969-10-22 \n",
|
" 'id_person': 3,\n",
|
||||||
"4 KOMMANDITIST 5 Staiger Michaela 1971-03-03 \n",
|
" 'lastname': 'Tutsch',\n",
|
||||||
"... ... ... ... ... ... \n",
|
" 'firstname': 'Rosemarie',\n",
|
||||||
"14891 GESCHAEFTSFUEHRER 878 Weirich Torsten 1975-07-21 \n",
|
" 'date_of_birth': datetime.date(1941, 10, 9)},\n",
|
||||||
"14892 GESCHAEFTSFUEHRER 1840 Brusinski Bastian 1980-10-29 \n",
|
" {'id_company': 2,\n",
|
||||||
"14893 PROKURIST 9359 Pape Ute 1978-12-13 \n",
|
" 'name_company': '1. Staiger Grundstücksverwaltung GmbH & Co. KG',\n",
|
||||||
"14894 GESCHAEFTSFUEHRER 9628 Neff Werner 1981-11-24 \n",
|
" 'relation_type': 'KOMMANDITIST',\n",
|
||||||
"14895 GESCHAEFTSFUEHRER 9629 Morris Richard 1971-01-02 \n",
|
" 'id_person': 4,\n",
|
||||||
"\n",
|
" 'lastname': 'Staiger',\n",
|
||||||
"[14896 rows x 7 columns]"
|
" 'firstname': 'Marc',\n",
|
||||||
|
" 'date_of_birth': datetime.date(1969, 10, 22)},\n",
|
||||||
|
" {'id_company': 2,\n",
|
||||||
|
" 'name_company': '1. Staiger Grundstücksverwaltung GmbH & Co. KG',\n",
|
||||||
|
" 'relation_type': 'KOMMANDITIST',\n",
|
||||||
|
" 'id_person': 5,\n",
|
||||||
|
" 'lastname': 'Staiger',\n",
|
||||||
|
" 'firstname': 'Michaela',\n",
|
||||||
|
" 'date_of_birth': datetime.date(1971, 3, 3)}]"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 45,
|
"execution_count": 15,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "execute_result"
|
"output_type": "execute_result"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"person_relations = pd.read_sql_query(str(relations_person_query), session.bind)\n",
|
"person_relations = pd.read_sql_query(str(relations_person_query), session.bind)\n",
|
||||||
"person_relations"
|
"person_relations.head().to_dict(orient=\"records\")"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -9,7 +9,6 @@ import pandas as pd
|
|||||||
import plotly.graph_objects as go
|
import plotly.graph_objects as go
|
||||||
from cachetools import TTLCache, cached
|
from cachetools import TTLCache, cached
|
||||||
from dash import Input, Output, callback, dash_table, dcc, html
|
from dash import Input, Output, callback, dash_table, dcc, html
|
||||||
from loguru import logger
|
|
||||||
|
|
||||||
from aki_prj23_transparenzregister.utils.networkx.network_2d import (
|
from aki_prj23_transparenzregister.utils.networkx.network_2d import (
|
||||||
create_2d_graph,
|
create_2d_graph,
|
||||||
@ -66,13 +65,11 @@ network = None
|
|||||||
|
|
||||||
def person_relation_type_filter() -> np.ndarray:
|
def person_relation_type_filter() -> np.ndarray:
|
||||||
"""Returns an Numpy Array of String with Person telation types."""
|
"""Returns an Numpy Array of String with Person telation types."""
|
||||||
logger.debug("Updating Person Dropdown")
|
|
||||||
return get_all_person_relations()["relation_type"].unique()
|
return get_all_person_relations()["relation_type"].unique()
|
||||||
|
|
||||||
|
|
||||||
def company_relation_type_filter() -> np.ndarray:
|
def company_relation_type_filter() -> np.ndarray:
|
||||||
"""Returns an Numpy Array of String with Company relation types."""
|
"""Returns an Numpy Array of String with Company relation types."""
|
||||||
logger.debug("Updating Person Dropdown")
|
|
||||||
return get_all_company_relations()["relation_type"].unique()
|
return get_all_company_relations()["relation_type"].unique()
|
||||||
|
|
||||||
|
|
||||||
@ -88,17 +85,14 @@ def update_table(
|
|||||||
Returns:
|
Returns:
|
||||||
tuple[dict, list]: _description_
|
tuple[dict, list]: _description_
|
||||||
"""
|
"""
|
||||||
logger.debug("Updateing Table")
|
|
||||||
table_df = metrics.sort_values(metric_dropdown_value, ascending=False).head(10)
|
table_df = metrics.sort_values(metric_dropdown_value, ascending=False).head(10)
|
||||||
table_df = table_df[["designation", "category", metric_dropdown_value]]
|
table_df = table_df[["designation", "category", metric_dropdown_value]]
|
||||||
table_df.to_dict("records")
|
|
||||||
columns = [{"name": i, "id": i} for i in table_df.columns]
|
columns = [{"name": i, "id": i} for i in table_df.columns]
|
||||||
return table_df.to_dict("records"), columns # type: ignore
|
return table_df.to_dict("records"), columns # type: ignore
|
||||||
|
|
||||||
|
|
||||||
def layout() -> list[html.Div]:
|
def layout() -> list[html.Div]:
|
||||||
"""Generates the Layout of the Homepage."""
|
"""Generates the Layout of the Homepage."""
|
||||||
logger.debug("Layouting Homepage")
|
|
||||||
person_relation_types = person_relation_type_filter()
|
person_relation_types = person_relation_type_filter()
|
||||||
company_relation_types = company_relation_type_filter()
|
company_relation_types = company_relation_type_filter()
|
||||||
top_companies_dict, top_companies_columns, figure = update_figure(
|
top_companies_dict, top_companies_columns, figure = update_figure(
|
||||||
@ -348,7 +342,6 @@ def update_graph_data(
|
|||||||
Returns:
|
Returns:
|
||||||
tuple[nx.Graph, pd.DataFrame, dict, list]: _description_
|
tuple[nx.Graph, pd.DataFrame, dict, list]: _description_
|
||||||
"""
|
"""
|
||||||
logger.debug("Updating Graph data")
|
|
||||||
# Get Data
|
# Get Data
|
||||||
person_df = get_all_person_relations()
|
person_df = get_all_person_relations()
|
||||||
company_df = get_all_company_relations()
|
company_df = get_all_company_relations()
|
||||||
@ -356,8 +349,6 @@ def update_graph_data(
|
|||||||
person_relation = filter_relation_type(person_df, person_relation_type)
|
person_relation = filter_relation_type(person_df, person_relation_type)
|
||||||
company_relation = filter_relation_type(company_df, company_relation_type)
|
company_relation = filter_relation_type(company_df, company_relation_type)
|
||||||
|
|
||||||
# company_relation = filter_relation_with_more_than_one_connection(company_relation, "id_company_to", "id_company_from")
|
|
||||||
|
|
||||||
# Create Edge and Node List from data
|
# Create Edge and Node List from data
|
||||||
nodes_tmp, edges_tmp = create_edge_and_node_list(person_relation, company_relation)
|
nodes_tmp, edges_tmp = create_edge_and_node_list(person_relation, company_relation)
|
||||||
|
|
||||||
@ -414,7 +405,6 @@ def update_figure( # noqa: PLR0913
|
|||||||
Returns:
|
Returns:
|
||||||
Network Graph(Plotly Figure): Plotly Figure in 3 or 2D
|
Network Graph(Plotly Figure): Plotly Figure in 3 or 2D
|
||||||
"""
|
"""
|
||||||
logger.debug("Update Figure")
|
|
||||||
_ = c_relation_filter_value, p_relation_filter_value
|
_ = c_relation_filter_value, p_relation_filter_value
|
||||||
|
|
||||||
graph, metrics, nodes, edges = update_graph_data(
|
graph, metrics, nodes, edges = update_graph_data(
|
||||||
@ -454,29 +444,3 @@ def update_figure( # noqa: PLR0913
|
|||||||
slider_value, # type: ignore
|
slider_value, # type: ignore
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@callback(
|
|
||||||
Output("company_dropdown", "style"),
|
|
||||||
[
|
|
||||||
Input("dropdown_data_soruce_filter", "value"),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
def update_dropdown(datasource_value: str) -> str:
|
|
||||||
"""_summary_.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
datasource_value (str): _description_
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
str: _description_
|
|
||||||
"""
|
|
||||||
style = ""
|
|
||||||
match datasource_value:
|
|
||||||
case "Company Data only":
|
|
||||||
style = "visibility: visible;"
|
|
||||||
case "Person Data only":
|
|
||||||
style = "visibility: hidden;"
|
|
||||||
case "Company & Person Data":
|
|
||||||
style = "visibility: visible;"
|
|
||||||
return style
|
|
||||||
|
@ -158,42 +158,6 @@ def filter_relation_type(
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def filter_relation_with_more_than_one_connection(
|
|
||||||
relation_dataframe: pd.DataFrame, id_column_name_to: str, id_column_name_from: str
|
|
||||||
) -> pd.DataFrame:
|
|
||||||
"""Method to filter all Entries in an DataFrame which has more than one connection.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
relation_dataframe (pd.DataFrame): _description_
|
|
||||||
id_column_name_to (_type_): _description_
|
|
||||||
id_column_name_from (_type_): _description_
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
relation_dataframe (pd.DataFrame): The DataFrame which now only contains entries with more than one connection.
|
|
||||||
"""
|
|
||||||
tmp_df = pd.DataFrame(columns=relation_dataframe.columns.values)
|
|
||||||
for _index, row in relation_dataframe.iterrows():
|
|
||||||
count = 0
|
|
||||||
id = row[id_column_name_to]
|
|
||||||
for _index_sub, row_sub in relation_dataframe.iterrows():
|
|
||||||
if id == row_sub[id_column_name_to]:
|
|
||||||
count = count + 1
|
|
||||||
if id == row_sub[id_column_name_from]:
|
|
||||||
count = count + 1
|
|
||||||
if count > 1:
|
|
||||||
break
|
|
||||||
|
|
||||||
if count > 1:
|
|
||||||
# tmp_df = pd.concat([tmp_df, pd.DataFrame(row)])+
|
|
||||||
tmp_df.loc[len(tmp_df)] = row # type: ignore
|
|
||||||
count = 0
|
|
||||||
else:
|
|
||||||
count = 0
|
|
||||||
continue
|
|
||||||
count = 0
|
|
||||||
return tmp_df
|
|
||||||
|
|
||||||
|
|
||||||
def create_edge_and_node_list(
|
def create_edge_and_node_list(
|
||||||
person_relations: pd.DataFrame, company_relations: pd.DataFrame
|
person_relations: pd.DataFrame, company_relations: pd.DataFrame
|
||||||
) -> tuple[dict, list]:
|
) -> tuple[dict, list]:
|
||||||
@ -362,7 +326,7 @@ def create_edge_and_node_list_for_company(
|
|||||||
return nodes, edges
|
return nodes, edges
|
||||||
|
|
||||||
|
|
||||||
def get_all_metrics_from_id(company_id: str) -> pd.Series:
|
def get_all_metrics_from_id(company_id: int) -> pd.Series:
|
||||||
"""Returns all Metric for the given ID.
|
"""Returns all Metric for the given ID.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -380,11 +344,14 @@ def get_all_metrics_from_id(company_id: str) -> pd.Series:
|
|||||||
graph, metrics = initialize_network_with_reduced_metrics(
|
graph, metrics = initialize_network_with_reduced_metrics(
|
||||||
nodes=nodes_tmp, edges=edges_tmp
|
nodes=nodes_tmp, edges=edges_tmp
|
||||||
)
|
)
|
||||||
return metrics.loc[metrics["id"] == company_id].iloc[0]
|
filtered_metrics = metrics.loc[metrics["id"] == company_id]
|
||||||
|
if len(filtered_metrics) == 0:
|
||||||
|
return pd.Series([])
|
||||||
|
return filtered_metrics.iloc[0]
|
||||||
|
|
||||||
|
|
||||||
@lru_cache
|
@lru_cache
|
||||||
def get_relations_number_from_id(id: str) -> tuple[int, int, int]:
|
def get_relations_number_from_id(id: int) -> tuple[int, int, int]:
|
||||||
"""Returns all Relation in 1, 2 and 3 lvl of one Node.
|
"""Returns all Relation in 1, 2 and 3 lvl of one Node.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -399,7 +366,6 @@ def get_relations_number_from_id(id: str) -> tuple[int, int, int]:
|
|||||||
|
|
||||||
# Create Edge and Node List from data
|
# Create Edge and Node List from data
|
||||||
nodes_tmp, edges_tmp = create_edge_and_node_list(person_df, company_df)
|
nodes_tmp, edges_tmp = create_edge_and_node_list(person_df, company_df)
|
||||||
|
|
||||||
graph = initialize_network_without_metrics(nodes=nodes_tmp, edges=edges_tmp)
|
graph = initialize_network_without_metrics(nodes=nodes_tmp, edges=edges_tmp)
|
||||||
|
|
||||||
neighbors = nx.all_neighbors(graph, id)
|
neighbors = nx.all_neighbors(graph, id)
|
||||||
|
@ -1,7 +1,195 @@
|
|||||||
"""Test for the Home Page."""
|
"""Test for the Home Page."""
|
||||||
|
import datetime
|
||||||
|
from collections.abc import Generator
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
import pandas as pd
|
||||||
|
import pytest
|
||||||
|
|
||||||
from aki_prj23_transparenzregister.ui.pages import home
|
from aki_prj23_transparenzregister.ui.pages import home
|
||||||
|
|
||||||
|
|
||||||
def test_import() -> None:
|
def test_import() -> None:
|
||||||
"""Checks if an import co company_stats_dash can be made."""
|
"""Checks if an import co company_stats_dash can be made."""
|
||||||
assert home is not None
|
assert home is not None
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.tim()
|
||||||
|
def test_person_relation_type_filter() -> None:
|
||||||
|
with patch(
|
||||||
|
"aki_prj23_transparenzregister.ui.pages.home.get_all_person_relations"
|
||||||
|
) as mock_filter:
|
||||||
|
data = [
|
||||||
|
{"relation_type": "Eigentümer"},
|
||||||
|
{"relation_type": "Inhaber"},
|
||||||
|
{"relation_type": "Eigentümer"},
|
||||||
|
]
|
||||||
|
mock_filter.return_value = pd.DataFrame(data)
|
||||||
|
assert list(home.person_relation_type_filter()) == ["Eigentümer", "Inhaber"]
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.tim()
|
||||||
|
def test_company_relation_type_filter() -> None:
|
||||||
|
with patch(
|
||||||
|
"aki_prj23_transparenzregister.ui.pages.home.get_all_company_relations"
|
||||||
|
) as mock_filter:
|
||||||
|
data = [
|
||||||
|
{"relation_type": "Eigentümer"},
|
||||||
|
{"relation_type": "Inhaber"},
|
||||||
|
{"relation_type": "Eigentümer"},
|
||||||
|
]
|
||||||
|
mock_filter.return_value = pd.DataFrame(data)
|
||||||
|
assert list(home.company_relation_type_filter()) == ["Eigentümer", "Inhaber"]
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.tim()
|
||||||
|
def test_update_table() -> None:
|
||||||
|
metrics = pd.DataFrame(
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"designation": "Mustermann, Max",
|
||||||
|
"category": "Person",
|
||||||
|
"centrality": 3.14,
|
||||||
|
"betweenness": 42,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"designation": "Musterfrau, Martina",
|
||||||
|
"category": "Person",
|
||||||
|
"centrality": 42,
|
||||||
|
"betweenness": 3.14,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
)
|
||||||
|
selected_metric = "centrality"
|
||||||
|
|
||||||
|
expected_result_df = [
|
||||||
|
{
|
||||||
|
"designation": "Musterfrau, Martina",
|
||||||
|
"category": "Person",
|
||||||
|
"centrality": 42.0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"designation": "Mustermann, Max",
|
||||||
|
"category": "Person",
|
||||||
|
"centrality": 3.14,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
expected_result_columns = [
|
||||||
|
{"name": "designation", "id": "designation"},
|
||||||
|
{"name": "category", "id": "category"},
|
||||||
|
{"name": "centrality", "id": "centrality"},
|
||||||
|
]
|
||||||
|
|
||||||
|
result_df, result_columns = home.update_table(selected_metric, metrics)
|
||||||
|
assert result_df == expected_result_df
|
||||||
|
assert result_columns == expected_result_columns
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope="session", autouse=True)
|
||||||
|
def _get_person_relations() -> Generator:
|
||||||
|
data = [
|
||||||
|
{
|
||||||
|
"id_company": 1,
|
||||||
|
"name_company": "0 10 24 Telefondienste GmbH",
|
||||||
|
"relation_type": "GESCHAEFTSFUEHRER",
|
||||||
|
"id_person": 1,
|
||||||
|
"lastname": "Tetau",
|
||||||
|
"firstname": "Nicolas",
|
||||||
|
"date_of_birth": datetime.date(1971, 1, 2),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id_company": 1,
|
||||||
|
"name_company": "0 10 24 Telefondienste GmbH",
|
||||||
|
"relation_type": "PROKURIST",
|
||||||
|
"id_person": 2,
|
||||||
|
"lastname": "Dammast",
|
||||||
|
"firstname": "Lutz",
|
||||||
|
"date_of_birth": datetime.date(1966, 12, 6),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id_company": 2,
|
||||||
|
"name_company": "1. Staiger Grundstücksverwaltung GmbH & Co. KG",
|
||||||
|
"relation_type": "KOMMANDITIST",
|
||||||
|
"id_person": 3,
|
||||||
|
"lastname": "Tutsch",
|
||||||
|
"firstname": "Rosemarie",
|
||||||
|
"date_of_birth": datetime.date(1941, 10, 9),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id_company": 2,
|
||||||
|
"name_company": "1. Staiger Grundstücksverwaltung GmbH & Co. KG",
|
||||||
|
"relation_type": "HAFTENDER_GESELLSCHAFTER",
|
||||||
|
"id_person": 4,
|
||||||
|
"lastname": "Staiger",
|
||||||
|
"firstname": "Marc",
|
||||||
|
"date_of_birth": datetime.date(1969, 10, 22),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id_company": 2,
|
||||||
|
"name_company": "1. Staiger Grundstücksverwaltung GmbH & Co. KG",
|
||||||
|
"relation_type": "HAFTENDER_GESELLSCHAFTER",
|
||||||
|
"id_person": 5,
|
||||||
|
"lastname": "Staiger",
|
||||||
|
"firstname": "Michaela",
|
||||||
|
"date_of_birth": datetime.date(1971, 3, 3),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
with patch(
|
||||||
|
"aki_prj23_transparenzregister.ui.pages.home.get_all_person_relations"
|
||||||
|
) as mock_get_person_relations:
|
||||||
|
mock_get_person_relations.return_value = pd.DataFrame(data)
|
||||||
|
yield
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope="session", autouse=True)
|
||||||
|
def _get_company_relations() -> Generator:
|
||||||
|
data = [
|
||||||
|
{
|
||||||
|
"id_company_to": 2,
|
||||||
|
"name_company_to": "1. Staiger Grundstücksverwaltung GmbH & Co. KG",
|
||||||
|
"relation_type": "GESCHAEFTSFUEHRER",
|
||||||
|
"name_company_from": "Staiger I. Verwaltung-GmbH",
|
||||||
|
"id_company_from": 3226,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id_company_to": 3,
|
||||||
|
"name_company_to": "1 A Autenrieth Kunststofftechnik GmbH & Co. KG",
|
||||||
|
"relation_type": "GESCHAEFTSFUEHRER",
|
||||||
|
"name_company_from": "Autenrieth Verwaltungs-GmbH",
|
||||||
|
"id_company_from": 3324,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id_company_to": 5,
|
||||||
|
"name_company_to": "2. Schaper Objekt GmbH & Co. Kiel KG",
|
||||||
|
"relation_type": "KOMMANDITIST",
|
||||||
|
"name_company_from": "Multi-Center Warenvertriebs GmbH",
|
||||||
|
"id_company_from": 2213,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id_company_to": 6,
|
||||||
|
"name_company_to": "AASP Filmproduktionsgesellschaft mbH & Co. Leonie KG",
|
||||||
|
"relation_type": "INHABER",
|
||||||
|
"name_company_from": "ABN AMRO Structured Products Gesellschaft für Fondsbeteiligungen mbH",
|
||||||
|
"id_company_from": 3332,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id_company_to": 6,
|
||||||
|
"name_company_to": "AASP Filmproduktionsgesellschaft mbH & Co. Leonie KG",
|
||||||
|
"relation_type": "KOMMANDITIST",
|
||||||
|
"name_company_from": "Kallang GmbH",
|
||||||
|
"id_company_from": 3316,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
with patch(
|
||||||
|
"aki_prj23_transparenzregister.ui.pages.home.get_all_company_relations"
|
||||||
|
) as mock_get_person_relations:
|
||||||
|
mock_get_person_relations.return_value = pd.DataFrame(data)
|
||||||
|
yield
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.tim()
|
||||||
|
def test_update_graph_data() -> None:
|
||||||
|
graph_result, metrics_result, nodes_result, edges_result = home.update_graph_data(
|
||||||
|
"HAFTENDER_GESELLSCHAFTER", "GESCHAEFTSFUEHRER"
|
||||||
|
)
|
||||||
|
assert graph_result is not None
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
"""Test the initialize Network function."""
|
"""Test the initialize Network function."""
|
||||||
|
import datetime
|
||||||
from collections.abc import Generator
|
from collections.abc import Generator
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import pytest
|
import pytest
|
||||||
@ -7,16 +9,108 @@ from sqlalchemy.orm import Session
|
|||||||
|
|
||||||
from aki_prj23_transparenzregister.ui.session_handler import SessionHandler
|
from aki_prj23_transparenzregister.ui.session_handler import SessionHandler
|
||||||
from aki_prj23_transparenzregister.utils.networkx import networkx_data
|
from aki_prj23_transparenzregister.utils.networkx import networkx_data
|
||||||
from aki_prj23_transparenzregister.utils.networkx.networkx_data import (
|
|
||||||
create_edge_and_node_list,
|
|
||||||
create_edge_and_node_list_for_company,
|
@pytest.fixture(scope="session", autouse=True)
|
||||||
filter_relation_type,
|
def _get_person_relations() -> Generator:
|
||||||
filter_relation_with_more_than_one_connection,
|
data = [
|
||||||
find_all_company_relations,
|
{
|
||||||
find_company_relations,
|
"id_company": 1,
|
||||||
get_all_company_relations,
|
"name_company": "0 10 24 Telefondienste GmbH",
|
||||||
get_all_person_relations,
|
"relation_type": "GESCHAEFTSFUEHRER",
|
||||||
)
|
"id_person": 1,
|
||||||
|
"lastname": "Tetau",
|
||||||
|
"firstname": "Nicolas",
|
||||||
|
"date_of_birth": datetime.date(1971, 1, 2),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id_company": 1,
|
||||||
|
"name_company": "0 10 24 Telefondienste GmbH",
|
||||||
|
"relation_type": "PROKURIST",
|
||||||
|
"id_person": 2,
|
||||||
|
"lastname": "Dammast",
|
||||||
|
"firstname": "Lutz",
|
||||||
|
"date_of_birth": datetime.date(1966, 12, 6),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id_company": 2,
|
||||||
|
"name_company": "1. Staiger Grundstücksverwaltung GmbH & Co. KG",
|
||||||
|
"relation_type": "KOMMANDITIST",
|
||||||
|
"id_person": 3,
|
||||||
|
"lastname": "Tutsch",
|
||||||
|
"firstname": "Rosemarie",
|
||||||
|
"date_of_birth": datetime.date(1941, 10, 9),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id_company": 2,
|
||||||
|
"name_company": "1. Staiger Grundstücksverwaltung GmbH & Co. KG",
|
||||||
|
"relation_type": "KOMMANDITIST",
|
||||||
|
"id_person": 4,
|
||||||
|
"lastname": "Staiger",
|
||||||
|
"firstname": "Marc",
|
||||||
|
"date_of_birth": datetime.date(1969, 10, 22),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id_company": 2,
|
||||||
|
"name_company": "1. Staiger Grundstücksverwaltung GmbH & Co. KG",
|
||||||
|
"relation_type": "KOMMANDITIST",
|
||||||
|
"id_person": 5,
|
||||||
|
"lastname": "Staiger",
|
||||||
|
"firstname": "Michaela",
|
||||||
|
"date_of_birth": datetime.date(1971, 3, 3),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
with patch(
|
||||||
|
"aki_prj23_transparenzregister.utils.networkx.networkx_data.get_all_person_relations"
|
||||||
|
) as mock_get_person_relations:
|
||||||
|
mock_get_person_relations.return_value = pd.DataFrame(data)
|
||||||
|
yield
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope="session", autouse=True)
|
||||||
|
def _get_company_relations() -> Generator:
|
||||||
|
data = [
|
||||||
|
{
|
||||||
|
"id_company_to": 2,
|
||||||
|
"name_company_to": "1. Staiger Grundstücksverwaltung GmbH & Co. KG",
|
||||||
|
"relation_type": "HAFTENDER_GESELLSCHAFTER",
|
||||||
|
"name_company_from": "Staiger I. Verwaltung-GmbH",
|
||||||
|
"id_company_from": 3226,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id_company_to": 3,
|
||||||
|
"name_company_to": "1 A Autenrieth Kunststofftechnik GmbH & Co. KG",
|
||||||
|
"relation_type": "HAFTENDER_GESELLSCHAFTER",
|
||||||
|
"name_company_from": "Autenrieth Verwaltungs-GmbH",
|
||||||
|
"id_company_from": 3324,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id_company_to": 5,
|
||||||
|
"name_company_to": "2. Schaper Objekt GmbH & Co. Kiel KG",
|
||||||
|
"relation_type": "KOMMANDITIST",
|
||||||
|
"name_company_from": "Multi-Center Warenvertriebs GmbH",
|
||||||
|
"id_company_from": 2213,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id_company_to": 6,
|
||||||
|
"name_company_to": "AASP Filmproduktionsgesellschaft mbH & Co. Leonie KG",
|
||||||
|
"relation_type": "INHABER",
|
||||||
|
"name_company_from": "ABN AMRO Structured Products Gesellschaft für Fondsbeteiligungen mbH",
|
||||||
|
"id_company_from": 3332,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id_company_to": 6,
|
||||||
|
"name_company_to": "AASP Filmproduktionsgesellschaft mbH & Co. Leonie KG",
|
||||||
|
"relation_type": "KOMMANDITIST",
|
||||||
|
"name_company_from": "Kallang GmbH",
|
||||||
|
"id_company_from": 3316,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
with patch(
|
||||||
|
"aki_prj23_transparenzregister.utils.networkx.networkx_data.get_all_company_relations"
|
||||||
|
) as mock_get_person_relations:
|
||||||
|
mock_get_person_relations.return_value = pd.DataFrame(data)
|
||||||
|
yield
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
@ -70,48 +164,37 @@ def test_import() -> None:
|
|||||||
|
|
||||||
def test_find_all_company_relations() -> None:
|
def test_find_all_company_relations() -> None:
|
||||||
"""This Test methods tests if the correct type is returned for the corresponding Function."""
|
"""This Test methods tests if the correct type is returned for the corresponding Function."""
|
||||||
company_relations_df = find_all_company_relations()
|
company_relations_df = networkx_data.find_all_company_relations()
|
||||||
assert type(company_relations_df) is pd.DataFrame
|
assert type(company_relations_df) is pd.DataFrame
|
||||||
|
|
||||||
|
|
||||||
def test_get_all_company_relations() -> None:
|
def test_get_all_company_relations() -> None:
|
||||||
"""This Test methods tests if the correct type is returned for the corresponding Function."""
|
"""This Test methods tests if the correct type is returned for the corresponding Function."""
|
||||||
company_relations_df = get_all_company_relations()
|
company_relations_df = networkx_data.get_all_company_relations()
|
||||||
assert type(company_relations_df) is pd.DataFrame
|
assert type(company_relations_df) is pd.DataFrame
|
||||||
|
|
||||||
|
|
||||||
def test_get_all_person_relations() -> None:
|
def test_get_all_person_relations() -> None:
|
||||||
"""This Test methods tests if the correct type is returned for the corresponding Function."""
|
"""This Test methods tests if the correct type is returned for the corresponding Function."""
|
||||||
company_relations_df = get_all_person_relations()
|
company_relations_df = networkx_data.get_all_person_relations()
|
||||||
assert type(company_relations_df) is pd.DataFrame
|
assert type(company_relations_df) is pd.DataFrame
|
||||||
|
|
||||||
|
|
||||||
def test_filter_relation_type() -> None:
|
def test_filter_relation_type() -> None:
|
||||||
"""This Test methods tests if the correct type is returned for the corresponding Function."""
|
"""This Test methods tests if the correct type is returned for the corresponding Function."""
|
||||||
relation_dataframe = get_all_company_relations()
|
relation_dataframe = networkx_data.get_all_company_relations()
|
||||||
selected_relation_type = "HAFTENDER_GESELLSCHAFTER"
|
selected_relation_type = "HAFTENDER_GESELLSCHAFTER"
|
||||||
company_relations_df = filter_relation_type(
|
company_relations_df = networkx_data.filter_relation_type(
|
||||||
relation_dataframe, selected_relation_type
|
relation_dataframe, selected_relation_type
|
||||||
)
|
)
|
||||||
assert type(company_relations_df) is pd.DataFrame
|
assert type(company_relations_df) is pd.DataFrame
|
||||||
|
|
||||||
|
|
||||||
def test_filter_relation_with_more_than_one_connection() -> None:
|
|
||||||
"""This Test methods tests if the correct type is returned for the corresponding Function."""
|
|
||||||
relation_dataframe = get_all_company_relations()
|
|
||||||
id_column_name_to = "c_1"
|
|
||||||
id_column_name_from = "c_2"
|
|
||||||
relations_df = filter_relation_with_more_than_one_connection(
|
|
||||||
relation_dataframe, id_column_name_to, id_column_name_from
|
|
||||||
)
|
|
||||||
assert type(relations_df) is pd.DataFrame
|
|
||||||
|
|
||||||
|
|
||||||
def test_create_edge_and_node_list() -> None:
|
def test_create_edge_and_node_list() -> None:
|
||||||
"""This Test methods tests if the correct type is returned for the corresponding Function."""
|
"""This Test methods tests if the correct type is returned for the corresponding Function."""
|
||||||
person_df = get_all_person_relations()
|
person_df = networkx_data.get_all_person_relations()
|
||||||
company_df = get_all_company_relations()
|
company_df = networkx_data.get_all_company_relations()
|
||||||
nodes, edges = create_edge_and_node_list(person_df, company_df)
|
nodes, edges = networkx_data.create_edge_and_node_list(person_df, company_df)
|
||||||
assert isinstance(nodes, dict)
|
assert isinstance(nodes, dict)
|
||||||
assert isinstance(edges, list)
|
assert isinstance(edges, list)
|
||||||
|
|
||||||
@ -119,32 +202,39 @@ def test_create_edge_and_node_list() -> None:
|
|||||||
def test_find_company_relations() -> None:
|
def test_find_company_relations() -> None:
|
||||||
"""This Test methods tests if the correct type is returned for the corresponding Function."""
|
"""This Test methods tests if the correct type is returned for the corresponding Function."""
|
||||||
selected_company_id = 1
|
selected_company_id = 1
|
||||||
company_relations_df, person_df = find_company_relations(selected_company_id)
|
company_relations_df, person_df = networkx_data.find_company_relations(
|
||||||
|
selected_company_id
|
||||||
|
)
|
||||||
assert type(company_relations_df) is pd.DataFrame
|
assert type(company_relations_df) is pd.DataFrame
|
||||||
assert type(person_df) is pd.DataFrame
|
assert type(person_df) is pd.DataFrame
|
||||||
|
|
||||||
|
|
||||||
def test_create_edge_and_node_list_for_company() -> None:
|
def test_create_edge_and_node_list_for_company() -> None:
|
||||||
"""This Test methods tests if the correct type is returned for the corresponding Function."""
|
"""This Test methods tests if the correct type is returned for the corresponding Function."""
|
||||||
company_relations = get_all_company_relations()
|
company_relations = networkx_data.get_all_company_relations()
|
||||||
nodes, edges = create_edge_and_node_list_for_company(company_relations)
|
nodes, edges = networkx_data.create_edge_and_node_list_for_company(
|
||||||
|
company_relations
|
||||||
|
)
|
||||||
assert isinstance(nodes, dict)
|
assert isinstance(nodes, dict)
|
||||||
assert isinstance(edges, list)
|
assert isinstance(edges, list)
|
||||||
|
|
||||||
|
|
||||||
# @pytest.mark.tim()
|
def test_get_all_metrics_from_id() -> None:
|
||||||
# def test_get_all_metrics_from_id() -> None:
|
"""This Test methods tests if the correct type is returned for the corresponding Function."""
|
||||||
# """This Test methods tests if the correct type is returned for the corresponding Function."""
|
company_id = 2
|
||||||
# company_id = 2549
|
metrics = networkx_data.get_all_metrics_from_id(company_id)
|
||||||
# metrics = get_all_metrics_from_id(company_id)
|
assert type(metrics) is pd.Series
|
||||||
# assert type(metrics) is pd.Series
|
|
||||||
|
|
||||||
# @pytest.mark.tim()
|
|
||||||
# def test_get_relations_number_from_id() -> None:
|
def test_get_relations_number_from_id() -> None:
|
||||||
# """This Test methods tests if the correct type and number of relations is received."""
|
"""This Test methods tests if the correct type and number of relations is received."""
|
||||||
# # id = "c_2549"
|
# id = "c_2549"
|
||||||
# id = "c_2667"
|
id = 2
|
||||||
# relations_lvl_1, relations_lvl_2, relations_lvl_3 = get_relations_number_from_id(id)
|
(
|
||||||
# assert type(relations_lvl_1) is int
|
relations_lvl_1,
|
||||||
# assert type(relations_lvl_2) is int
|
relations_lvl_2,
|
||||||
# assert type(relations_lvl_3) is int
|
relations_lvl_3,
|
||||||
|
) = networkx_data.get_relations_number_from_id(id)
|
||||||
|
assert isinstance(relations_lvl_1, int)
|
||||||
|
assert isinstance(relations_lvl_2, int)
|
||||||
|
assert isinstance(relations_lvl_3, int)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user