def test_gallery_not_initialized(self):
        with TempDirectory() as tempdir:
            with self.assertRaises(SystemExit) as cm:
                sys.argv = [
                    'gallery_upload', 'aws', 'testbucket/path', '-p',
                    tempdir.path
                ]
                gallery_upload.main()

            self.assertEqual(cm.exception.code, 1)
示例#2
0
    def test_gallery_not_initialized(self):
        with TempDirectory() as tempdir:
            with self.assertRaises(SystemExit) as cm:
                sys.argv = [
                    "gallery_upload",
                    "aws",
                    "testbucket/path",
                    "-p",
                    tempdir.path,
                ]
                gallery_upload.main()

            self.assertEqual(cm.exception.code, 1)
    def test_upload_aws(self, subprocess_run, input):
        subprocess_run.return_value = subprocess.CompletedProcess([],
                                                                  returncode=0)

        with TempDirectory() as tempdir:
            # Setup the mock gallery
            public_path = setup_gallery(tempdir)

            # Call upload without specified AWS S3 bucket
            with self.assertRaises(SystemExit) as cm:
                sys.argv = ['gallery_upload', 'aws', '-p', tempdir.path]
                gallery_upload.main()
            self.assertEqual(cm.exception.code, 1)

            # Call upload with a bucket specified as a parameter
            sys.argv = [
                'gallery_upload', 'aws', 's3://testbucket/path/', '-p',
                tempdir.path
            ]
            gallery_upload.main()
            subprocess_run.assert_called_with([
                'aws', 's3', 'sync', public_path, 's3://testbucket/path/',
                '--exclude', '.DS_Store'
            ])

            # Call upload with a bucket specified in the gallery.json
            add_remote_location(tempdir, 's3://testbucket/path/')

            sys.argv = ['gallery_upload', 'aws', '-p', tempdir.path]
            gallery_upload.main()
            subprocess_run.assert_called_with([
                'aws', 's3', 'sync', public_path, 's3://testbucket/path/',
                '--exclude', '.DS_Store'
            ])
示例#4
0
    def test_upload_netlify(self, upload_gallery, input):
        with TempDirectory() as tempdir:
            # Setup the mock gallery
            public_path = setup_gallery(tempdir)

            # Call upload without specified location
            sys.argv = ["gallery_upload", "netlify", "-p", tempdir.path]
            gallery_upload.main()
            upload_gallery.assert_called_with("", public_path)

            # Call upload with a site specified as a parameter
            sys.argv = [
                "gallery_upload",
                "netlify",
                "test_location",
                "-p",
                tempdir.path,
            ]
            gallery_upload.main()
            upload_gallery.assert_called_with("test_location", public_path)

            # Call upload with a site specified in the gallery.json
            add_remote_location(tempdir, "test_location")

            sys.argv = ["gallery_upload", "netlify", "-p", tempdir.path]
            gallery_upload.main()
            upload_gallery.assert_called_with("test_location", public_path)
    def test_aws_without_location(self):
        with self.assertRaises(SystemExit) as cm:
            sys.argv = ['gallery_upload', 'aws']
            gallery_upload.main()

        self.assertEqual(cm.exception.code, 1)