Ejemplo n.º 1
0
def test_create_power_report_from_csv_with_bad_timestamp_format_raise_BadInputData():
    csv_lines = [("power",
                  {
                      "timestamp": '1970-09-01T090909.543',
                      "sensor": "formula_group",
                      "target": "all",
                      "power": 42
                  }
                  )
                 ]
    with pytest.raises(BadInputData):
        report = PowerReport.from_csv_lines(csv_lines)
Ejemplo n.º 2
0
def test_create_power_report_from_csv_with_one_lines_create_an_power_report():
    csv_lines = [("power",
                  {
            "timestamp": "2021-09-14T12:37:37.168817",
            "sensor": "formula_group",
            "target": "all",
            "power": 42
                  }
                  )
                 ]
    report = PowerReport.from_csv_lines(csv_lines)
    assert isinstance(report, PowerReport)
Ejemplo n.º 3
0
def test_create_report_from_csv_with_metadata():
    csv_lines = [("power",
                  {
                      "timestamp": "2021-09-14T12:37:37.168817",
                      "sensor": "formula_group",
                      "target": "all",
                      "power": 42,
                      "tag":1
                  }
                  )
                 ]
    report = PowerReport.from_csv_lines(csv_lines)
    assert report.metadata["tag"] == 1
Ejemplo n.º 4
0
def test_create_power_report_from_csv_with_two_lines_raise_BadInputData():
    csv_lines = [("power",
                  {
            "timestamp": "2021-09-14T12:37:37.168817",
            "sensor": "formula_group",
            "target": "all",
            "power": 42
                  }
                  ),
                 ("power",
                  {
            "timestamp": "2021-09-14T12:37:37.168817",
            "sensor": "formula_group",
            "target": "all",
            "power": 42
                  }
                  )
                 ]
    with pytest.raises(BadInputData):
        report = PowerReport.from_csv_lines(csv_lines)