예제 #1
0
    def test_s3_project_root_can_be_set_empty_string_or_default(self):
        b = self.create_example_bucket()
        conf = '''
[aws]
region_name = 'eu-west-1'
s3_bucket_name = 'www.example.com'
'''
        with tempfile.TemporaryDirectory() as tmpd:
            project_root = self.create_projdir_with_conf(
                'skeleton_proj_1.0', tmpd, conf)
            p = Project(project_root)
            diff, new_remote_cat = p.calculate_diff()
            p.sync()
        self.assertIn('index.html', diff['upload']['new_files'])
        self.assertIn('index.html', all_bucket_keys(b))

        conf = '''
[aws]
region_name = 'eu-west-1'
s3_bucket_name = 'www.example.com'
s3_project_root = ''
'''
        with tempfile.TemporaryDirectory() as tmpd:
            project_root = self.create_projdir_with_conf(
                'skeleton_proj_1.0', tmpd, conf)
            p = Project(project_root)
            diff, new_remote_cat = p.calculate_diff()
            p.sync()
        self.assertIn('index.html', diff['unchanged'])
        self.assertIn('index.html', all_bucket_keys(b))
예제 #2
0
    def test_migration_interrupted_both_formats_now_on_s3_old_ignored(self):
        """
        It's possible the migration was interrupted and now both the CSV and
        SQLite versions of the catalogue are now on S3. Need to make sure that
        the only the new one is used when building the remote catalogue and not
        the old one, which may be out of date.
        """
        self.conn = boto3.resource('s3', region_name='eu-west-1')
        self.conn.create_bucket(
            Bucket='www.example.com',
            CreateBucketConfiguration={'LocationConstraint': 'eu-west-1'})
        project_root = os.path.join(MODULE_DIR, 'migration_fixture_proj_1.1')
        p = Project(project_root)
        p.sync()

        b = self.conn.Bucket('www.example.com')
        old_csv_p = os.path.join(
            MODULE_DIR, 'migration_fixture_proj_1.s3sup.catalogue.csv')
        with open(old_csv_p, 'rb') as old_csv_f:
            b.put_object(Key='.s3sup.catalogue.csv',
                         ACL='private',
                         Body=old_csv_f)

        self.assertIn('.s3sup.cat', all_bucket_keys(b))
        self.assertIn('.s3sup.catalogue.csv', all_bucket_keys(b))

        project_root_n = os.path.join(MODULE_DIR, 'migration_fixture_proj_1.1')
        pn = Project(project_root_n)
        diff, new_remote_cat = pn.calculate_diff()
        self.assertEqual(0, diff['num_changes'])