コード例 #1
0
ファイル: tests.py プロジェクト: geaden/geaden_web
 def test_skill_model(self):
     load()
     skill = Skill(title='Python', desc='Cool',
                   links=['http://www.github.com/'])
     skill.approve()
     self.assertEquals(skill.approved, 1)
     skills = Skill.all()
     self.assertEquals(len(skills), 4)
     s_key = skill.put()
     skill.id = s_key.id()
     skill.put()
     Skill.get(skill.id)
     self.assertEquals(skill.id, s_key.id())
コード例 #2
0
ファイル: tests.py プロジェクト: geaden/geaden_web
 def test_skills_handler(self):
     load()
     response = self.testapp.get('/skills')
     self.assertEquals(response.status_int, 200)
     self.assertEquals(response.content_type, 'application/json')
     data = json.loads(response.normal_body)
     self.assertEquals(4, len(data))
     # Approve skill
     skill = Skill(title="Math").put()
     response = self.testapp.post_json('/skills/approve/',
                                       {'_id': skill.id()})
     self.assertEquals(response.status_int, 201)
     self.assertEquals(Skill.get(skill.id()).approved, 1)
     # Create skill
     before = len(Skill.all())
     post_data = {'action': 'new',
                  'data': {'title': 'Python',
                           'desc': 'Love it!',
                           'links': [{'url': 'http://www.github.com',
                                      'title': 'My Github'}]}}
     response = self.testapp.post_json('/skills', post_data)
     self.assertEquals(response.status_int, 201)
     self.assertEquals(response.content_type, 'application/json')
     self.assertEquals(before + 1, len(Skill.all()))
     # Remove skill
     before = len(Skill.all())
     response = self.testapp.post_json('/skills',
                                       {'_id': skill.id(),
                                        'action': 'delete'})
     self.assertEquals(response.status_int, 200)
     self.assertEquals(before - 1, len(Skill.all()))
     # Updte skill
     links_before = len(Link.query().fetch())
     skill = Skill(title='Foo', desc='Bar').put()
     post_data = {'action': 'update',
                  'data': {'_id': skill.id(),
                           'title': 'Noob',
                           'desc': 'Noob!',
                           'links': [{'url': 'http://www.noob.com',
                                      'title': 'Noob Com'}]}}
     response = self.testapp.post_json('/skills', post_data)
     self.assertEquals(200, response.status_int)
     self.assertEquals(links_before + 1, len(Link.query().fetch()),
                       msg="Should create new link.")
     skill = Skill.get(skill.id())
     self.assertEquals(len(skill.links), 1)
     self.assertEquals(skill.title, 'Noob')
コード例 #3
0
ファイル: tests.py プロジェクト: geaden/geaden_web
 def test_delete_skill(self):
     skill = Skill(title='foo').put()
     s = Skill.get(skill.id())
     s.enabled = False
     s.put()
     self.assertEquals(0, len(Skill.all()))