Пример #1
0
def test_ValidationResultsPageRenderer_render_nested_table_from_dict():
    batch_kwargs = {
        "path": "project_dir/project_path/data/titanic/Titanic.csv",
        "datasource": "Titanic",
        "reader_options": {
            "sep": None,
            "engine": "python"
        }
    }
    batch_kwargs_table = ValidationResultsPageRenderer._render_nested_table_from_dict(
        batch_kwargs, header="Batch Kwargs").to_json_dict()
    print(batch_kwargs_table)

    expected_batch_kwarg_table = {
        'content_block_type': 'table',
        'styling': {'classes': ['col-6', 'table-responsive', 'mt-1'],
                    'body': {'classes': ['table', 'table-sm']}},
        'header': {'content_block_type': 'string_template',
                   'string_template': {'template': 'Batch Kwargs', 'tag': 'h6',
                                       'styling': {'classes': ['m-0']}}}, 'table': [[{
            'content_block_type': 'string_template',
            'styling': {
                'parent': {
                    'classes': [
                        'pr-3']}},
            'string_template': {
                'template': '$value',
                'params': {
                    'value': 'datasource'},
                'styling': {
                    'default': {
                        'styles': {
                            'word-break': 'break-all'}}}}},
            {
                'content_block_type': 'string_template',
                'styling': {
                    'parent': {
                        'classes': []}},
                'string_template': {
                    'template': '$value',
                    'params': {
                        'value': 'Titanic'},
                    'styling': {
                        'default': {
                            'styles': {
                                'word-break': 'break-all'}}}}}],
            [{
                'content_block_type': 'string_template',
                'styling': {
                    'parent': {
                        'classes': [
                            'pr-3']}},
                'string_template': {
                    'template': '$value',
                    'params': {
                        'value': 'path'},
                    'styling': {
                        'default': {
                            'styles': {
                                'word-break': 'break-all'}}}}},
                {
                    'content_block_type': 'string_template',
                    'styling': {
                        'parent': {
                            'classes': []}},
                    'string_template': {
                        'template': '$value',
                        'params': {
                            'value': 'project_dir/project_path/data/titanic/Titanic.csv'},
                        'styling': {
                            'default': {
                                'styles': {
                                    'word-break': 'break-all'}}}}}],
            [{
                'content_block_type': 'string_template',
                'styling': {
                    'parent': {
                        'classes': [
                            'pr-3']}},
                'string_template': {
                    'template': '$value',
                    'params': {
                        'value': 'reader_options'},
                    'styling': {
                        'default': {
                            'styles': {
                                'word-break': 'break-all'}}}}},
                {
                    'content_block_type': 'table',
                    'styling': {
                        'classes': [
                            'col-6',
                            'table-responsive'],
                        'body': {
                            'classes': [
                                'table',
                                'table-sm',
                                'm-0']},
                        'parent': {
                            'classes': [
                                'pt-0',
                                'pl-0',
                                'border-top-0']}},
                    'table': [
                        [
                            {
                                'content_block_type': 'string_template',
                                'styling': {
                                    'parent': {
                                        'classes': [
                                            'pr-3']}},
                                'string_template': {
                                    'template': '$value',
                                    'params': {
                                        'value': 'engine'},
                                    'styling': {
                                        'default': {
                                            'styles': {
                                                'word-break': 'break-all'}}}}},
                            {
                                'content_block_type': 'string_template',
                                'styling': {
                                    'parent': {
                                        'classes': []}},
                                'string_template': {
                                    'template': '$value',
                                    'params': {
                                        'value': 'python'},
                                    'styling': {
                                        'default': {
                                            'styles': {
                                                'word-break': 'break-all'}}}}}],
                        [
                            {
                                'content_block_type': 'string_template',
                                'styling': {
                                    'parent': {
                                        'classes': [
                                            'pr-3']}},
                                'string_template': {
                                    'template': '$value',
                                    'params': {
                                        'value': 'sep'},
                                    'styling': {
                                        'default': {
                                            'styles': {
                                                'word-break': 'break-all'}}}}},
                            {
                                'content_block_type': 'string_template',
                                'styling': {
                                    'parent': {
                                        'classes': []}},
                                'string_template': {
                                    'template': '$value',
                                    'params': {
                                        'value': 'None'},
                                    'styling': {
                                        'default': {
                                            'styles': {
                                                'word-break': 'break-all'}}}}}]]}]]}

    assert batch_kwargs_table == expected_batch_kwarg_table
def test_ValidationResultsPageRenderer_render_nested_table_from_dict():
    batch_kwargs = {
        "path": "project_dir/project_path/data/titanic/Titanic.csv",
        "datasource": "Titanic",
        "reader_options": {"sep": None, "engine": "python"},
    }
    batch_kwargs_table = ValidationResultsPageRenderer._render_nested_table_from_dict(
        batch_kwargs, header="Batch Kwargs"
    ).to_json_dict()
    print(batch_kwargs_table)

    expected_batch_kwarg_table = {
        "content_block_type": "table",
        "styling": {
            "body": {
                "classes": ["table", "table-sm"],
                "styles": {
                    "margin-bottom": "0.5rem !important",
                    "margin-top": "0.5rem !important",
                },
            }
        },
        "header": {
            "content_block_type": "string_template",
            "string_template": {
                "template": "Batch Kwargs",
                "tag": "h6",
                "styling": {"classes": ["m-0"]},
            },
        },
        "table": [
            [
                {
                    "content_block_type": "string_template",
                    "styling": {"parent": {"classes": ["pr-3"]}},
                    "string_template": {
                        "template": "$value",
                        "params": {"value": "datasource"},
                        "styling": {"default": {"styles": {"word-break": "break-all"}}},
                    },
                },
                {
                    "content_block_type": "string_template",
                    "styling": {"parent": {"classes": []}},
                    "string_template": {
                        "template": "$value",
                        "params": {"value": "Titanic"},
                        "styling": {"default": {"styles": {"word-break": "break-all"}}},
                    },
                },
            ],
            [
                {
                    "content_block_type": "string_template",
                    "styling": {"parent": {"classes": ["pr-3"]}},
                    "string_template": {
                        "template": "$value",
                        "params": {"value": "path"},
                        "styling": {"default": {"styles": {"word-break": "break-all"}}},
                    },
                },
                {
                    "content_block_type": "string_template",
                    "styling": {"parent": {"classes": []}},
                    "string_template": {
                        "template": "$value",
                        "params": {
                            "value": "project_dir/project_path/data/titanic/Titanic.csv"
                        },
                        "styling": {"default": {"styles": {"word-break": "break-all"}}},
                    },
                },
            ],
            [
                {
                    "content_block_type": "string_template",
                    "styling": {"parent": {"classes": ["pr-3"]}},
                    "string_template": {
                        "template": "$value",
                        "params": {"value": "reader_options"},
                        "styling": {"default": {"styles": {"word-break": "break-all"}}},
                    },
                },
                {
                    "content_block_type": "table",
                    "styling": {
                        "classes": ["col-6", "table-responsive"],
                        "body": {"classes": ["table", "table-sm", "m-0"]},
                        "parent": {"classes": ["pt-0", "pl-0", "border-top-0"]},
                    },
                    "table": [
                        [
                            {
                                "content_block_type": "string_template",
                                "styling": {"parent": {"classes": ["pr-3"]}},
                                "string_template": {
                                    "template": "$value",
                                    "params": {"value": "engine"},
                                    "styling": {
                                        "default": {
                                            "styles": {"word-break": "break-all"}
                                        }
                                    },
                                },
                            },
                            {
                                "content_block_type": "string_template",
                                "styling": {"parent": {"classes": []}},
                                "string_template": {
                                    "template": "$value",
                                    "params": {"value": "python"},
                                    "styling": {
                                        "default": {
                                            "styles": {"word-break": "break-all"}
                                        }
                                    },
                                },
                            },
                        ],
                        [
                            {
                                "content_block_type": "string_template",
                                "styling": {"parent": {"classes": ["pr-3"]}},
                                "string_template": {
                                    "template": "$value",
                                    "params": {"value": "sep"},
                                    "styling": {
                                        "default": {
                                            "styles": {"word-break": "break-all"}
                                        }
                                    },
                                },
                            },
                            {
                                "content_block_type": "string_template",
                                "styling": {"parent": {"classes": []}},
                                "string_template": {
                                    "template": "$value",
                                    "params": {"value": "None"},
                                    "styling": {
                                        "default": {
                                            "styles": {"word-break": "break-all"}
                                        }
                                    },
                                },
                            },
                        ],
                    ],
                },
            ],
        ],
    }

    assert batch_kwargs_table == expected_batch_kwarg_table
def test_ValidationResultsPageRenderer_render_nested_table_from_dict(
        titanic_profiled_evrs_1):
    batch_kwargs_table = ValidationResultsPageRenderer._render_nested_table_from_dict(
        titanic_profiled_evrs_1["meta"]["batch_kwargs"], header="Batch Kwargs")
    print(json.dumps(batch_kwargs_table, indent=2))

    expected_batch_kwarg_table = {
        "content_block_type":
        "table",
        "header":
        "Batch Kwargs",
        "table":
        [[{
            "content_block_type": "string_template",
            "string_template": {
                "template": "$value",
                "params": {
                    "value": "partition_id"
                },
                "styling": {
                    "default": {
                        "styles": {
                            "word-break": "break-all"
                        }
                    }
                }
            },
            "styling": {
                "parent": {
                    "classes": ["pr-3"]
                }
            }
        },
          {
              "content_block_type": "string_template",
              "string_template": {
                  "template": "$value",
                  "params": {
                      "value": "Titanic"
                  },
                  "styling": {
                      "default": {
                          "styles": {
                              "word-break": "break-all"
                          }
                      }
                  }
              },
              "styling": {
                  "parent": {
                      "classes": []
                  }
              }
          }],
         [{
             "content_block_type": "string_template",
             "string_template": {
                 "template": "$value",
                 "params": {
                     "value":
                     "path"
                 },
                 "styling": {
                     "default": {
                         "styles": {
                             "word-break": "break-all"
                         }
                     }
                 }
             },
             "styling": {
                 "parent": {
                     "classes": ["pr-3"]
                 }
             }
         }, {
             "content_block_type": "string_template",
             "string_template": {
                 "template": "$value",
                 "params":
                 {
                     "value":
                     "project_dir/project_path/data/titanic/Titanic.csv"
                 },
                 "styling": {
                     "default": {
                         "styles": {
                             "word-break": "break-all"
                         }
                     }
                 }
             },
             "styling": {
                 "parent": {
                     "classes": []
                 }
             }
         }],
         [{
             "content_block_type": "string_template",
             "string_template": {
                 "template": "$value",
                 "params": {
                     "value": "reader_options"
                 },
                 "styling": {
                     "default": {
                         "styles": {
                             "word-break": "break-all"
                         }
                     }
                 }
             },
             "styling": {
                 "parent": {
                     "classes": ["pr-3"]
                 }
             }
         }, {
             "content_block_type":
             "table",
             "table": [[{
                 "content_block_type": "string_template",
                 "string_template": {
                     "template": "$value",
                     "params": {
                         "value": "engine"
                     },
                     "styling": {
                         "default": {
                             "styles": {
                                 "word-break": "break-all"
                             }
                         }
                     }
                 },
                 "styling": {
                     "parent": {
                         "classes": ["pr-3"]
                     }
                 }
             }, {
                 "content_block_type": "string_template",
                 "string_template": {
                     "template": "$value",
                     "params": {
                         "value": "python"
                     },
                     "styling": {
                         "default": {
                             "styles": {
                                 "word-break": "break-all"
                             }
                         }
                     }
                 },
                 "styling": {
                     "parent": {
                         "classes": []
                     }
                 }
             }],
                       [{
                           "content_block_type": "string_template",
                           "string_template": {
                               "template": "$value",
                               "params": {
                                   "value": "sep"
                               },
                               "styling": {
                                   "default": {
                                       "styles": {
                                           "word-break": "break-all"
                                       }
                                   }
                               }
                           },
                           "styling": {
                               "parent": {
                                   "classes": ["pr-3"]
                               }
                           }
                       }, {
                           "content_block_type": "string_template",
                           "string_template": {
                               "template": "$value",
                               "params": {
                                   "value": "None"
                               },
                               "styling": {
                                   "default": {
                                       "styles": {
                                           "word-break": "break-all"
                                       }
                                   }
                               }
                           },
                           "styling": {
                               "parent": {
                                   "classes": []
                               }
                           }
                       }]],
             "styling": {
                 "classes": ["col-12", "table-responsive"],
                 "body": {
                     "classes": ["table", "table-sm", "m-0"]
                 },
                 "parent": {
                     "classes": ["pt-0", "pl-0", "border-top-0"]
                 }
             }
         }]],
        "styling": {
            "classes": ["col-12", "table-responsive"],
            "styles": {
                "margin-top": "20px"
            },
            "body": {
                "classes": ["table", "table-sm"]
            }
        }
    }

    assert batch_kwargs_table == expected_batch_kwarg_table