Ejemplo n.º 1
0
    def test_get_add_datasets(self):
        source_dataset1_1 = BigQueryDataset(dataset_id='test1',
                                            friendly_name='test_friendly_name',
                                            description='test_description',
                                            default_table_expiration_ms=24 *
                                            60 * 60 * 1000,
                                            location='US')
        source_dataset1_2 = BigQueryDataset(dataset_id='test2',
                                            friendly_name='foo_bar',
                                            description='fizz_buzz',
                                            default_table_expiration_ms=60 *
                                            60 * 1000,
                                            location='EU')

        target_dataset1_1 = BigQueryDataset(dataset_id='test1',
                                            friendly_name='test_friendly_name',
                                            description='test_description',
                                            default_table_expiration_ms=24 *
                                            60 * 60 * 1000,
                                            location='US')
        target_dataset1_2 = BigQueryDataset(dataset_id='test2',
                                            friendly_name='foo_bar',
                                            description='fizz_buzz',
                                            default_table_expiration_ms=60 *
                                            60 * 1000,
                                            location='EU')

        source1 = [source_dataset1_1]
        target1 = [target_dataset1_1, target_dataset1_2]
        actual_count1, actual_results1 = DatasetAction.get_add_datasets(
            source1, target1)
        self.assertEqual(actual_count1, 1)
        self.assertEqual(actual_results1, (target_dataset1_2, ))

        source2 = [source_dataset1_1, source_dataset1_2]
        target2 = [target_dataset1_1, target_dataset1_2]
        actual_count2, actual_results2 = DatasetAction.get_add_datasets(
            source2, target2)
        self.assertEqual(actual_count2, 0)
        self.assertEqual(actual_results2, ())

        source3 = [source_dataset1_1, source_dataset1_2]
        target3 = [target_dataset1_1]
        actual_count3, actual_results3 = DatasetAction.get_add_datasets(
            source3, target3)
        self.assertEqual(actual_count3, 0)
        self.assertEqual(actual_results3, ())
 def get_dataset(self, dataset_id):
     dataset_ref = self._client.dataset(dataset_id)
     dataset = None
     try:
         dataset = self._client.get_dataset(dataset_ref)
         echo('Load dataset: ' + dataset.path)
         dataset = BigQueryDataset.from_dataset(dataset)
     except NotFound:
         _logger.info('Dataset {0} is not found.'.format(dataset_id))
     return dataset
 def _add(self, model, prefix='  ', fg='green'):
     dataset = BigQueryDataset.to_dataset(self._client.project, model)
     echo('Adding... {0}'.format(dataset.path),
          prefix=prefix, fg=fg, no_color=self.no_color)
     echo_dump(model, prefix=prefix + '  ', fg=fg, no_color=self.no_color)
     self._client.create_dataset(dataset)
     self._client.update_dataset(dataset, [
         'access_entries'
     ])
     echo()
 def _change(self, source_model, target_model, prefix='  ', fg='yellow'):
     dataset = BigQueryDataset.to_dataset(self._client.project, target_model)
     echo('Changing... {0}'.format(dataset.path),
          prefix=prefix, fg=fg, no_color=self.no_color)
     echo_ndiff(source_model, target_model, prefix=prefix + '  ', fg=fg)
     source_labels = source_model.labels
     if source_labels:
         labels = dataset.labels.copy()
         for k, v in iteritems(source_labels):
             if k not in labels.keys():
                 labels[k] = None
         dataset.labels = labels
     self._client.update_dataset(dataset, [
         'friendly_name',
         'description',
         'default_table_expiration_ms',
         'labels',
         'access_entries'
     ])
     echo()
Ejemplo n.º 5
0
def load_dataset(conf):
    from bqdm.model.dataset import BigQueryDataset

    echo('Load dataset config: {0}'.format(conf))
    with codecs.open(conf, 'rb', 'utf-8') as f:
        return BigQueryDataset.from_dict(yaml.load(f))
    def test_dump_dataset(self):
        dataset1 = BigQueryDataset(dataset_id='test1',
                                   friendly_name='test_friendly_name',
                                   description='test_description',
                                   default_table_expiration_ms=24 * 30 * 60 *
                                   1000,
                                   location='US')
        expected_dump_data1 = """dataset_id: test1
friendly_name: test_friendly_name
description: test_description
default_table_expiration_ms: 43200000
location: US
access_entries: null
labels: null
"""
        actual_dump_data1 = dump(dataset1)
        self.assertEqual(expected_dump_data1, actual_dump_data1)

        access_entry2 = BigQueryAccessEntry('OWNER', 'specialGroup',
                                            'projectOwners')
        dataset2 = BigQueryDataset(dataset_id='test2',
                                   friendly_name='test_friendly_name',
                                   description='test_description',
                                   default_table_expiration_ms=24 * 30 * 60 *
                                   1000,
                                   location='US',
                                   access_entries=(access_entry2, ))
        expected_dump_data2 = """dataset_id: test2
friendly_name: test_friendly_name
description: test_description
default_table_expiration_ms: 43200000
location: US
access_entries:
-   role: OWNER
    entity_type: specialGroup
    entity_id: projectOwners
labels: null
"""
        actual_dump_data2 = dump(dataset2)
        self.assertEqual(expected_dump_data2, actual_dump_data2)

        access_entry3 = BigQueryAccessEntry(
            None, 'view', {
                'datasetId': 'test',
                'projectId': 'test-project',
                'tableId': 'test_table'
            })
        dataset3 = BigQueryDataset(dataset_id='test3',
                                   friendly_name='test_friendly_name',
                                   description='test_description',
                                   default_table_expiration_ms=24 * 30 * 60 *
                                   1000,
                                   location='US',
                                   access_entries=(access_entry3, ))
        expected_dump_data3 = """dataset_id: test3
friendly_name: test_friendly_name
description: test_description
default_table_expiration_ms: 43200000
location: US
access_entries:
-   role: null
    entity_type: view
    entity_id:
        datasetId: test
        projectId: test-project
        tableId: test_table
labels: null
"""
        actual_dump_data3 = dump(dataset3)
        self.assertEqual(expected_dump_data3, actual_dump_data3)

        dataset4 = BigQueryDataset(
            dataset_id='test4',
            friendly_name='test_friendly_name',
            description='test_description',
            default_table_expiration_ms=24 * 30 * 60 * 1000,
            location='US',
            access_entries=(access_entry2, access_entry3))
        expected_dump_data4 = """dataset_id: test4
friendly_name: test_friendly_name
description: test_description
default_table_expiration_ms: 43200000
location: US
access_entries:
-   role: OWNER
    entity_type: specialGroup
    entity_id: projectOwners
-   role: null
    entity_type: view
    entity_id:
        datasetId: test
        projectId: test-project
        tableId: test_table
labels: null
"""
        actual_dump_data4 = dump(dataset4)
        self.assertEqual(expected_dump_data4, actual_dump_data4)

        label5 = {'foo': 'bar'}
        dataset5 = BigQueryDataset(dataset_id='test5',
                                   friendly_name='test_friendly_name',
                                   description='test_description',
                                   default_table_expiration_ms=24 * 30 * 60 *
                                   1000,
                                   location='US',
                                   labels=label5)
        expected_dump_data5 = """dataset_id: test5
friendly_name: test_friendly_name
description: test_description
default_table_expiration_ms: 43200000
location: US
access_entries: null
labels:
    foo: bar
"""
        actual_dump_data5 = dump(dataset5)
        self.assertEqual(expected_dump_data5, actual_dump_data5)

        label6 = {'aaa': 'bbb', 'ccc': 'ddd'}
        dataset6 = BigQueryDataset(dataset_id='test6',
                                   friendly_name='test_friendly_name',
                                   description='test_description',
                                   default_table_expiration_ms=24 * 30 * 60 *
                                   1000,
                                   location='US',
                                   labels=label6)
        expected_dump_data6 = """dataset_id: test6
friendly_name: test_friendly_name
description: test_description
default_table_expiration_ms: 43200000
location: US
access_entries: null
labels:
    aaa: bbb
    ccc: ddd
"""
        actual_dump_data6 = dump(dataset6)
        self.assertEqual(expected_dump_data6, actual_dump_data6)
Ejemplo n.º 7
0
    def test_get_change_datasets(self):
        source_dataset1_1 = BigQueryDataset(dataset_id='test1',
                                            friendly_name='test_friendly_name',
                                            description='test_description',
                                            default_table_expiration_ms=24 *
                                            60 * 60 * 1000,
                                            location='US')
        source_dataset1_2 = BigQueryDataset(
            dataset_id='test2',
            friendly_name='test_friendly_name',
            description='test_description',
            default_table_expiration_ms=24 * 60 * 60 * 1000,
            location='US',
            access_entries=(BigQueryAccessEntry('OWNER', 'specialGroup',
                                                'projectOwners'), ))
        source_dataset1_3 = BigQueryDataset(dataset_id='test3',
                                            friendly_name='test_friendly_name',
                                            description='test_description',
                                            default_table_expiration_ms=24 *
                                            30 * 60 * 1000,
                                            location='US',
                                            labels={'foo': 'bar'})

        target_dataset1_1 = BigQueryDataset(dataset_id='test1',
                                            friendly_name='foo',
                                            description='bar',
                                            default_table_expiration_ms=60 *
                                            60 * 1000,
                                            location='UK')
        target_dataset1_2 = BigQueryDataset(
            dataset_id='test2',
            friendly_name='test_friendly_name',
            description='test_description',
            default_table_expiration_ms=24 * 60 * 60 * 1000,
            location='US',
            access_entries=(BigQueryAccessEntry('OWNER', 'specialGroup',
                                                'projectOwners'),
                            BigQueryAccessEntry(
                                None, 'view', {
                                    'datasetId': 'test',
                                    'projectId': 'test',
                                    'tableId': 'test_table'
                                })))
        target_dataset1_3 = BigQueryDataset(dataset_id='test3',
                                            friendly_name='test_friendly_name',
                                            description='test_description',
                                            default_table_expiration_ms=24 *
                                            60 * 60 * 1000,
                                            location='US',
                                            labels={
                                                'aaa': 'bbb',
                                                'ccc': 'ddd'
                                            })

        source1 = [source_dataset1_1, source_dataset1_2, source_dataset1_3]
        target1 = [target_dataset1_1, target_dataset1_2, target_dataset1_3]
        actual_count1, actual_results1 = DatasetAction.get_change_datasets(
            source1, target1)
        self.assertEqual(actual_count1, 3)
        self.assertEqual(
            set(actual_results1),
            {target_dataset1_1, target_dataset1_2, target_dataset1_3})

        source2 = [source_dataset1_3, source_dataset1_2, source_dataset1_1]
        target2 = [target_dataset1_1, target_dataset1_2, target_dataset1_3]
        actual_count2, actual_results2 = DatasetAction.get_change_datasets(
            source2, target2)
        self.assertEqual(actual_count2, 3)
        self.assertEqual(
            set(actual_results2),
            {target_dataset1_1, target_dataset1_2, target_dataset1_3})

        source3 = [source_dataset1_1, source_dataset1_2, source_dataset1_3]
        target3 = [source_dataset1_1, source_dataset1_2, source_dataset1_3]
        actual_count3, actual_results3 = DatasetAction.get_change_datasets(
            source3, target3)
        self.assertEqual(actual_count3, 0)
        self.assertEqual(actual_results3, ())

        source4 = [source_dataset1_1, source_dataset1_2, source_dataset1_3]
        target4 = [source_dataset1_3, source_dataset1_2, source_dataset1_1]
        actual_count4, actual_results4 = DatasetAction.get_change_datasets(
            source4, target4)
        self.assertEqual(actual_count4, 0)
        self.assertEqual(actual_results4, ())

        source5 = [target_dataset1_1, target_dataset1_2, target_dataset1_3]
        target5 = [target_dataset1_1, target_dataset1_2, target_dataset1_3]
        actual_count5, actual_results5 = DatasetAction.get_change_datasets(
            source5, target5)
        self.assertEqual(actual_count5, 0)
        self.assertEqual(actual_results5, ())

        source6 = [target_dataset1_1, target_dataset1_2, target_dataset1_3]
        target6 = [target_dataset1_3, target_dataset1_2, target_dataset1_1]
        actual_count6, actual_results6 = DatasetAction.get_change_datasets(
            source6, target6)
        self.assertEqual(actual_count6, 0)
        self.assertEqual(actual_results6, ())

        source7 = [source_dataset1_1, source_dataset1_2, source_dataset1_3]
        target7 = [target_dataset1_1, target_dataset1_2]
        actual_count7, actual_results7 = DatasetAction.get_change_datasets(
            source7, target7)
        self.assertEqual(actual_count7, 2)
        self.assertEqual(set(actual_results7),
                         {target_dataset1_1, target_dataset1_2})

        source8 = [source_dataset1_1, source_dataset1_2]
        target8 = [target_dataset1_1, target_dataset1_2, target_dataset1_3]
        actual_count8, actual_results8 = DatasetAction.get_change_datasets(
            source8, target8)
        self.assertEqual(actual_count8, 2)
        self.assertEqual(set(actual_results8),
                         {target_dataset1_1, target_dataset1_2})
Ejemplo n.º 8
0
    def test_get_intersection_datasets(self):
        source_dataset1_1 = BigQueryDataset(dataset_id='test1',
                                            friendly_name='test_friendly_name',
                                            description='test_description',
                                            default_table_expiration_ms=24 *
                                            60 * 60 * 1000,
                                            location='US')
        source_dataset1_2 = BigQueryDataset(dataset_id='test2',
                                            friendly_name='foo_bar',
                                            description='fizz_buzz',
                                            default_table_expiration_ms=60 *
                                            60 * 1000,
                                            location='EU')

        target_dataset1_1 = BigQueryDataset(dataset_id='test1',
                                            friendly_name='test_friendly_name',
                                            description='test_description',
                                            default_table_expiration_ms=24 *
                                            60 * 60 * 1000,
                                            location='US')
        target_dataset1_2 = BigQueryDataset(dataset_id='test2',
                                            friendly_name='foo_bar',
                                            description='fizz_buzz',
                                            default_table_expiration_ms=60 *
                                            60 * 1000,
                                            location='EU')

        source1 = [source_dataset1_1]
        target1 = [target_dataset1_1, target_dataset1_2]
        actual_count1, actual_results1 = DatasetAction.get_intersection_datasets(
            source1, target1)
        self.assertEqual(actual_count1, 1)
        self.assertEqual(actual_results1, (source_dataset1_1, ))

        source2 = [source_dataset1_1, source_dataset1_2]
        target2 = [target_dataset1_1, target_dataset1_2]
        actual_count2, actual_results2 = DatasetAction.get_intersection_datasets(
            source2, target2)
        self.assertEqual(actual_count2, 2)
        self.assertEqual(set(actual_results2),
                         {source_dataset1_1, source_dataset1_2})

        source3 = [source_dataset1_1, source_dataset1_2]
        target3 = [target_dataset1_1]
        actual_count3, actual_results3 = DatasetAction.get_intersection_datasets(
            source3, target3)
        self.assertEqual(actual_count3, 1)
        self.assertEqual(actual_results3, (source_dataset1_1, ))

        source4 = [source_dataset1_1, source_dataset1_2]
        target4 = []
        actual_count4, actual_results4 = DatasetAction.get_intersection_datasets(
            source4, target4)
        self.assertEqual(actual_count4, 0)
        self.assertEqual(actual_results4, ())

        source5 = []
        target5 = [target_dataset1_1, target_dataset1_2]
        actual_count5, actual_results5 = DatasetAction.get_intersection_datasets(
            source5, target5)
        self.assertEqual(actual_count5, 0)
        self.assertEqual(actual_results5, ())
 def _destroy(self, model, prefix='  ', fg='red'):
     datasetted = BigQueryDataset.to_dataset(self._client.project, model)
     echo('Destroying... {0}'.format(datasetted.path),
          prefix=prefix, fg=fg, no_color=self.no_color)
     self._client.delete_dataset(datasetted)
     echo()
    def test_to_dataset(self):
        project = 'test'

        expected_dataset1 = make_dataset(project=project,
                                         dataset_id='test',
                                         friendly_name='test_friendly_name',
                                         description='test_description',
                                         default_table_expiration_ms=24 * 60 *
                                         60 * 1000,
                                         location='US')
        actual_dataset1_1 = BigQueryDataset.to_dataset(
            project,
            BigQueryDataset(dataset_id='test',
                            friendly_name='test_friendly_name',
                            description='test_description',
                            default_table_expiration_ms=24 * 60 * 60 * 1000,
                            location='US'))
        self.assertEqual(expected_dataset1.dataset_id,
                         actual_dataset1_1.dataset_id)
        self.assertEqual(expected_dataset1.friendly_name,
                         actual_dataset1_1.friendly_name)
        self.assertEqual(expected_dataset1.description,
                         actual_dataset1_1.description)
        self.assertEqual(expected_dataset1.default_table_expiration_ms,
                         actual_dataset1_1.default_table_expiration_ms)
        self.assertEqual(expected_dataset1.location,
                         actual_dataset1_1.location)
        self.assertEqual(expected_dataset1.labels, actual_dataset1_1.labels)
        self.assertEqual(expected_dataset1.access_entries,
                         actual_dataset1_1.access_entries)
        actual_dataset1_2 = BigQueryDataset.to_dataset(
            project,
            BigQueryDataset(dataset_id='aaa',
                            friendly_name='foo_bar',
                            description='fizz_buzz',
                            default_table_expiration_ms=60 * 60 * 1000,
                            location='EU'))
        self.assertNotEqual(expected_dataset1.dataset_id,
                            actual_dataset1_2.dataset_id)
        self.assertNotEqual(expected_dataset1.friendly_name,
                            actual_dataset1_2.friendly_name)
        self.assertNotEqual(expected_dataset1.description,
                            actual_dataset1_2.description)
        self.assertNotEqual(expected_dataset1.default_table_expiration_ms,
                            actual_dataset1_2.default_table_expiration_ms)
        self.assertNotEqual(expected_dataset1.location,
                            actual_dataset1_2.location)
        self.assertEqual(expected_dataset1.labels, actual_dataset1_2.labels)
        self.assertEqual(expected_dataset1.access_entries,
                         actual_dataset1_2.access_entries)

        expected_dataset2 = make_dataset(
            project=project,
            dataset_id='test',
            friendly_name='test_friendly_name',
            description='test_description',
            default_table_expiration_ms=24 * 60 * 60 * 1000,
            location='US',
            access_entries=(AccessEntry('OWNER', 'specialGroup',
                                        'projectOwners'), ))
        actual_dataset2_1 = BigQueryDataset.to_dataset(
            project,
            BigQueryDataset(dataset_id='test',
                            friendly_name='test_friendly_name',
                            description='test_description',
                            default_table_expiration_ms=24 * 60 * 60 * 1000,
                            location='US',
                            access_entries=(BigQueryAccessEntry(
                                'OWNER', 'specialGroup', 'projectOwners'), )))
        self.assertEqual(expected_dataset2.access_entries,
                         actual_dataset2_1.access_entries)
        actual_dataset2_2 = BigQueryDataset.to_dataset(
            project,
            BigQueryDataset(dataset_id='test',
                            friendly_name='test_friendly_name',
                            description='test_description',
                            default_table_expiration_ms=24 * 60 * 60 * 1000,
                            location='US',
                            access_entries=(BigQueryAccessEntry(
                                None, 'view', {
                                    'datasetId': 'test',
                                    'projectId': 'test-project',
                                    'tableId': 'test_table'
                                }), )))
        self.assertNotEqual(expected_dataset2.access_entries,
                            actual_dataset2_2.access_entries)

        expected_dataset3 = make_dataset(project=project,
                                         dataset_id='test',
                                         friendly_name='test_friendly_name',
                                         description='test_description',
                                         default_table_expiration_ms=24 * 60 *
                                         60 * 1000,
                                         location='US',
                                         labels={'foo': 'bar'})
        actual_dataset3_1 = BigQueryDataset.to_dataset(
            project,
            BigQueryDataset(dataset_id='test',
                            friendly_name='test_friendly_name',
                            description='test_description',
                            default_table_expiration_ms=24 * 60 * 60 * 1000,
                            location='US',
                            labels={'foo': 'bar'}))
        self.assertEqual(expected_dataset3.labels, actual_dataset3_1.labels)
        actual_dataset3_2 = BigQueryDataset.to_dataset(
            project,
            BigQueryDataset(dataset_id='test',
                            friendly_name='test_friendly_name',
                            description='test_description',
                            default_table_expiration_ms=24 * 60 * 60 * 1000,
                            location='US',
                            labels={
                                'foo': 'bar',
                                'fizz': 'buzz'
                            }))
        self.assertNotEqual(expected_dataset3.labels, actual_dataset3_2.labels)
    def test_from_dict(self):
        expected_dataset1 = BigQueryDataset(dataset_id='test',
                                            friendly_name='test_friendly_name',
                                            description='test_description',
                                            default_table_expiration_ms=24 *
                                            60 * 60 * 1000,
                                            location='US')
        actual_dataset1_1 = BigQueryDataset.from_dict({
            'dataset_id':
            'test',
            'friendly_name':
            'test_friendly_name',
            'description':
            'test_description',
            'default_table_expiration_ms':
            24 * 60 * 60 * 1000,
            'location':
            'US',
            'labels':
            None,
            'access_entries':
            None
        })
        self.assertEqual(expected_dataset1, actual_dataset1_1)
        actual_dataset1_2 = BigQueryDataset.from_dict({
            'dataset_id':
            'test',
            'friendly_name':
            'foo_bar',
            'description':
            'fizz_buzz',
            'default_table_expiration_ms':
            60 * 60 * 1000,
            'location':
            'EU',
            'labels':
            None,
            'access_entries':
            None
        })
        self.assertNotEqual(expected_dataset1, actual_dataset1_2)

        expected_dataset2 = BigQueryDataset(
            dataset_id='test',
            friendly_name='test_friendly_name',
            description='test_description',
            default_table_expiration_ms=24 * 60 * 60 * 1000,
            location='US',
            access_entries=(BigQueryAccessEntry('OWNER', 'specialGroup',
                                                'projectOwners'), ))
        actual_dataset2_1 = BigQueryDataset.from_dict({
            'dataset_id':
            'test',
            'friendly_name':
            'test_friendly_name',
            'description':
            'test_description',
            'default_table_expiration_ms':
            24 * 60 * 60 * 1000,
            'location':
            'US',
            'labels':
            None,
            'access_entries': [
                {
                    'role': 'OWNER',
                    'entity_type': 'specialGroup',
                    'entity_id': 'projectOwners'
                },
            ]
        })
        self.assertEqual(expected_dataset2, actual_dataset2_1)
        actual_dataset2_2 = BigQueryDataset.from_dict({
            'dataset_id':
            'test',
            'friendly_name':
            'test_friendly_name',
            'description':
            'test_description',
            'default_table_expiration_ms':
            24 * 60 * 60 * 1000,
            'location':
            'US',
            'labels':
            None,
            'access_entries': [
                {
                    'role': None,
                    'entity_type': 'view',
                    'entity_id': {
                        'datasetId': 'test',
                        'projectId': 'test-project',
                        'tableId': 'test_table'
                    }
                },
            ]
        })
        self.assertNotEqual(expected_dataset2, actual_dataset2_2)

        expected_dataset3 = BigQueryDataset(dataset_id='test',
                                            friendly_name='test_friendly_name',
                                            description='test_description',
                                            default_table_expiration_ms=24 *
                                            60 * 60 * 1000,
                                            location='US',
                                            labels={'foo': 'bar'})
        actual_dataset3_1 = BigQueryDataset.from_dict({
            'dataset_id':
            'test',
            'friendly_name':
            'test_friendly_name',
            'description':
            'test_description',
            'default_table_expiration_ms':
            24 * 60 * 60 * 1000,
            'location':
            'US',
            'labels': {
                'foo': 'bar'
            },
            'access_entries':
            None
        })
        self.assertEqual(expected_dataset3, actual_dataset3_1)
        actual_dataset3_2 = BigQueryDataset.from_dict({
            'dataset_id':
            'test',
            'friendly_name':
            'test_friendly_name',
            'description':
            'test_description',
            'default_table_expiration_ms':
            24 * 60 * 60 * 1000,
            'location':
            'US',
            'labels': {
                'foo': 'bar',
                'fizz': 'buzz'
            },
            'access_entries':
            None
        })
        self.assertNotEqual(expected_dataset3, actual_dataset3_2)
    def test_eq(self):
        dataset1_1 = BigQueryDataset(dataset_id='test',
                                     friendly_name='test_friendly_name',
                                     description='test_description',
                                     default_table_expiration_ms=24 * 60 * 60 *
                                     1000,
                                     location='US')
        dataset1_2 = BigQueryDataset(dataset_id='test',
                                     friendly_name='test_friendly_name',
                                     description='test_description',
                                     default_table_expiration_ms=24 * 60 * 60 *
                                     1000,
                                     location='US')
        self.assertEqual(dataset1_1, dataset1_2)

        dataset2_1 = BigQueryDataset(dataset_id='test',
                                     friendly_name='test_friendly_name',
                                     description='test_description',
                                     default_table_expiration_ms=24 * 60 * 60 *
                                     1000,
                                     location='US')
        dataset2_2 = BigQueryDataset(dataset_id='test',
                                     friendly_name='fizz_buzz',
                                     description='foo_bar',
                                     default_table_expiration_ms=60 * 60 *
                                     1000,
                                     location='EU')
        self.assertNotEqual(dataset2_1, dataset2_2)

        access_entry1 = BigQueryAccessEntry('OWNER', 'specialGroup',
                                            'projectOwners')
        access_entry2 = BigQueryAccessEntry('OWNER', 'specialGroup',
                                            'projectOwners')
        access_entry3 = BigQueryAccessEntry(
            None, 'view', {
                'datasetId': 'test',
                'projectId': 'test-project',
                'tableId': 'test_table'
            })

        dataset3_1 = BigQueryDataset(dataset_id='test',
                                     friendly_name='test_friendly_name',
                                     description='test_description',
                                     default_table_expiration_ms=24 * 60 * 60 *
                                     1000,
                                     location='US',
                                     access_entries=(access_entry1, ))
        dataset3_2 = BigQueryDataset(dataset_id='test',
                                     friendly_name='test_friendly_name',
                                     description='test_description',
                                     default_table_expiration_ms=24 * 60 * 60 *
                                     1000,
                                     location='US',
                                     access_entries=(access_entry1, ))
        self.assertEqual(dataset3_1, dataset3_2)

        dataset4_1 = BigQueryDataset(dataset_id='test',
                                     friendly_name='test_friendly_name',
                                     description='test_description',
                                     default_table_expiration_ms=24 * 60 * 60 *
                                     1000,
                                     location='US',
                                     access_entries=(access_entry1, ))
        dataset4_2 = BigQueryDataset(dataset_id='foo',
                                     friendly_name='bar',
                                     description='test_description',
                                     default_table_expiration_ms=24 * 60 * 60 *
                                     1000,
                                     location='US',
                                     access_entries=(access_entry2, ))
        self.assertNotEqual(dataset4_1, dataset4_2)

        dataset5_1 = BigQueryDataset(
            dataset_id='foo',
            friendly_name='bar',
            description='test_description',
            default_table_expiration_ms=24 * 60 * 60 * 1000,
            location='US',
            access_entries=(access_entry1, access_entry2))
        dataset5_2 = BigQueryDataset(
            dataset_id='foo',
            friendly_name='bar',
            description='test_description',
            default_table_expiration_ms=24 * 60 * 60 * 1000,
            location='US',
            access_entries=(access_entry2, access_entry1))
        dataset5_3 = BigQueryDataset(
            dataset_id='foo',
            friendly_name='bar',
            description='test_description',
            default_table_expiration_ms=24 * 60 * 60 * 1000,
            location='US',
            access_entries=[access_entry1, access_entry2])
        self.assertEqual(dataset5_1, dataset5_2)
        self.assertEqual(dataset5_1, dataset5_3)
        self.assertEqual(dataset5_2, dataset5_3)

        dataset6_1 = BigQueryDataset(
            dataset_id='foo',
            friendly_name='bar',
            description='test_description',
            default_table_expiration_ms=24 * 60 * 60 * 1000,
            location='US',
            access_entries=(access_entry1, access_entry2))
        dataset6_2 = BigQueryDataset(dataset_id='foo',
                                     friendly_name='bar',
                                     description='test_description',
                                     default_table_expiration_ms=24 * 60 * 60 *
                                     1000,
                                     location='US',
                                     access_entries=(access_entry3, ))
        dataset6_3 = BigQueryDataset(
            dataset_id='foo',
            friendly_name='bar',
            description='test_description',
            default_table_expiration_ms=24 * 60 * 60 * 1000,
            location='US',
            access_entries=(access_entry1, access_entry3))
        self.assertNotEqual(dataset6_1, dataset6_2)
        self.assertNotEqual(dataset6_1, dataset6_3)
        self.assertNotEqual(dataset6_2, dataset6_3)

        label1 = {'foo': 'bar'}
        label2 = {'fizz': 'buzz'}

        dataset7_1 = BigQueryDataset(dataset_id='foo',
                                     friendly_name='bar',
                                     description='test_description',
                                     default_table_expiration_ms=24 * 60 * 60 *
                                     1000,
                                     location='US',
                                     labels=label1)
        dataset7_2 = BigQueryDataset(dataset_id='foo',
                                     friendly_name='bar',
                                     description='test_description',
                                     default_table_expiration_ms=24 * 60 * 60 *
                                     1000,
                                     location='US',
                                     labels=label1)
        self.assertEqual(dataset7_1, dataset7_2)

        dataset8_1 = BigQueryDataset(dataset_id='foo',
                                     friendly_name='bar',
                                     description='test_description',
                                     default_table_expiration_ms=24 * 60 * 60 *
                                     1000,
                                     location='US',
                                     labels=label1)
        dataset8_2 = BigQueryDataset(dataset_id='foo',
                                     friendly_name='bar',
                                     description='test_description',
                                     default_table_expiration_ms=24 * 60 * 60 *
                                     1000,
                                     location='US',
                                     labels=label2)
        self.assertNotEqual(dataset8_1, dataset8_2)