def test_launch_instance(self): provider = ProviderImpl(project=self.project, echoer=self.echoer_mock) provider.start_mock.side_effect = errors.ProviderInstanceNotFoundError( instance_name=self.instance_name) provider.launch_instance() provider.launch_mock.assert_any_call() provider.start_mock.assert_any_call() provider.save_info_mock.assert_called_once_with({"base": "core16"}) self.assertThat(provider.run_mock.call_count, Equals(7)) provider.run_mock.assert_has_calls([ call(["snapcraft", "refresh"]), call(["mv", "/tmp/L3Jvb3QvLmJhc2hyYw==", "/root/.bashrc"]), call(["chown", "root:root", "/root/.bashrc"]), call(["chmod", "0600", "/root/.bashrc"]), call([ "mv", "/tmp/L2Jpbi9fc25hcGNyYWZ0X3Byb21wdA==", "/bin/_snapcraft_prompt", ]), call(["chown", "root:root", "/bin/_snapcraft_prompt"]), call(["chmod", "0755", "/bin/_snapcraft_prompt"]), ]) self.assertThat(provider.provider_project_dir, DirExists())
def test_launch_instance(self): provider = ProviderImpl(project=self.project, echoer=self.echoer_mock) provider.start_mock.side_effect = errors.ProviderInstanceNotFoundError( instance_name=self.instance_name) provider.launch_instance() provider.launch_mock.assert_any_call() provider.start_mock.assert_any_call() provider.run_mock.assert_called_once_with(["snapcraft", "refresh"]) self.assertThat(provider.provider_project_dir, DirExists())
def test_launch_instance(self): self.useFixture(fixtures.EnvironmentVariable("SNAP_VERSION", "4.0")) provider = ProviderImpl(project=self.project, echoer=self.echoer_mock) provider.start_mock.side_effect = errors.ProviderInstanceNotFoundError( instance_name=self.instance_name) provider.launch_instance() provider.launch_mock.assert_any_call() provider.start_mock.assert_any_call() provider.save_info_mock.assert_called_once_with({ "data": { "base": "core16", "created-by-snapcraft-version": "4.0" } }) self.assertThat( provider.run_mock.mock_calls, Equals([ call(["mv", "/var/tmp/L3Jvb3QvLmJhc2hyYw==", "/root/.bashrc"]), call(["chown", "root:root", "/root/.bashrc"]), call(["chmod", "0600", "/root/.bashrc"]), call([ "mv", "/var/tmp/L2Jpbi9fc25hcGNyYWZ0X3Byb21wdA==", "/bin/_snapcraft_prompt", ]), call(["chown", "root:root", "/bin/_snapcraft_prompt"]), call(["chmod", "0755", "/bin/_snapcraft_prompt"]), call([ "mv", "/var/tmp/L2V0Yy9hcHQvc291cmNlcy5saXN0", "/etc/apt/sources.list", ]), call(["chown", "root:root", "/etc/apt/sources.list"]), call(["chmod", "0644", "/etc/apt/sources.list"]), call([ "mv", "/var/tmp/L2V0Yy9hcHQvc291cmNlcy5saXN0LmQvZGVmYXVsdC5zb3VyY2Vz", "/etc/apt/sources.list.d/default.sources", ]), call([ "chown", "root:root", "/etc/apt/sources.list.d/default.sources", ]), call([ "chmod", "0644", "/etc/apt/sources.list.d/default.sources" ]), call([ "mv", "/var/tmp/L2V0Yy9hcHQvc291cmNlcy5saXN0LmQvZGVmYXVsdC1zZWN1cml0eS5zb3VyY2Vz", "/etc/apt/sources.list.d/default-security.sources", ]), call([ "chown", "root:root", "/etc/apt/sources.list.d/default-security.sources", ]), call([ "chmod", "0644", "/etc/apt/sources.list.d/default-security.sources", ]), call([ "mv", "/var/tmp/L2V0Yy9hcHQvYXB0LmNvbmYuZC8wMC1zbmFwY3JhZnQ=", "/etc/apt/apt.conf.d/00-snapcraft", ]), call( ["chown", "root:root", "/etc/apt/apt.conf.d/00-snapcraft"]), call(["chmod", "0644", "/etc/apt/apt.conf.d/00-snapcraft"]), call(["apt-get", "update"]), call(["apt-get", "dist-upgrade", "--yes"]), call(["apt-get", "install", "--yes", "apt-transport-https"]), call(["snap", "unset", "system", "proxy.http"]), call(["snap", "unset", "system", "proxy.https"]), ]), ) self.assertThat(provider.provider_project_dir, DirExists())
def test_launch_instance(self): provider = ProviderImpl(project=self.project, echoer=self.echoer_mock) provider.start_mock.side_effect = errors.ProviderInstanceNotFoundError( instance_name=self.instance_name) provider.launch_instance() provider.launch_mock.assert_any_call() provider.start_mock.assert_any_call() provider.save_info_mock.assert_called_once_with({"base": "core16"}) self.assertThat( provider.run_mock.mock_calls, Equals([ call(["mv", "/var/tmp/L3Jvb3QvLmJhc2hyYw==", "/root/.bashrc"]), call(["chown", "root:root", "/root/.bashrc"]), call(["chmod", "0600", "/root/.bashrc"]), call([ "mv", "/var/tmp/L2Jpbi9fc25hcGNyYWZ0X3Byb21wdA==", "/bin/_snapcraft_prompt", ]), call(["chown", "root:root", "/bin/_snapcraft_prompt"]), call(["chmod", "0755", "/bin/_snapcraft_prompt"]), call([ "mv", "/var/tmp/L2V0Yy9hcHQvc291cmNlcy5saXN0", "/etc/apt/sources.list", ]), call(["chown", "root:root", "/etc/apt/sources.list"]), call(["chmod", "0644", "/etc/apt/sources.list"]), call([ "mv", "/var/tmp/L2V0Yy9hcHQvc291cmNlcy5saXN0LmQvbWFpbi5zb3VyY2Vz", "/etc/apt/sources.list.d/main.sources", ]), call([ "chown", "root:root", "/etc/apt/sources.list.d/main.sources" ]), call(["chmod", "0644", "/etc/apt/sources.list.d/main.sources"]), call([ "mv", "/var/tmp/L2V0Yy9hcHQvc291cmNlcy5saXN0LmQvc2VjdXJpdHkuc291cmNlcw==", "/etc/apt/sources.list.d/security.sources", ]), call([ "chown", "root:root", "/etc/apt/sources.list.d/security.sources", ]), call([ "chmod", "0644", "/etc/apt/sources.list.d/security.sources" ]), call([ "mv", "/var/tmp/L2V0Yy9hcHQvYXB0LmNvbmYuZC8wMC1zbmFwY3JhZnQ=", "/etc/apt/apt.conf.d/00-snapcraft", ]), call( ["chown", "root:root", "/etc/apt/apt.conf.d/00-snapcraft"]), call(["chmod", "0644", "/etc/apt/apt.conf.d/00-snapcraft"]), call(["apt-get", "update"]), ]), ) self.assertThat(provider.provider_project_dir, DirExists())