def test_filter_auto_renew(self):
   filter = Filter()
   res = filter.in_filter("A", "B", "C", dimension='links')
   res.to_dict()
   res2 = filter.in_filter("D","E", dimension='links')
   expected2 = {
     'filter': {
       'type': 'in',
       'dimension': 'links',
       'values': ['D', 'E']
     }
   }
   self.assertEqual(res2.to_dict(), expected2)
 def test_filter_auto_renew2(self):
   filter = Filter()
   res = ~filter.selector(dimension='country_name', value='AUSTRALIA')
   res.to_dict()
   res2 = filter.in_filter("D", "E", dimension='links')
   expected_logic = None
   self.assertEqual(res2._logic, expected_logic)
 def test_in_filter(self):
   filter = Filter()
   res = filter.in_filter("A", "B", "C", dimension='links')
   expected = {
     'filter': {
       'type': 'in',
       'dimension': 'links',
       'values': ['A', 'B', 'C']
     }
   }
   self.assertEqual(res.to_dict(), expected)
    def test_query3(self):
        query = BasicQuery('linkmeta')
        query.dates(begin_date="2019-07-01", end_date="2019-07-28")
        query.time_series_reference("arrival")
        query.granularity(period="P7D")
        filter = Filter()
        query.filter(
            filter.in_filter("VIC17483860",
                             "VIC6052402",
                             "NSW500187142",
                             dimension="link_id"))
        query.aggregate(metric="unique_agents", described_as="unique_agents")
        query.aggregate(metric="total_records")
        query.dumps()

        expected = {
            "dates": {
                "beginDate": "2019-07-01",
                "endDate": "2019-07-28",
                "type": "range"
            },
            "aggregations": [{
                "metric": "unique_agents",
                "type": "hyperUnique",
                "describedAs": "unique_agents"
            }, {
                "metric": "total_records",
                "type": "longSum"
            }],
            "queryGranularity": {
                "period": "P7D",
                "type": "period",
                "timeZone": "Australia/Sydney"
            },
            "filter": {
                "dimension": "link_id",
                "type": "in",
                "values": ["VIC17483860", "VIC6052402", "NSW500187142"]
            },
            "timeSeriesReference":
            "arrival"
        }

        self.assertEqual(query._req, expected)