@@ -189,6 +189,67 @@ async def test_timeseries_detail(client: AsyncClient) -> None:
189189 }
190190
191191
192+ @pytest .mark .asyncio
193+ async def test_timeseries_join_style (client : AsyncClient ) -> None :
194+ r = await client .get (
195+ "/api/datalink/timeseries" ,
196+ params = {
197+ "id" : 18446744073709551617 ,
198+ "table" : "dp1.ForcedSource" ,
199+ "id_column" : "diaObjectId" ,
200+ "detail" : "principal" ,
201+ "join_time_column" : "dp1.CcdVisit.expMidptMJD" ,
202+ "join_style" : "ccdVisit" ,
203+ },
204+ )
205+ assert r .status_code == 307
206+ url = urlparse (r .headers ["Location" ])
207+ assert url .path == "/api/tap/sync"
208+ query = parse_qs (url .query )
209+ assert query == {
210+ "LANG" : ["ADQL" ],
211+ "REQUEST" : ["doQuery" ],
212+ "QUERY" : [
213+ (
214+ "SELECT t.expMidptMJD,s.band,s.detector,s.objectId,"
215+ "s.psfDiffFlux,s.psfDiffFluxErr,s.psfFlux,s.psfFluxErr,s.visit"
216+ " FROM dp1.ForcedSource"
217+ " AS s JOIN dp1.CcdVisit AS t ON s.ccdVisitId = t.ccdVisitId"
218+ " WHERE s.diaObjectId = 18446744073709551617"
219+ )
220+ ],
221+ }
222+
223+ r = await client .get (
224+ "/api/datalink/timeseries" ,
225+ params = {
226+ "id" : 18446744073709551617 ,
227+ "table" : "dp1.ForcedSource" ,
228+ "id_column" : "diaObjectId" ,
229+ "detail" : "principal" ,
230+ "join_time_column" : "dp1.CcdVisit.expMidptMJD" ,
231+ "join_style" : "visit_detector" ,
232+ },
233+ )
234+ assert r .status_code == 307
235+ url = urlparse (r .headers ["Location" ])
236+ assert url .path == "/api/tap/sync"
237+ query = parse_qs (url .query )
238+ assert query == {
239+ "LANG" : ["ADQL" ],
240+ "REQUEST" : ["doQuery" ],
241+ "QUERY" : [
242+ (
243+ "SELECT t.expMidptMJD,s.band,s.detector,s.objectId,"
244+ "s.psfDiffFlux,s.psfDiffFluxErr,s.psfFlux,s.psfFluxErr,s.visit"
245+ " FROM dp1.ForcedSource AS s JOIN dp1.CcdVisit AS t"
246+ " ON (s.visit = t.visitId AND s.detector = t.detector)"
247+ " WHERE s.diaObjectId = 18446744073709551617"
248+ )
249+ ],
250+ }
251+
252+
192253@pytest .mark .asyncio
193254async def test_links (
194255 client : AsyncClient , mock_butler : MockButler , mock_discovery : Discovery
0 commit comments