@@ -675,7 +675,9 @@ def _verifyResourceProperties(self, job, resource):
675
675
self .assertEqual (job .destination .dataset_name , table_ref ['datasetId' ])
676
676
self .assertEqual (job .destination .name , table_ref ['tableId' ])
677
677
678
- sources = config ['sourceTables' ]
678
+ sources = config .get ('sourceTables' )
679
+ if sources is None :
680
+ sources = [config ['sourceTable' ]]
679
681
self .assertEqual (len (sources ), len (job .sources ))
680
682
for table_ref , table in zip (sources , job .sources ):
681
683
self .assertEqual (table .project , table_ref ['projectId' ])
@@ -764,6 +766,35 @@ def test_from_api_repr_bare(self):
764
766
self .assertIs (job ._client , client )
765
767
self ._verifyResourceProperties (job , RESOURCE )
766
768
769
+ def test_from_api_repr_w_sourcetable (self ):
770
+ self ._setUpConstants ()
771
+ client = _Client (self .PROJECT )
772
+ RESOURCE = {
773
+ 'id' : self .JOB_ID ,
774
+ 'jobReference' : {
775
+ 'projectId' : self .PROJECT ,
776
+ 'jobId' : self .JOB_NAME ,
777
+ },
778
+ 'configuration' : {
779
+ 'copy' : {
780
+ 'sourceTable' : {
781
+ 'projectId' : self .PROJECT ,
782
+ 'datasetId' : self .DS_NAME ,
783
+ 'tableId' : self .SOURCE_TABLE ,
784
+ },
785
+ 'destinationTable' : {
786
+ 'projectId' : self .PROJECT ,
787
+ 'datasetId' : self .DS_NAME ,
788
+ 'tableId' : self .DESTINATION_TABLE ,
789
+ },
790
+ }
791
+ },
792
+ }
793
+ klass = self ._get_target_class ()
794
+ job = klass .from_api_repr (RESOURCE , client = client )
795
+ self .assertIs (job ._client , client )
796
+ self ._verifyResourceProperties (job , RESOURCE )
797
+
767
798
def test_from_api_repr_w_properties (self ):
768
799
client = _Client (self .PROJECT )
769
800
RESOURCE = self ._makeResource ()
0 commit comments