@@ -473,6 +473,129 @@ def MockClient(project=None):
473473 mock_client .insert_rows .assert_called_with (
474474 store ._release_time_table , [row_release_time ])
475475
476+ def test_save_compatibility_statuses_release_time_for_latest_many_packages (
477+ self ):
478+ mock_client = mock .Mock ()
479+ timestamp = '2018-07-17 03:01:06.11693 UTC'
480+ status = compatibility_store .Status .SUCCESS
481+ apache_beam_py2 = mock .Mock (
482+ packages = [package .Package ('apache-beam[gcp]' )],
483+ python_major_version = '2' ,
484+ status = status ,
485+ details = None ,
486+ dependency_info = {
487+ 'six' : {
488+ 'installed_version' : '9.9.9' ,
489+ 'installed_version_time' : '2018-05-12T16:26:31' ,
490+ 'latest_version' : '2.7.0' ,
491+ 'current_time' : '2018-07-13T17:11:29.140608' ,
492+ 'latest_version_time' : '2018-05-12T16:26:31' ,
493+ 'is_latest' : False ,
494+ } ,
495+ 'apache-beam' : {
496+ 'installed_version' : '2.7.0' ,
497+ 'installed_version_time' : '2018-05-12T16:26:31' ,
498+ 'latest_version' : '2.7.0' ,
499+ 'current_time' : '2018-07-13T17:11:29.140608' ,
500+ 'latest_version_time' : '2018-05-12T16:26:31' ,
501+ 'is_latest' : True ,
502+ }},
503+ timestamp = timestamp )
504+ apache_beam_py3 = mock .Mock (
505+ packages = [package .Package ('apache-beam[gcp]' )],
506+ python_major_version = '3' ,
507+ status = status ,
508+ details = None ,
509+ dependency_info = {'apache-beam' : {
510+ 'installed_version' : '2.2.0' ,
511+ 'installed_version_time' : '2018-05-12T16:26:31' ,
512+ 'latest_version' : '2.7.0' ,
513+ 'current_time' : '2018-07-13T17:11:29.140608' ,
514+ 'latest_version_time' : '2018-05-12T16:26:31' ,
515+ 'is_latest' : False ,
516+ }},
517+ timestamp = timestamp )
518+ google_api_core_py2 = mock .Mock (
519+ packages = [package .Package ('google-api-core' )],
520+ python_major_version = '2' ,
521+ status = status ,
522+ details = None ,
523+ dependency_info = {
524+ 'google-api-core' : {
525+ 'installed_version' : '3.7.0' ,
526+ 'installed_version_time' : '2018-05-12T16:26:31' ,
527+ 'latest_version' : '2.7.0' ,
528+ 'current_time' : '2018-07-13T17:11:29.140608' ,
529+ 'latest_version_time' : '2018-05-12T16:26:31' ,
530+ 'is_latest' : True ,
531+ }},
532+ timestamp = timestamp )
533+ google_api_core_py3 = mock .Mock (
534+ packages = [package .Package ('google-api-core' )],
535+ python_major_version = '3' ,
536+ status = status ,
537+ details = None ,
538+ dependency_info = {'google-api-core' : {
539+ 'installed_version' : '3.7.1' ,
540+ 'installed_version_time' : '2018-05-12T16:26:31' ,
541+ 'latest_version' : '2.7.0' ,
542+ 'current_time' : '2018-07-13T17:11:29.140608' ,
543+ 'latest_version_time' : '2018-05-12T16:26:31' ,
544+ 'is_latest' : False ,
545+ }},
546+ timestamp = timestamp )
547+
548+ apache_beam_row = {
549+ 'install_name' : 'apache-beam[gcp]' ,
550+ 'dep_name' : 'apache-beam' ,
551+ 'installed_version' : '2.7.0' ,
552+ 'installed_version_time' : '2018-05-12T16:26:31' ,
553+ 'latest_version' : '2.7.0' ,
554+ 'latest_version_time' : '2018-05-12T16:26:31' ,
555+ 'is_latest' : True ,
556+ 'timestamp' : '2018-07-13T17:11:29.140608' ,
557+ }
558+
559+ six_row = {
560+ 'install_name' : 'apache-beam[gcp]' ,
561+ 'dep_name' : 'six' ,
562+ 'installed_version' : '9.9.9' ,
563+ 'installed_version_time' : '2018-05-12T16:26:31' ,
564+ 'latest_version' : '2.7.0' ,
565+ 'latest_version_time' : '2018-05-12T16:26:31' ,
566+ 'is_latest' : False ,
567+ 'timestamp' : '2018-07-13T17:11:29.140608' ,
568+ }
569+
570+ google_api_core_row = {
571+ 'install_name' : 'google-api-core' ,
572+ 'dep_name' : 'google-api-core' ,
573+ 'installed_version' : '3.7.1' ,
574+ 'installed_version_time' : '2018-05-12T16:26:31' ,
575+ 'latest_version' : '2.7.0' ,
576+ 'latest_version_time' : '2018-05-12T16:26:31' ,
577+ 'is_latest' : False ,
578+ 'timestamp' : '2018-07-13T17:11:29.140608' ,
579+ }
580+
581+ def MockClient (project = None ):
582+ return mock_client
583+
584+ patch_client = mock .patch (
585+ 'compatibility_lib.compatibility_store.bigquery.Client' ,
586+ MockClient )
587+
588+ with patch_client :
589+ store = compatibility_store .CompatibilityStore ()
590+ store .save_compatibility_statuses (
591+ [apache_beam_py2 ,
592+ apache_beam_py3 ,
593+ google_api_core_py2 ,
594+ google_api_core_py3 ])
595+
596+ mock_client .insert_rows .assert_called_with (
597+ store ._release_time_table ,
598+ [apache_beam_row , six_row , google_api_core_row ])
476599
477600class MockClient (object ):
478601
0 commit comments