def setUp(self): self.app = create_app('testing') self.app_context = self.app.app_context() self.app_context.push() db.create_all() Role.insert_roles() User.add_admin() User.add_test_user() Category.add_none() self.client = self.app.test_client()
def test_06_category_posts_count(self): Category.add_none() none = Category.query.get(1) category = Category(name='tester', parent_category=Category.query.get(1)) category.save() self.assertTrue(none.posts_count() == 0) post = Post(body='# Post Big title', category=category) post.save() self.assertTrue(none.posts_count() == 1) self.assertTrue(category.posts_count() == 1) query = Post.query self.assertTrue(none.posts_count(query) == 1) self.assertTrue(category.posts_count(query) == 1)
def test_04_category_repr_save_and_delete(self): self.assertTrue(Category.query.count() == 0) Category.add_none() category = Category(name='tester', parent_category=Category.query.get(1)) category.save() self.assertTrue( '<Category tester Parent None Son []>' == category.__repr__()) self.assertTrue(Category.query.count() == 2) post = Post(body='# Post Big title', category=category) post.save() self.assertTrue(category.posts.count() == 1) category.delete() self.assertTrue(Category.query.count() == 1) self.assertTrue(post.category_id == 1)
def setUpClass(cls): cls.base_url = 'http://127.0.0.1:5000' try: cls.client = webdriver.Firefox() except: pass if cls.client: cls.app = create_app('testing') cls.app_context = cls.app.app_context() cls.app_context.push() import logging logger = logging.getLogger('werkzeug') logger.setLevel("ERROR") db.create_all() Role.insert_roles() User.add_admin() User.add_test_user() Category.add_none() threading.Thread(target=cls.app.run).start()
def deploy(): """Run deployment task""" if not os.path.isfile(app.config['SQLALCHEMY_DATABASE_URI'][10:]): db.create_all() print 'Datebase created.' Role.insert_roles() User.add_self_follows() User.add_admin() User.add_test_user() print 'add admin :'\ '\[email protected]'\ '\npassword=1234' Category.add_none() print 'Category insert None.' else: print 'database already exists!' admin_id = input('admin_id:') while True: if User.query.get(admin_id): User.add_admin_dialogue(admin_id) break else: admin_id = input('get admin error!\nadmin_id:') print 'User config.'
def test_05_category_add_none(self): post = Post(body='# Post Big title') post.save() self.assertTrue(post.category is None) Category.add_none() self.assertTrue(post.category == Category.query.get(1))