mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Remove intellij edu plugins, obsolete tests and unused dependencies
This commit is contained in:
@@ -1,43 +0,0 @@
|
||||
<idea-plugin version="2">
|
||||
<id>com.jetbrains.edu.student.intellij</id>
|
||||
<name>Educational plugin for Intellij</name>
|
||||
<version>2.0</version>
|
||||
|
||||
<description><![CDATA[
|
||||
Educational plugin core for students.
|
||||
]]></description>
|
||||
<vendor>JetBrains</vendor>
|
||||
|
||||
<change-notes><![CDATA[
|
||||
|
||||
]]>
|
||||
</change-notes>
|
||||
|
||||
<depends>com.jetbrains.edu.student</depends>
|
||||
|
||||
<!-- please see http://confluence.jetbrains.net/display/IDEADEV/Plugin+Compatibility+with+IntelliJ+Platform+Products
|
||||
on how to target different products -->
|
||||
|
||||
<depends>com.intellij.modules.lang</depends>
|
||||
|
||||
<project-components>
|
||||
|
||||
</project-components>
|
||||
|
||||
<application-components>
|
||||
|
||||
</application-components>
|
||||
|
||||
<actions>
|
||||
|
||||
</actions>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<projectTemplatesFactory implementation="EduProjectTemplateFactory"/>
|
||||
</extensions>
|
||||
|
||||
<extensionPoints>
|
||||
<extensionPoint name="EduProjectTemplate" interface="EduProjectTemplate"/>
|
||||
</extensionPoints>
|
||||
|
||||
</idea-plugin>
|
||||
@@ -1,28 +0,0 @@
|
||||
import com.intellij.ide.util.projectWizard.WizardInputField;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.platform.ProjectTemplate;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public abstract class EduProjectTemplate implements ProjectTemplate {
|
||||
public static final ExtensionPointName<EduProjectTemplate> EP_NAME = ExtensionPointName.create("com.jetbrains.edu.interactivelearning.intellij.EduProjectTemplate");
|
||||
|
||||
public static WizardInputField createWizardInputField(String id, final String label, final JComponent component) {
|
||||
return new WizardInputField(id, id) {
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getComponent() {
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
import com.intellij.ide.util.projectWizard.WizardContext;
|
||||
import com.intellij.platform.ProjectTemplate;
|
||||
import com.intellij.platform.ProjectTemplatesFactory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class EduProjectTemplateFactory extends ProjectTemplatesFactory {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return new String[] {"Edu"};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ProjectTemplate[] createTemplates(@Nullable String group, WizardContext context) {
|
||||
return EduProjectTemplate.EP_NAME.getExtensions();
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/../../educational/interactive-learning-intellij/pluginResources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/../../educational/interactive-learning-intellij/pluginResources/fileTemplates/internal" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/../../educational/interactive-learning-intellij/pluginResources/fileTemplates/j2ee" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="lang-api" />
|
||||
<orderEntry type="module" module-name="platform-impl" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,25 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="platform-impl" />
|
||||
<orderEntry type="module" module-name="student-intellij" />
|
||||
<orderEntry type="module" module-name="lang-api" />
|
||||
<orderEntry type="module" module-name="python-community-plugin-core" />
|
||||
<orderEntry type="module" module-name="python-community-plugin-java" />
|
||||
<orderEntry type="module" module-name="course-creator" />
|
||||
<orderEntry type="module" module-name="course-creator-python" />
|
||||
<orderEntry type="module" module-name="main" />
|
||||
<orderEntry type="module" module-name="python-community-ide-resources" />
|
||||
<orderEntry type="module" module-name="python-community" />
|
||||
<orderEntry type="module" module-name="openapi" />
|
||||
<orderEntry type="module" module-name="student-intellij-py" />
|
||||
<orderEntry type="module" module-name="student" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,39 +0,0 @@
|
||||
<!--suppress XmlUnboundNsPrefix -->
|
||||
<idea-plugin version="2">
|
||||
<id>com.jetbrains.edu.coursecreator.intellij.python</id>
|
||||
<name>Plugin for Intellij IDEA for creating python courses</name>
|
||||
<version>2.0</version>
|
||||
|
||||
<description><![CDATA[
|
||||
Educational plugin core for students.
|
||||
]]></description>
|
||||
<vendor>JetBrains</vendor>
|
||||
|
||||
<change-notes><![CDATA[
|
||||
|
||||
]]>
|
||||
</change-notes>
|
||||
|
||||
<depends>com.intellij.modules.lang</depends>
|
||||
<depends>com.intellij.modules.python</depends>
|
||||
<depends>com.jetbrains.edu.student.intellij</depends>
|
||||
<depends>com.jetbrains.edu.coursecreator</depends>
|
||||
<depends>com.jetbrains.edu.coursecreator.python</depends>
|
||||
|
||||
<project-components>
|
||||
|
||||
</project-components>
|
||||
|
||||
<application-components>
|
||||
|
||||
</application-components>
|
||||
|
||||
<actions>
|
||||
|
||||
</actions>
|
||||
|
||||
<extensions defaultExtensionNs="com.jetbrains.edu.interactivelearning.intellij">
|
||||
<EduProjectTemplate implementation="PyCCEduProjectTemplate"/>
|
||||
</extensions>
|
||||
|
||||
</idea-plugin>
|
||||
@@ -1,92 +0,0 @@
|
||||
import com.intellij.ide.util.projectWizard.AbstractModuleBuilder;
|
||||
import com.intellij.ide.util.projectWizard.WizardInputField;
|
||||
import com.intellij.openapi.module.ModifiableModuleModel;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.startup.StartupManager;
|
||||
import com.intellij.openapi.ui.ValidationInfo;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.jetbrains.edu.coursecreator.PyCCProjectGenerator;
|
||||
import com.jetbrains.edu.coursecreator.ui.CCNewProjectPanel;
|
||||
import com.jetbrains.python.facet.PythonSdkComboBox;
|
||||
import com.jetbrains.python.module.PythonModuleBuilder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PyCCEduProjectTemplate extends EduProjectTemplate {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Python Course Creation";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public AbstractModuleBuilder createModuleBuilder() {
|
||||
return new PythonEduModuleBuilder() ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValidationInfo validateSettings() {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static class PythonEduModuleBuilder extends PythonModuleBuilder {
|
||||
@Override
|
||||
public void setupRootModel(ModifiableRootModel rootModel) throws ConfigurationException {
|
||||
super.setupRootModel(rootModel);
|
||||
Sdk sdk = mySdkComboBox.getSelectedSdk();
|
||||
if (sdk != null) {
|
||||
rootModel.setSdk(sdk);
|
||||
}
|
||||
}
|
||||
|
||||
final PythonSdkComboBox mySdkComboBox = new PythonSdkComboBox();
|
||||
final CCNewProjectPanel panel = new CCNewProjectPanel();
|
||||
|
||||
|
||||
@Override
|
||||
protected List<WizardInputField> getAdditionalFields() {
|
||||
List<WizardInputField> wizardInputFields = new ArrayList<WizardInputField>();
|
||||
wizardInputFields.add(createWizardInputField("Edu.CCProjectSdk", "Python Interpreter:", mySdkComboBox));
|
||||
wizardInputFields.add(createWizardInputField("Edu.Author", "Author:", panel.getAuthorField()));
|
||||
wizardInputFields.add(createWizardInputField("Edu.Name", "Name:", panel.getNameField()));
|
||||
wizardInputFields.add(createWizardInputField("Edu.Description", "Description:", panel.getDescriptionField()));
|
||||
return wizardInputFields;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Module commitModule(@NotNull final Project project, @Nullable ModifiableModuleModel model) {
|
||||
Module module = super.commitModule(project, model);
|
||||
if (module != null) {
|
||||
final VirtualFile baseDir = project.getBaseDir();
|
||||
StartupManager.getInstance(project).runWhenProjectIsInitialized(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PyCCProjectGenerator.generateProject(project, baseDir, panel.getName(), panel.getAuthors(), panel.getDescription());
|
||||
}
|
||||
});
|
||||
}
|
||||
return module;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,11 +11,8 @@
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="course-creator" />
|
||||
<orderEntry type="module" module-name="lang-impl" />
|
||||
<orderEntry type="module" module-name="python-community-ide-resources" />
|
||||
<orderEntry type="module" module-name="python-community" />
|
||||
<orderEntry type="module" module-name="testFramework" scope="TEST" />
|
||||
<orderEntry type="module" module-name="python-ide-community" />
|
||||
<orderEntry type="module" module-name="educational-core" />
|
||||
<orderEntry type="module" module-name="educational-python" />
|
||||
<orderEntry type="module" module-name="python-community" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,3 +0,0 @@
|
||||
print("Hello world")
|
||||
print("Hello world")
|
||||
print("Hello world")
|
||||
@@ -1,86 +0,0 @@
|
||||
<TaskFile>
|
||||
<option name="task_windows">
|
||||
<list>
|
||||
<TaskWindow>
|
||||
<option name="index" value="1"/>
|
||||
<option name="length" value="72"/>
|
||||
<option name="line" value="0"/>
|
||||
<option name="replacementLength" value="5"/>
|
||||
<option name="start" value="0"/>
|
||||
<option name="taskText" value="123456789123456789123456789123456789123456789123456789123456789123456789"/>
|
||||
<option name="line" value="0"/>
|
||||
<option name="start" value="0"/>
|
||||
<option name="hint"/>
|
||||
<option name="possible_answer" value="print"/>
|
||||
<option name="length" value="72"/>
|
||||
<option name="myTaskText" value="123456789123456789123456789123456789123456789123456789123456789123456789"/>
|
||||
<option name="myReplacementLength" value="5"/>
|
||||
<option name="myIndex" value="1"/>
|
||||
</TaskWindow>
|
||||
<TaskWindow>
|
||||
<option name="index" value="2"/>
|
||||
<option name="length" value="27"/>
|
||||
<option name="line" value="0"/>
|
||||
<option name="replacementLength" value="5"/>
|
||||
<option name="start" value="13"/>
|
||||
<option name="taskText" value="123456789123456789123456789"/>
|
||||
<option name="line" value="0"/>
|
||||
<option name="start" value="13"/>
|
||||
<option name="hint"/>
|
||||
<option name="possible_answer" value="world"/>
|
||||
<option name="length" value="27"/>
|
||||
<option name="myTaskText" value="123456789123456789123456789"/>
|
||||
<option name="myReplacementLength" value="5"/>
|
||||
<option name="myIndex" value="2"/>
|
||||
</TaskWindow>
|
||||
<TaskWindow>
|
||||
<option name="index" value="3"/>
|
||||
<option name="length" value="18"/>
|
||||
<option name="line" value="1"/>
|
||||
<option name="replacementLength" value="5"/>
|
||||
<option name="start" value="7"/>
|
||||
<option name="taskText" value="123456789123456789"/>
|
||||
<option name="line" value="1"/>
|
||||
<option name="start" value="7"/>
|
||||
<option name="hint"/>
|
||||
<option name="possible_answer" value="Hello"/>
|
||||
<option name="length" value="18"/>
|
||||
<option name="myTaskText" value="123456789123456789"/>
|
||||
<option name="myReplacementLength" value="5"/>
|
||||
<option name="myIndex" value="3"/>
|
||||
</TaskWindow>
|
||||
<TaskWindow>
|
||||
<option name="index" value="4"/>
|
||||
<option name="length" value="27"/>
|
||||
<option name="line" value="1"/>
|
||||
<option name="replacementLength" value="5"/>
|
||||
<option name="start" value="13"/>
|
||||
<option name="taskText" value="123456789123456789123456789"/>
|
||||
<option name="line" value="1"/>
|
||||
<option name="start" value="13"/>
|
||||
<option name="hint"/>
|
||||
<option name="possible_answer" value="world"/>
|
||||
<option name="length" value="27"/>
|
||||
<option name="myTaskText" value="123456789123456789123456789"/>
|
||||
<option name="myReplacementLength" value="5"/>
|
||||
<option name="myIndex" value="4"/>
|
||||
</TaskWindow>
|
||||
<TaskWindow>
|
||||
<option name="index" value="5"/>
|
||||
<option name="length" value="27"/>
|
||||
<option name="line" value="2"/>
|
||||
<option name="replacementLength" value="5"/>
|
||||
<option name="start" value="0"/>
|
||||
<option name="taskText" value="123456789123456789123456789"/>
|
||||
<option name="line" value="2"/>
|
||||
<option name="start" value="0"/>
|
||||
<option name="hint"/>
|
||||
<option name="possible_answer" value="print"/>
|
||||
<option name="length" value="27"/>
|
||||
<option name="myTaskText" value="123456789123456789123456789"/>
|
||||
<option name="myReplacementLength" value="5"/>
|
||||
<option name="myIndex" value="5"/>
|
||||
</TaskWindow>
|
||||
</list>
|
||||
</option>
|
||||
</TaskFile>
|
||||
@@ -1,31 +0,0 @@
|
||||
import com.intellij.testFramework.UsefulTestCase;
|
||||
import com.intellij.testFramework.fixtures.CodeInsightTestFixture;
|
||||
import com.intellij.testFramework.fixtures.IdeaProjectTestFixture;
|
||||
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory;
|
||||
import com.intellij.testFramework.fixtures.TestFixtureBuilder;
|
||||
import com.jetbrains.python.PythonHelpersLocator;
|
||||
|
||||
public abstract class CCTestCase extends UsefulTestCase {
|
||||
protected CodeInsightTestFixture myFixture;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
final TestFixtureBuilder<IdeaProjectTestFixture> projectBuilder = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(
|
||||
getName());
|
||||
myFixture = IdeaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(projectBuilder.getFixture());
|
||||
myFixture.setUp();
|
||||
myFixture.setTestDataPath(getTestDataPath());
|
||||
}
|
||||
|
||||
protected String getTestDataPath() {
|
||||
return PythonHelpersLocator.getPythonCommunityPath() + "/edu/course-creator-python/testData";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
myFixture.tearDown();
|
||||
myFixture = null;
|
||||
super.tearDown();
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="python-openapi" exported="" />
|
||||
<orderEntry type="module" module-name="platform-impl" />
|
||||
<orderEntry type="module" module-name="lang-impl" />
|
||||
<orderEntry type="library" name="Guava" level="project" />
|
||||
<orderEntry type="module" module-name="python-pydev" />
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
<!--suppress XmlUnboundNsPrefix -->
|
||||
<idea-plugin version="2">
|
||||
<id>com.jetbrains.edu.student.intellij.python</id>
|
||||
<name>Educational plugin for Intellij Python</name>
|
||||
<version>2.0</version>
|
||||
|
||||
<description><![CDATA[
|
||||
Educational plugin core for students.
|
||||
]]></description>
|
||||
<vendor>JetBrains</vendor>
|
||||
|
||||
<change-notes><![CDATA[
|
||||
|
||||
]]>
|
||||
</change-notes>
|
||||
|
||||
<depends>com.intellij.modules.lang</depends>
|
||||
<depends>com.intellij.modules.python</depends>
|
||||
<depends>com.jetbrains.edu.student</depends>
|
||||
<depends>com.jetbrains.python.edu.student.python</depends>
|
||||
<depends>com.jetbrains.edu.student.intellij</depends>
|
||||
|
||||
<project-components>
|
||||
|
||||
</project-components>
|
||||
|
||||
<application-components>
|
||||
|
||||
</application-components>
|
||||
|
||||
<actions>
|
||||
|
||||
</actions>
|
||||
|
||||
<extensions defaultExtensionNs="com.jetbrains.edu.interactivelearning.intellij">
|
||||
<EduProjectTemplate implementation="PyEduProjectTemplate"/>
|
||||
</extensions>
|
||||
|
||||
</idea-plugin>
|
||||
-195
@@ -1,195 +0,0 @@
|
||||
import sys
|
||||
|
||||
|
||||
def get_file_text(path):
|
||||
""" Returns file text by path"""
|
||||
file_io = open(path, "r")
|
||||
text = file_io.read()
|
||||
file_io.close()
|
||||
return text
|
||||
|
||||
|
||||
def get_file_output(encoding="utf-8", path=sys.argv[-1]):
|
||||
"""
|
||||
Returns answer file output
|
||||
:param encoding: to decode output in python3
|
||||
:param path: path of file to execute
|
||||
:return: list of strings
|
||||
"""
|
||||
import subprocess
|
||||
|
||||
proc = subprocess.Popen([sys.executable, path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
return list(map(lambda x: str(x.decode(encoding)), proc.communicate()[0].splitlines()))
|
||||
|
||||
|
||||
def test_file_importable():
|
||||
""" Tests there is no obvious syntax errors"""
|
||||
path = sys.argv[-1]
|
||||
if not path.endswith(".py"):
|
||||
import os
|
||||
|
||||
parent = os.path.abspath(os.path.join(path, os.pardir))
|
||||
python_files = [f for f in os.listdir(parent) if os.path.isfile(os.path.join(parent, f)) and f.endswith(".py")]
|
||||
for python_file in python_files:
|
||||
if python_file == "tests.py": continue
|
||||
check_importable_path(os.path.join(parent, python_file))
|
||||
return
|
||||
check_importable_path(path)
|
||||
|
||||
|
||||
def check_importable_path(path):
|
||||
""" Checks that file is importable.
|
||||
Reports failure otherwise.
|
||||
"""
|
||||
try:
|
||||
import_file(path)
|
||||
except:
|
||||
failed("The file contains syntax errors", test_file_importable.__name__)
|
||||
return
|
||||
passed(test_file_importable.__name__)
|
||||
|
||||
|
||||
def import_file(path):
|
||||
""" Returns imported file """
|
||||
if sys.version_info[0] == 2 or sys.version_info[1] < 3:
|
||||
import imp
|
||||
|
||||
return imp.load_source("tmp", path)
|
||||
elif sys.version_info[0] == 3:
|
||||
import importlib.machinery
|
||||
|
||||
return importlib.machinery.SourceFileLoader("tmp", path).load_module("tmp")
|
||||
|
||||
|
||||
def import_task_file():
|
||||
""" Returns imported file.
|
||||
Imports file from which check action was run
|
||||
"""
|
||||
path = sys.argv[-1]
|
||||
return import_file(path)
|
||||
|
||||
|
||||
def test_is_not_empty():
|
||||
"""
|
||||
Checks that file is not empty
|
||||
"""
|
||||
path = sys.argv[-1]
|
||||
file_text = get_file_text(path)
|
||||
|
||||
if len(file_text) > 0:
|
||||
passed()
|
||||
else:
|
||||
failed("The file is empty. Please, reload the task and try again.")
|
||||
|
||||
|
||||
def test_is_initial_text(error_text="You should modify the file"):
|
||||
"""
|
||||
Checks that file was modified
|
||||
"""
|
||||
path = sys.argv[-1]
|
||||
text = get_initial_text(path)
|
||||
file_text = get_file_text(path)
|
||||
|
||||
if file_text.strip() == text:
|
||||
failed(error_text)
|
||||
else:
|
||||
passed()
|
||||
|
||||
|
||||
def get_initial_text(path):
|
||||
"""
|
||||
Returns the initial task text
|
||||
"""
|
||||
course_lib = sys.argv[-2]
|
||||
|
||||
import os
|
||||
# path format is "project_root/lessonX/taskY/file.py"
|
||||
task_index = path.rfind(os.sep, 0, path.rfind(os.sep))
|
||||
index = path.rfind(os.sep, 0, task_index)
|
||||
relative_path = path[index + 1:]
|
||||
initial_file_path = os.path.join(course_lib, relative_path)
|
||||
return get_file_text(initial_file_path)
|
||||
|
||||
|
||||
def test_text_equals(text, error_text):
|
||||
"""
|
||||
Checks that answer equals text.
|
||||
"""
|
||||
path = sys.argv[-1]
|
||||
file_text = get_file_text(path)
|
||||
|
||||
if file_text.strip() == text:
|
||||
passed()
|
||||
else:
|
||||
failed(error_text)
|
||||
|
||||
|
||||
def test_answer_placeholders_text_deleted(error_text="Don't just delete task text"):
|
||||
"""
|
||||
Checks that all answer placeholders are not empty
|
||||
"""
|
||||
windows = get_answer_placeholders()
|
||||
|
||||
for window in windows:
|
||||
if len(window) == 0:
|
||||
failed(error_text)
|
||||
return
|
||||
passed()
|
||||
|
||||
|
||||
def set_congratulation_message(message):
|
||||
""" Overrides default 'Congratulations!' message """
|
||||
print("#educational_plugin CONGRATS_MESSAGE " + message)
|
||||
|
||||
|
||||
def failed(message="Please, reload the task and try again.", name=None):
|
||||
""" Reports failure """
|
||||
if not name:
|
||||
name = sys._getframe().f_back.f_code.co_name
|
||||
print("#educational_plugin " + name + " FAILED + " + message)
|
||||
|
||||
|
||||
def passed(name=None):
|
||||
""" Reports success """
|
||||
if not name:
|
||||
name = sys._getframe().f_back.f_code.co_name
|
||||
print("#educational_plugin " + name + " test OK")
|
||||
|
||||
|
||||
def get_answer_placeholders():
|
||||
"""
|
||||
Returns all answer placeholders text
|
||||
"""
|
||||
prefix = "#educational_plugin_window = "
|
||||
path = sys.argv[-1]
|
||||
import os
|
||||
|
||||
file_name_without_extension = os.path.splitext(path)[0]
|
||||
windows_path = file_name_without_extension + "_windows"
|
||||
windows = []
|
||||
f = open(windows_path, "r")
|
||||
window_text = ""
|
||||
first = True
|
||||
for line in f.readlines():
|
||||
if line.startswith(prefix):
|
||||
if not first:
|
||||
windows.append(window_text.strip())
|
||||
else:
|
||||
first = False
|
||||
window_text = line[len(prefix):]
|
||||
else:
|
||||
window_text += line
|
||||
|
||||
if window_text:
|
||||
windows.append(window_text.strip())
|
||||
|
||||
f.close()
|
||||
return windows
|
||||
|
||||
|
||||
def run_common_tests(error_text="Please, reload file and try again"):
|
||||
test_is_initial_text()
|
||||
test_is_not_empty()
|
||||
test_answer_placeholders_text_deleted()
|
||||
test_file_importable()
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
import com.intellij.ide.fileTemplates.FileTemplate;
|
||||
import com.intellij.ide.fileTemplates.FileTemplateManager;
|
||||
import com.intellij.ide.fileTemplates.FileTemplateUtil;
|
||||
import com.intellij.ide.util.projectWizard.AbstractModuleBuilder;
|
||||
import com.intellij.ide.util.projectWizard.WizardInputField;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.module.ModifiableModuleModel;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.startup.StartupManager;
|
||||
import com.intellij.openapi.ui.ValidationInfo;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.jetbrains.edu.learning.courseGeneration.StudyProjectGenerator;
|
||||
import com.jetbrains.edu.learning.ui.StudyNewProjectPanel;
|
||||
import com.jetbrains.python.facet.PythonSdkComboBox;
|
||||
import com.jetbrains.python.module.PythonModuleBuilder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PyEduProjectTemplate extends EduProjectTemplate {
|
||||
private static final Logger LOG = Logger.getInstance(PyEduProjectTemplate.class);
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Python";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public AbstractModuleBuilder createModuleBuilder() {
|
||||
return new PythonEduModuleBuilder();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ValidationInfo validateSettings() {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static class PythonEduModuleBuilder extends PythonModuleBuilder {
|
||||
|
||||
final StudyProjectGenerator studyProjectGenerator = new StudyProjectGenerator();
|
||||
final PythonSdkComboBox mySdkComboBox = new PythonSdkComboBox();
|
||||
|
||||
@Override
|
||||
public void setupRootModel(ModifiableRootModel rootModel) throws ConfigurationException {
|
||||
super.setupRootModel(rootModel);
|
||||
Sdk sdk = mySdkComboBox.getSelectedSdk();
|
||||
if (sdk != null) {
|
||||
rootModel.setSdk(sdk);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<WizardInputField> getAdditionalFields() {
|
||||
final StudyNewProjectPanel panel = new StudyNewProjectPanel(studyProjectGenerator);
|
||||
List<WizardInputField> wizardInputFields = new ArrayList<WizardInputField>();
|
||||
wizardInputFields.add(createWizardInputField("Edu.ProjectSdk", "Python Interpreter:", mySdkComboBox));
|
||||
wizardInputFields.add(createWizardInputField("Edu.Courses", "Courses:", panel.getCoursesComboBox()));
|
||||
wizardInputFields.add(createWizardInputField("Edu.InfoPanel", "", panel.getInfoPanel()));
|
||||
return wizardInputFields;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Module commitModule(@NotNull final Project project, @Nullable ModifiableModuleModel model) {
|
||||
Module module = super.commitModule(project, model);
|
||||
if (module != null) {
|
||||
final VirtualFile baseDir = project.getBaseDir();
|
||||
studyProjectGenerator.generateProject(project, baseDir);
|
||||
final FileTemplate template = FileTemplateManager.getInstance(project).getInternalTemplate("test_helper.py");
|
||||
|
||||
StartupManager.getInstance(project).runWhenProjectIsInitialized(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final PsiDirectory projectDir = PsiManager.getInstance(project).findDirectory(baseDir);
|
||||
if (projectDir != null) {
|
||||
try {
|
||||
FileTemplateUtil.createFromTemplate(template, "test_helper.py", null, projectDir);
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error("Failed to create test_helper", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return module;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="util" />
|
||||
<orderEntry type="module" module-name="lang-api" />
|
||||
<orderEntry type="module" module-name="python-community-plugin-core" />
|
||||
<orderEntry type="module" module-name="python-community-plugin-java" />
|
||||
<orderEntry type="module" module-name="student" />
|
||||
<orderEntry type="module" module-name="lang-impl" />
|
||||
<orderEntry type="module" module-name="student-intellij" />
|
||||
<orderEntry type="module" module-name="main" />
|
||||
<orderEntry type="module" module-name="python-community-ide-resources" />
|
||||
<orderEntry type="module" module-name="python-community" />
|
||||
<orderEntry type="module" module-name="openapi" />
|
||||
<orderEntry type="module" module-name="student-python" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -11,15 +11,11 @@
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="student" />
|
||||
<orderEntry type="module" module-name="lang-impl" />
|
||||
<orderEntry type="module" module-name="python-community-ide-resources" />
|
||||
<orderEntry type="module" module-name="python-community" />
|
||||
<orderEntry type="module" module-name="python-community-configure" />
|
||||
<orderEntry type="module" module-name="platform-impl" />
|
||||
<orderEntry type="module" module-name="python-ide-community" />
|
||||
<orderEntry type="library" name="gson" level="project" />
|
||||
<orderEntry type="module" module-name="testFramework" scope="TEST" />
|
||||
<orderEntry type="library" scope="TEST" name="JUnit3" level="project" />
|
||||
<orderEntry type="module" module-name="educational-core" />
|
||||
<orderEntry type="module" module-name="educational-python" />
|
||||
<orderEntry type="module" module-name="python-community-configure" />
|
||||
<orderEntry type="module" module-name="python-ide-community" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,130 +0,0 @@
|
||||
{
|
||||
"name": "Python для начинающих",
|
||||
"description": "Начальный курс по языку Python",
|
||||
"lessons": [
|
||||
{
|
||||
"name": "Первые программа",
|
||||
"task_list": [
|
||||
{
|
||||
"name": "Задание 1",
|
||||
"text": "hello-text.html",
|
||||
"test_file": "hello-tests.py",
|
||||
"test_num": 1,
|
||||
"task_files": {
|
||||
"helloworld.py": {
|
||||
"task_windows": [
|
||||
{
|
||||
"line": 0,
|
||||
"start": 0,
|
||||
"text": "type operator",
|
||||
"hint": "hello-text.html",
|
||||
"possible_answer": "print"
|
||||
},
|
||||
{
|
||||
"line": 0,
|
||||
"start": 33,
|
||||
"text": "type your name",
|
||||
"hint": "empty_study.docs",
|
||||
"possible_answer": "Liana"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Задание 2",
|
||||
"text": "matchends-text.html",
|
||||
"test_file": "matchends-test.py",
|
||||
"test_num": 3,
|
||||
"task_files": {
|
||||
"match_ends.py": {
|
||||
"task_windows": [
|
||||
{
|
||||
"line": 1,
|
||||
"start": 43,
|
||||
"text": "condition",
|
||||
"hint": "empty_study.docs",
|
||||
"possible_answer": ">="
|
||||
},
|
||||
{
|
||||
"line": 1,
|
||||
"start": 61,
|
||||
"text": "index",
|
||||
"hint": "empty_study.docs",
|
||||
"possible_answer": "0"
|
||||
},
|
||||
{
|
||||
"line": 1,
|
||||
"start": 73,
|
||||
"text": "index",
|
||||
"hint": "empty_study.docs",
|
||||
"possible_answer": "-1"
|
||||
},
|
||||
{
|
||||
"line": 2,
|
||||
"start": 11,
|
||||
"text": "function",
|
||||
"hint": "list.docs",
|
||||
"possible_answer": "len"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Простые задачи",
|
||||
"task_list": [
|
||||
{
|
||||
"name": "Задание 1",
|
||||
"text": "sum-text.html",
|
||||
"test_file": "sum_tests.py",
|
||||
"test_num": 3,
|
||||
"user_tests": [
|
||||
{
|
||||
"input": "sum-input.txt",
|
||||
"output": "sum-output"
|
||||
}
|
||||
],
|
||||
"task_files": {
|
||||
"sum.py": {
|
||||
"task_windows": [
|
||||
{
|
||||
"line": 4,
|
||||
"start": 15,
|
||||
"text": "получите из консоли имя файла",
|
||||
"hint": "argv.docs",
|
||||
"possible_answer": "sys.argv[1]"
|
||||
},
|
||||
{
|
||||
"line": 5,
|
||||
"start": 8,
|
||||
"text": "откройте файл на запись",
|
||||
"hint": "empty_study.docs",
|
||||
"possible_answer": "open(filename, 'r')"
|
||||
},
|
||||
{
|
||||
"line": 10,
|
||||
"start": 4,
|
||||
"text": "закройте файл",
|
||||
"hint": "empty_study.docs",
|
||||
"possible_answer": "f.close()"
|
||||
},
|
||||
{
|
||||
"line": 11,
|
||||
"start": 14,
|
||||
"text": "правильно проинициализируйте значение",
|
||||
"hint": "empty_study.docs",
|
||||
"possible_answer": "-sys.maxint"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
]
|
||||
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
type operator("Hello, world! My name is type your name")
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.jetbrains.edu.learning;
|
||||
|
||||
import com.google.gson.FieldNamingPolicy;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.jetbrains.edu.courseFormat.Course;
|
||||
import com.jetbrains.python.PythonHelpersLocator;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
|
||||
|
||||
/**
|
||||
* author: liana
|
||||
* data: 7/4/14.
|
||||
*/
|
||||
public class JsonParserTest extends TestCase {
|
||||
private Course myCourse = null;
|
||||
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
Reader reader = new InputStreamReader(new FileInputStream(getTestDataPath() + "/course.json"));
|
||||
Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create();
|
||||
myCourse = gson.fromJson(reader, Course.class);
|
||||
}
|
||||
|
||||
public void testCourseLevel() {
|
||||
assertEquals(myCourse.getName(), "Python для начинающих");
|
||||
|
||||
//assertEquals(StudyUtils.getFirst(myCourse.getLessons().get(1).getTaskList().get(0).getUserTests()).getInput(), "sum-input.txt");
|
||||
assertEquals(myCourse.getLessons().size(), 2);
|
||||
assertEquals(myCourse.getLessons().get(0).getTaskList().size(), 2);
|
||||
assertEquals(myCourse.getLessons().get(1).getTaskList().size(), 1);
|
||||
}
|
||||
protected String getTestDataPath() {
|
||||
return PythonHelpersLocator.getPythonCommunityPath() + "/edu/interactive-learning-python/testData";
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package com.jetbrains.edu.learning;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.jetbrains.edu.EduDocumentListener;
|
||||
import com.jetbrains.edu.courseFormat.AnswerPlaceholder;
|
||||
import com.jetbrains.edu.courseFormat.TaskFile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class StudyDocumentListenerTest extends StudyTestCase {
|
||||
|
||||
public void testTaskWindowSimpleUpdate() throws Exception {
|
||||
PsiFile psiFile = myFixture.configureByFile("helloworld.py");
|
||||
final Document document = myFixture.getDocument(psiFile);
|
||||
|
||||
TaskFile taskFile = new TaskFile();
|
||||
List<AnswerPlaceholder> answerPlaceholders = new ArrayList<AnswerPlaceholder>();
|
||||
addTaskWindow(answerPlaceholders, 0, 32, 14);
|
||||
taskFile.setAnswerPlaceholders(answerPlaceholders);
|
||||
EduDocumentListener listener = new EduDocumentListener(taskFile);
|
||||
document.addDocumentListener(listener);
|
||||
CommandProcessor.getInstance().executeCommand(myFixture.getProject(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
document.insertString(0, "text");
|
||||
FileDocumentManager.getInstance().saveDocument(document);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, "x", "qwe");
|
||||
assertEquals(answerPlaceholders.get(0).getRealStartOffset(document), 36);
|
||||
}
|
||||
|
||||
private static void addTaskWindow(List<AnswerPlaceholder> answerPlaceholders, int line, int start, int length) {
|
||||
AnswerPlaceholder answerPlaceholder = new AnswerPlaceholder();
|
||||
answerPlaceholder.setLine(line);
|
||||
answerPlaceholder.setStart(start);
|
||||
answerPlaceholder.setLength(length);
|
||||
answerPlaceholders.add(answerPlaceholder);
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package com.jetbrains.edu.learning;
|
||||
|
||||
import com.intellij.testFramework.UsefulTestCase;
|
||||
import com.intellij.testFramework.fixtures.CodeInsightTestFixture;
|
||||
import com.intellij.testFramework.fixtures.IdeaProjectTestFixture;
|
||||
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory;
|
||||
import com.intellij.testFramework.fixtures.TestFixtureBuilder;
|
||||
import com.jetbrains.python.PythonHelpersLocator;
|
||||
|
||||
public abstract class StudyTestCase extends UsefulTestCase {
|
||||
protected CodeInsightTestFixture myFixture;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
final TestFixtureBuilder<IdeaProjectTestFixture> projectBuilder = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(
|
||||
getName());
|
||||
myFixture = IdeaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(projectBuilder.getFixture());
|
||||
myFixture.setUp();
|
||||
myFixture.setTestDataPath(getTestDataPath());
|
||||
}
|
||||
|
||||
protected String getTestDataPath() {
|
||||
return PythonHelpersLocator.getPythonCommunityPath() + "/edu/interactive-learning-python/testData";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
myFixture.tearDown();
|
||||
myFixture = null;
|
||||
super.tearDown();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user