def testStoredOperationsQueryStringOneDay(self):
   date = datetime.datetime(2014, 1, 16)
   query_str = GceZoneOperationsInput._StoredOperationsQueryString(
       'ds', 'tb', 'zn', date, 1)
   self.assertEqual('SELECT id, insertTime FROM [ds.tb] WHERE '
                    'zoneName = \'zn\' AND DATE(insertTime) = \'2014-01-16\' '
                    'ORDER BY insertTime DESC', query_str)
 def testStoredOperationsQueryStringOneDay(self):
     date = datetime.datetime(2014, 1, 16)
     query_str = GceZoneOperationsInput._StoredOperationsQueryString("ds", "tb", "zn", date, 1)
     self.assertEqual(
         "SELECT id, insertTime FROM [ds.tb] WHERE "
         "zoneName = 'zn' AND DATE(insertTime) = '2014-01-16' "
         "ORDER BY insertTime DESC",
         query_str,
     )
 def testValidateBigQueryIdBadId(self):
   test_input = GceZoneOperationsInput({})
   self.assertRaises(ValueError, test_input.ValidateBigQueryId, 'table$id')
   self.assertRaises(ValueError, test_input.ValidateBigQueryId, '123-table')
   self.assertRaises(ValueError, test_input.ValidateBigQueryId, '123:table')
   self.assertRaises(ValueError, test_input.ValidateBigQueryId, '')
 def testValidateBigQueryId(self):
   test_input = GceZoneOperationsInput({})
   # If valid, function did not raise an exception and return None.
   self.assertIsNone(test_input.ValidateBigQueryId('table'))
   self.assertIsNone(test_input.ValidateBigQueryId('test_table'))
   self.assertIsNone(test_input.ValidateBigQueryId('test_table_1'))
 def testListZoneOperationsFilterThreeDays(self):
   date = datetime.datetime(2014, 1, 16)
   filter_str = GceZoneOperationsInput._ListZoneOperationsFilter(
       date, num_days=3)
   self.assertEqual('insertTime eq 2014-01-16.*|2014-01-15.*|2014-01-14.*',
                    filter_str)
 def testListZoneOperationsFilterThreeDays(self):
     date = datetime.datetime(2014, 1, 16)
     filter_str = GceZoneOperationsInput._ListZoneOperationsFilter(date, num_days=3)
     self.assertEqual("insertTime eq 2014-01-16.*|2014-01-15.*|2014-01-14.*", filter_str)