def test_get_time_grain_with_unkown_values(self):
     """ Should concatenate from configs and then sort in the proper order
     putting unknown patterns at the end """
     app.config["TIME_GRAIN_ADDON_EXPRESSIONS"] = {
         "mysql": {
             "PT2H": "foo",
             "weird": "foo",
             "PT12H": "foo",
         }
     }
     time_grains = MySQLEngineSpec.get_time_grain_expressions()
     self.assertEqual(
         list(time_grains)[-1],
         "weird",
     )
     app.config["TIME_GRAIN_ADDON_EXPRESSIONS"] = {}
Exemple #2
0
 def test_get_time_grain_expressions(self):
     time_grains = MySQLEngineSpec.get_time_grain_expressions()
     self.assertEqual(
         list(time_grains.keys()),
         [
             None,
             "PT1S",
             "PT1M",
             "PT1H",
             "P1D",
             "P1W",
             "P1M",
             "P3M",
             "P1Y",
             "1969-12-29T00:00:00Z/P1W",
         ],
     )
Exemple #3
0
def test_get_time_grain_with_unkown_values():
    """Should concatenate from configs and then sort in the proper order
    putting unknown patterns at the end"""
    config = app.config.copy()

    app.config["TIME_GRAIN_ADDON_EXPRESSIONS"] = {
        "mysql": {
            "PT2H": "foo",
            "weird": "foo",
            "PT12H": "foo",
        }
    }

    with app.app_context():
        time_grains = MySQLEngineSpec.get_time_grain_expressions()
        assert list(time_grains)[-1] == "weird"

    app.config = config
Exemple #4
0
def test_get_time_grain_with_config():
    """Should concatenate from configs and then sort in the proper order"""
    config = app.config.copy()

    app.config["TIME_GRAIN_ADDON_EXPRESSIONS"] = {
        "mysql": {
            "PT2H": "foo",
            "PT4H": "foo",
            "PT6H": "foo",
            "PT8H": "foo",
            "PT10H": "foo",
            "PT12H": "foo",
            "PT1S": "foo",
        }
    }

    with app.app_context():
        time_grains = MySQLEngineSpec.get_time_grain_expressions()
        assert set(time_grains.keys()) == {
            None,
            "PT1S",
            "PT1M",
            "PT1H",
            "PT2H",
            "PT4H",
            "PT6H",
            "PT8H",
            "PT10H",
            "PT12H",
            "P1D",
            "P1W",
            "P1M",
            "P3M",
            "P1Y",
            "1969-12-29T00:00:00Z/P1W",
        }

    app.config = config
 def test_get_time_grain_with_config(self):
     """ Should concatenate from configs and then sort in the proper order """
     app.config["TIME_GRAIN_ADDON_EXPRESSIONS"] = {
         "mysql": {
             "PT2H": "foo",
             "PT4H": "foo",
             "PT6H": "foo",
             "PT8H": "foo",
             "PT10H": "foo",
             "PT12H": "foo",
             "PT1S": "foo",
         }
     }
     time_grains = MySQLEngineSpec.get_time_grain_expressions()
     self.assertEqual(
         list(time_grains.keys()),
         [
             None,
             "PT1S",
             "PT1M",
             "PT1H",
             "PT2H",
             "PT4H",
             "PT6H",
             "PT8H",
             "PT10H",
             "PT12H",
             "P1D",
             "P1W",
             "P1M",
             "P0.25Y",
             "P1Y",
             "1969-12-29T00:00:00Z/P1W",
         ],
     )
     app.config["TIME_GRAIN_ADDON_EXPRESSIONS"] = {}