@@ -395,14 +395,29 @@ def test_from_api_repr_w_properties(self):
395395 self .assertIs (table ._dataset ._client , client )
396396 self ._verifyResourceProperties (table , RESOURCE )
397397
398- def test_create_no_view_query_no_schema (self ):
399- conn = _Connection ()
398+ def test_create_new_day_partitioned_table (self ):
399+ PATH = 'projects/%s/datasets/%s/tables' % (self .PROJECT , self .DS_NAME )
400+ RESOURCE = self ._makeResource ()
401+ conn = _Connection (RESOURCE )
400402 client = _Client (project = self .PROJECT , connection = conn )
401403 dataset = _Dataset (client )
402404 table = self ._make_one (self .TABLE_NAME , dataset )
405+ table .partitioning_type = 'DAY'
406+ table .create ()
403407
404- with self .assertRaises (ValueError ):
405- table .create ()
408+ self .assertEqual (len (conn ._requested ), 1 )
409+ req = conn ._requested [0 ]
410+ self .assertEqual (req ['method' ], 'POST' )
411+ self .assertEqual (req ['path' ], '/%s' % PATH )
412+ SENT = {
413+ 'tableReference' : {
414+ 'projectId' : self .PROJECT ,
415+ 'datasetId' : self .DS_NAME ,
416+ 'tableId' : self .TABLE_NAME },
417+ 'timePartitioning' : {'type' : 'DAY' },
418+ }
419+ self .assertEqual (req ['data' ], SENT )
420+ self ._verifyResourceProperties (table , RESOURCE )
406421
407422 def test_create_w_bound_client (self ):
408423 from google .cloud .bigquery .table import SchemaField
@@ -647,7 +662,6 @@ def test_create_w_alternate_client(self):
647662 import datetime
648663 from google .cloud ._helpers import UTC
649664 from google .cloud ._helpers import _millis
650- from google .cloud .bigquery .table import SchemaField
651665
652666 PATH = 'projects/%s/datasets/%s/tables' % (self .PROJECT , self .DS_NAME )
653667 DESCRIPTION = 'DESCRIPTION'
@@ -667,10 +681,7 @@ def test_create_w_alternate_client(self):
667681 conn2 = _Connection (RESOURCE )
668682 client2 = _Client (project = self .PROJECT , connection = conn2 )
669683 dataset = _Dataset (client = client1 )
670- full_name = SchemaField ('full_name' , 'STRING' , mode = 'REQUIRED' )
671- age = SchemaField ('age' , 'INTEGER' , mode = 'REQUIRED' )
672- table = self ._make_one (self .TABLE_NAME , dataset = dataset ,
673- schema = [full_name , age ])
684+ table = self ._make_one (self .TABLE_NAME , dataset = dataset )
674685 table .friendly_name = TITLE
675686 table .description = DESCRIPTION
676687 table .view_query = QUERY
0 commit comments