def test_to_access_entry(self):
        expected_access_entry1 = AccessEntry('OWNER', 'specialGroup',
                                             'projectOwners')
        actual_access_entry1_1 = BigQueryAccessEntry.to_access_entry(
            BigQueryAccessEntry('OWNER', 'specialGroup', 'projectOwners'))
        self.assertEqual(expected_access_entry1, actual_access_entry1_1)
        actual_access_entry1_2 = BigQueryAccessEntry.to_access_entry(
            BigQueryAccessEntry('WRITER', 'specialGroup', 'projectWriters'))
        self.assertNotEqual(expected_access_entry1, actual_access_entry1_2)

        expected_access_entry2 = AccessEntry(
            None, 'view', {
                'datasetId': 'test',
                'projectId': 'test-project',
                'tableId': 'test_table'
            })
        actual_access_entry2_1 = BigQueryAccessEntry.to_access_entry(
            BigQueryAccessEntry(
                None, 'view', {
                    'datasetId': 'test',
                    'projectId': 'test-project',
                    'tableId': 'test_table'
                }))
        self.assertEqual(expected_access_entry2, actual_access_entry2_1)
        actual_access_entry2_2 = BigQueryAccessEntry.to_access_entry(
            BigQueryAccessEntry(
                None, 'view', {
                    'datasetId': 'test',
                    'projectId': 'test-project',
                    'tableId': 'foo_bar'
                }))
        self.assertNotEqual(expected_access_entry2, actual_access_entry2_2)
    def test_eq(self):
        access_entry1_1 = BigQueryAccessEntry('OWNER', 'specialGroup',
                                              'projectOwners')
        access_entry1_2 = BigQueryAccessEntry('OWNER', 'specialGroup',
                                              'projectOwners')
        self.assertEqual(access_entry1_1, access_entry1_2)

        access_entry2_1 = BigQueryAccessEntry('READER', 'specialGroup',
                                              'projectReaders')
        access_entry2_2 = BigQueryAccessEntry('READER', 'userByEmail', '[email protected]')
        self.assertNotEqual(access_entry2_1, access_entry2_2)

        access_entry3_1 = BigQueryAccessEntry('WRITER', 'specialGroup',
                                              'projectWriters')
        access_entry3_2 = BigQueryAccessEntry(
            None, 'view', {
                'datasetId': 'test',
                'projectId': 'test-project',
                'tableId': 'test_table'
            })
        access_entry3_3 = BigQueryAccessEntry(None, 'view', {
            'datasetId': 'test',
            'projectId': 'test-project',
            'tableId': 'foo_bar'
        })
        self.assertNotEqual(access_entry3_1, access_entry3_2)
        self.assertNotEqual(access_entry3_2, access_entry3_3)

        access_entry4_1 = BigQueryAccessEntry(
            None, 'view', {
                'datasetId': 'test',
                'projectId': 'test-project',
                'tableId': 'test_table'
            })
        access_entry4_2 = BigQueryAccessEntry(
            None, 'view', {
                'datasetId': 'test',
                'projectId': 'test-project',
                'tableId': 'test_table'
            })
        self.assertEqual(access_entry4_1, access_entry4_2)
    def test_from_dict(self):
        expected_access_entry1 = BigQueryAccessEntry('OWNER', 'specialGroup',
                                                     'projectOwners')
        actual_access_entry1_1 = BigQueryAccessEntry.from_dict({
            'role':
            'OWNER',
            'entity_type':
            'specialGroup',
            'entity_id':
            'projectOwners'
        })
        self.assertEqual(expected_access_entry1, actual_access_entry1_1)
        actual_access_entry1_2 = BigQueryAccessEntry.from_dict({
            'role':
            'WRITER',
            'entity_type':
            'specialGroup',
            'entity_id':
            'projectWriters'
        })
        self.assertNotEqual(expected_access_entry1, actual_access_entry1_2)

        expected_access_entry2 = BigQueryAccessEntry(
            None, 'view', {
                'datasetId': 'test',
                'projectId': 'test-project',
                'tableId': 'test_table'
            })
        actual_access_entry2_1 = BigQueryAccessEntry.from_dict({
            'role': None,
            'entity_type': 'view',
            'entity_id': {
                'datasetId': 'test',
                'projectId': 'test-project',
                'tableId': 'test_table'
            }
        })
        self.assertEqual(expected_access_entry2, actual_access_entry2_1)
        actual_access_entry2_2 = BigQueryAccessEntry.from_dict({
            'role': None,
            'entity_type': 'view',
            'entity_id': {
                'datasetId': 'test',
                'projectId': 'test-project',
                'tableId': 'foo_bar'
            }
        })
        self.assertNotEqual(expected_access_entry2, actual_access_entry2_2)
    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)
Esempio n. 5
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})
    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)