diff options
author | Tor Norbye <tnorbye@google.com> | 2014-08-20 17:01:23 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2014-08-20 17:01:23 -0700 |
commit | 1aa2e09bdbd413eacb677e9fa4b50630530d0656 (patch) | |
tree | 2f4cc6d69645bd460aa253fdecb606d764fbd25d /python/edu/learn-python/tests/JsonParserTest.java | |
parent | 02cf98d65c798d368fcec43ed64a001d513bdd4f (diff) | |
download | idea-1aa2e09bdbd413eacb677e9fa4b50630530d0656.tar.gz |
Snapshot idea/138.1696 from git://git.jetbrains.org/idea/community.git
Change-Id: I50c97b83a815ce635e49a38380ba5b8765e4b16a
Diffstat (limited to 'python/edu/learn-python/tests/JsonParserTest.java')
-rw-r--r-- | python/edu/learn-python/tests/JsonParserTest.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/python/edu/learn-python/tests/JsonParserTest.java b/python/edu/learn-python/tests/JsonParserTest.java new file mode 100644 index 000000000000..903f0a539acf --- /dev/null +++ b/python/edu/learn-python/tests/JsonParserTest.java @@ -0,0 +1,37 @@ +import com.google.gson.FieldNamingPolicy; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import org.junit.Before; +import org.junit.Test; +import com.jetbrains.python.edu.StudyUtils; +import com.jetbrains.python.edu.course.Course; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStreamReader; +import java.io.Reader; + +import static org.junit.Assert.assertEquals; + +/** + * author: liana + * data: 7/4/14. + */ +public class JsonParserTest { + private Course myCourse = null; + @Before + public void setUp() throws FileNotFoundException { + Reader reader = new InputStreamReader(new FileInputStream("EDIDE/testData/course.json")); + Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create(); + myCourse = gson.fromJson(reader, Course.class); + } + + @Test + 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); + } +} |