strip: a route to allow stripping series from the http client
2 files changed, 50 insertions(+), 0 deletions(-)

M test/test_api.py
M tshistory_rest/blueprint.py
M test/test_api.py +33 -0
@@ 459,6 459,38 @@ def test_rename(client):
     }
 
 
+
+def test_strip(client):
+    series_in = genserie(utcdt(2021, 1, 1), 'H', 3)
+    res = client.patch('/series/state', params={
+        'name': 'stripme',
+        'series': util.tojson(series_in),
+        'author': 'Babar',
+        'insertion_date': utcdt(2021, 1, 1),
+        'tzaware': util.tzaware_serie(series_in)
+    })
+    series_in = genserie(utcdt(2021, 1, 2), 'H', 3)
+    res = client.patch('/series/state', params={
+        'name': 'stripme',
+        'series': util.tojson(series_in),
+        'author': 'Babar',
+        'insertion_date': utcdt(2021, 1, 2),
+        'tzaware': util.tzaware_serie(series_in)
+    })
+
+    res = client.put('/series/strip', params={
+        'name': 'stripme',
+        'insertion_date': utcdt(2021, 1, 2)
+    })
+    assert res.status_code == 204
+
+    res = client.get('/series/insertion_dates', params={
+        'name': 'stripme'
+    })
+    idates = json.loads(res.text)['insertion_dates']
+    assert len(idates) == 1
+
+
 def test_staircase(client):
     # each days we insert 7 data points
     for idate in pd.date_range(start=utcdt(2015, 1, 1),

          
@@ 667,6 699,7 @@ def test_multisource(client, engine):
             ['test-naive', 'primary'],
             ['test2', 'primary'],
             ['test3', 'primary'],
+            ['stripme', 'primary'],
             ['staircase', 'primary'],
             ['test_fast', 'primary'],
             ['test-multi', 'primary']

          
M tshistory_rest/blueprint.py +17 -0
@@ 176,6 176,12 @@ catalog.add_argument(
     'allsources', type=inputs.boolean, default=True
 )
 
+strip = base.copy()
+strip.add_argument(
+    'insertion_date', type=utcdt, default=None
+)
+
+
 # supervision
 
 edited = base.copy()

          
@@ 444,6 450,17 @@ class httpapi:
 
                 return no_content()
 
+        @ns.route('/strip')
+        class timeseries_strip(Resource):
+
+            @api.expect(strip)
+            @onerror
+            def put(self):
+                args = strip.parse_args()
+                tsa.strip(args.name, args.insertion_date)
+                return no_content()
+
+
         @ns.route('/insertion_dates')
         class timeseries_idates(Resource):