def test_generate_password(self, Command):
        p = mock.Mock(
            stderr=io.BytesIO(b"error"), stdout=io.BytesIO(b"out"), returncode=0
        )
        Command.return_value = p

        config = ScratchOrgConfig({"username": "******"}, "test")
        config.generate_password()

        p.run.assert_called_once()
    def test_generate_password(self, Command):
        p = mock.Mock(
            stderr=io.BytesIO(b"error"), stdout=io.BytesIO(b"out"), returncode=0
        )
        Command.return_value = p

        config = ScratchOrgConfig({"username": "******"}, "test")
        config.generate_password()

        p.run.assert_called_once()
    def test_generate_password_failed(self, Command):
        p = mock.Mock()
        p.stderr = io.BytesIO(b"error")
        p.stdout = io.BytesIO(b"out")
        p.returncode = 1
        Command.return_value = p

        config = ScratchOrgConfig({"username": "******"}, "test")
        config.logger = mock.Mock()
        config.generate_password()

        config.logger.warning.assert_called_once()
Exemple #4
0
    def test_generate_password_failed(self, Command):
        p = mock.Mock()
        p.stderr = io.BytesIO(b'error')
        p.stdout = io.BytesIO(b'out')
        p.returncode = 1
        Command.return_value = p

        config = ScratchOrgConfig({'username': '******'}, 'test')
        config.logger = mock.Mock()
        config.generate_password()

        config.logger.warn.assert_called_once()
Exemple #5
0
    def test_generate_password(self, Command):
        p = mock.Mock(
            stderr=io.BytesIO(b'error'),
            stdout=io.BytesIO(b'out'),
            returncode=0,
        )
        Command.return_value = p

        config = ScratchOrgConfig({'username': '******'}, 'test')
        config.generate_password()

        p.run.assert_called_once()
    def test_generate_password_failed(self, Command):
        p = mock.Mock()
        p.stderr = io.BytesIO(b"error")
        p.stdout = io.BytesIO(b"out")
        p.returncode = 1
        Command.return_value = p

        config = ScratchOrgConfig({"username": "******"}, "test")
        config.logger = mock.Mock()
        config.generate_password()

        config.logger.warning.assert_called_once()
    def test_create_org_uses_org_def_email(self, Command):
        out = b"Successfully created scratch org: ORG_ID, username: USERNAME"
        Command.return_value = p = mock.Mock(
            stdout=io.BytesIO(out), stderr=io.BytesIO(b""), returncode=0
        )

        config = ScratchOrgConfig(
            {
                "config_file": "tmp.json",
                "set_password": True,
                "email_address": "*****@*****.**",
            },
            "test",
        )
        config.generate_password = mock.Mock()
        with temporary_dir():
            with open("tmp.json", "w") as f:
                f.write('{"adminEmail": "*****@*****.**"}')

            config.create_org()

        p.run.assert_called_once()
        self.assertEqual(config.config["org_id"], "ORG_ID")
        self.assertEqual(config.config["username"], "USERNAME")
        self.assertIn("date_created", config.config)
        config.generate_password.assert_called_once()
        self.assertTrue(config.config["created"])
        self.assertEqual(config.scratch_org_type, "workspace")

        self.assertNotIn("*****@*****.**", Command.call_args[0][0])
    def test_create_org_uses_org_def_email(self, Command):
        out = b"Successfully created scratch org: ORG_ID, username: USERNAME"
        Command.return_value = p = mock.Mock(
            stdout=io.BytesIO(out), stderr=io.BytesIO(b""), returncode=0
        )

        config = ScratchOrgConfig(
            {
                "config_file": "tmp.json",
                "set_password": True,
                "email_address": "*****@*****.**",
            },
            "test",
        )
        config.generate_password = mock.Mock()
        with temporary_dir():
            with open("tmp.json", "w") as f:
                f.write('{"adminEmail": "*****@*****.**"}')

            config.create_org()

        p.run.assert_called_once()
        self.assertEqual(config.config["org_id"], "ORG_ID")
        self.assertEqual(config.config["username"], "USERNAME")
        self.assertIn("date_created", config.config)
        config.generate_password.assert_called_once()
        self.assertTrue(config.config["created"])
        self.assertEqual(config.scratch_org_type, "workspace")

        self.assertNotIn("*****@*****.**", Command.call_args[0][0])
    def test_create_org(self, Command):
        out = b"Successfully created scratch org: ORG_ID, username: USERNAME"
        Command.return_value = p = mock.Mock(stdout=io.BytesIO(out),
                                             stderr=io.BytesIO(b""),
                                             returncode=0)

        config = ScratchOrgConfig({
            "config_file": "tmp",
            "set_password": True
        }, "test")
        config.generate_password = mock.Mock()
        config.create_org()

        p.run.assert_called_once()
        self.assertEqual(config.config["org_id"], "ORG_ID")
        self.assertEqual(config.config["username"], "USERNAME")
        self.assertIn("date_created", config.config)
        config.generate_password.assert_called_once()
        self.assertTrue(config.config["created"])
        self.assertEqual(config.scratch_org_type, "workspace")
Exemple #10
0
    def test_create_org(self, Command):
        out = b'Successfully created scratch org: ORG_ID, username: USERNAME'
        Command.return_value = p = mock.Mock(
            stdout=io.BytesIO(out),
            stderr=io.BytesIO(b''),
            returncode=0,
        )

        config = ScratchOrgConfig({
                'config_file': 'tmp',
                'set_password': True,
            }, 'test')
        config.generate_password = mock.Mock()
        config.create_org()

        p.run.assert_called_once()
        self.assertEqual(config.config['org_id'], 'ORG_ID')
        self.assertEqual(config.config['username'], 'USERNAME')
        self.assertIn('date_created', config.config)
        config.generate_password.assert_called_once()
        self.assertTrue(config.config['created'])
        self.assertEqual(config.scratch_org_type, 'workspace')
 def test_generate_password_skips_if_failed(self, Command):
     config = ScratchOrgConfig({"username": "******"}, "test")
     config.password_failed = True
     config.generate_password()
     Command.assert_not_called()
Exemple #12
0
 def test_generate_password_skips_if_failed(self, Command):
     config = ScratchOrgConfig({'username': '******'}, 'test')
     config.password_failed = True
     config.generate_password()
     Command.assert_not_called()
 def test_generate_password_skips_if_failed(self, Command):
     config = ScratchOrgConfig({"username": "******"}, "test")
     config.password_failed = True
     config.generate_password()
     Command.assert_not_called()