# Path: studio/tests/lib/helpers.py
# def log_in(app, login, password):
#     response = app.get(url('/login'),
#             params={
#                 'login': login,
#                 'password': password,
#                 })
#     assert response.status.startswith('302 ')
# 
# def log_out(app):
#     response = app.get(url('/logout'))
#     assert response.status.startswith('302 ')
# 
# Path: studio/lib/provisionning.py
# def create_layertemplate(lt_name, lt_comment, json, user_id=2):
#     lt = LayerTemplate(lt_name, lt_comment, json, user_id)
#     meta.Session.add(lt)
#     meta.Session.commit()
#     return lt


import simplejson 
from studio.tests import *
from studio.model import *
from studio.tests.lib.helpers import log_in, log_out
from studio.lib.provisionning import create_layertemplate
        assert results[0].json['g'] == 1
        assert results[0].json['h'] == 2
        assert results[0].json['i'] == 3
        
    def test_update(self):
        id1, id2 = self._insert_layertemplates()
        params = {'name': 'layertemplate3',
                  'comment': 'comment for layertemplate3',
                  'json': {'j': 4, 'k': 5, 'l': 6}}     
        response = self.app.put(url('LayerTemplates', id=id2),
                                params = simplejson.dumps(params),
                                content_type='application/json')
        results = meta.Session.query(LayerTemplate).all()
        assert len(results) == 2
        assert results[1].id == id2
        assert results[1].name == 'layertemplate3'
        assert results[1].comment == 'comment for layertemplate3'
        assert results[1].json['j'] == 4
        assert results[1].json['k'] == 5
        assert results[1].json['l'] == 6
       
    def test_delete(self):
        id1, id2 = self._insert_layertemplates()
        response = self.app.delete(url('LayerTemplates', id=id1))
        results = meta.Session.query(LayerTemplate).all()
        assert len(results) == 1
        assert results[0].id == id2
        assert results[0].name == 'layertemplate2'
        assert len(results[0].json['test']) == 2
        

# Path: studio/tests/lib/helpers.py
# def log_in(app, login, password):
#     response = app.get(url('/login'),
#             params={
#                 'login': login,
#                 'password': password,
#                 })
#     assert response.status.startswith('302 ')
# 
# def log_out(app):
#     response = app.get(url('/logout'))
#     assert response.status.startswith('302 ')
# 
# Path: studio/lib/provisionning.py
# def create_layertemplate(lt_name, lt_comment, json, user_id=2):
#     lt = LayerTemplate(lt_name, lt_comment, json, user_id)
#     meta.Session.add(lt)
#     meta.Session.commit()
#     return lt


# Path: studio/tests/functional/test_layertemplates.py
import simplejson 
from studio.tests import *
from studio.model import *
from studio.tests.lib.helpers import log_in, log_out
from studio.lib.provisionning import create_layertemplate

        assert results[0].json['g'] == 1
        assert results[0].json['h'] == 2
        assert results[0].json['i'] == 3
        
    def test_update(self):
        id1, id2 = self._insert_layertemplates()
        params = {'name': 'layertemplate3',
                  'comment': 'comment for layertemplate3',
                  'json': {'j': 4, 'k': 5, 'l': 6}}     
        response = self.app.put(url('LayerTemplates', id=id2),
                                params = simplejson.dumps(params),
                                content_type='application/json')
        results = meta.Session.query(LayerTemplate).all()
        assert len(results) == 2
        assert results[1].id == id2
        assert results[1].name == 'layertemplate3'
        assert results[1].comment == 'comment for layertemplate3'
        assert results[1].json['j'] == 4
        assert results[1].json['k'] == 5
        assert results[1].json['l'] == 6
       
    def test_delete(self):
        id1, id2 = self._insert_layertemplates()
        response = self.app.delete(url('LayerTemplates', id=id1))
        results = meta.Session.query(LayerTemplate).all()
        assert len(results) == 1
        assert results[0].id == id2
        assert results[0].name == 'layertemplate2'
        assert len(results[0].json['test']) == 2
        

    def test_show(self):