소스 검색

start working on better testings

Oz N Tiram 9 년 전
부모
커밋
ca220fcab4
1개의 변경된 파일62개의 추가작업 그리고 0개의 파일을 삭제
  1. 62 0
      tests/test.py

+ 62 - 0
tests/test.py

@@ -0,0 +1,62 @@
+import os
+from blogit.blogit import CONFIG
+
+
+CONFIG['content_root'] = 'test_root'
+
+tags = ['foo', 'bar', 'baz', 'bug', 'buf']
+
+shift = lambda l, n: l[-n:] + l[:-n]
+
+post = '''\
+---
+title: Blog post {number}
+author: Famous author
+published: 2015-01-{number}
+tags: {tags}
+public: yes
+chronological: yes
+kind: writing
+summary: This is a summry of post {number}. Donec id elit non mi porta gravida at eget metus. Fusce dapibus
+---
+
+This is the body of post {number}. Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.
+
+This is a snippet in bash
+
+```bash
+$ for i in `seq 1 10`; do
+   echo $i
+done
+
+VAR="variable"
+echo $VAR
+# This is a very long long long long long long long long long long comment
+```
+
+This is a snippet in python
+
+```python
+def yay(top):
+    for i in range(1, top+1):
+            yield i
+
+for i in yay:
+    print(i)
+```
+'''
+
+try:
+    os.mkdir(CONFIG['content_root'])
+except OSError:
+    pass
+
+shift_factors = map(lambda x: (x - 1) / 5 +1,   range(1,21))
+
+
+for i in range(1,21):
+    f = open((os.path.join(CONFIG['content_root'], 'post' + str(i) + '.md')),
+             'w')
+    d = {'number': i,
+         'tags': shift(tags, shift_factors[i-1])[:-1] }
+    f.write(post.format(**d))