def test_in_progress_documents(self):
        template = insert_new_template(published=True)
        insert_new_document(template.id, name='test')
        insert_new_document(template.id, name='test2')

        response = self.client.get('/generate/edit')
        assert response.status_code == 200
        self.assertEquals(len(self.get_context_variable('documents')), 2)
Exemplo n.º 2
0
    def test_get_documents(self):
        documents = dm.get_all_documents()
        self.assertEquals(len(documents), 1)
        util.insert_new_document(self.template.id, name='second test doc')
        documents = dm.get_all_documents()
        self.assertEquals(len(documents), 2)

        document = dm.get_single_document(2)
        self.assertEquals(document.template_id, self.template.id)
    def test_edit_in_progress_documents(self):
        template = insert_new_template(published=True)
        document = insert_new_document(template.id, name='test')
        insert_new_document(template.id, name='test2')

        self.assertEquals(len(DocumentBase.query.all()), 2)

        response = self.client.post('/generate/edit/' + str(document.id) + '?method=DELETE')
        self.assertEquals(len(DocumentBase.query.all()), 1)
        self.assertEquals(response.status_code, 302)
        self.assertEquals(response.location, 'http://localhost/generate/edit')
Exemplo n.º 4
0
    def test_get_documents_from_single_parent(self):
        template_two = util.insert_new_template(title='test two')
        util.insert_new_document(template_two.id)
        util.insert_new_document(template_two.id)

        documents = dm.get_documents_and_parent_templates()
        test_results = defaultdict(int)
        for document in documents:
            test_results[document.title] += 1

        self.assertEquals(test_results['test'], 1)
        self.assertEquals(test_results['test two'], 2)
        self.assertEquals(len(test_results.keys()), 2)
        self.assertEquals(sum(test_results.values()), 3)

        document = dm.get_single_document_and_parent_template(self.document.id)
        self.assertEquals(document[2], 'test')
 def test_delete_template_cascade(self):
     template = insert_new_template(published=True)
     insert_new_document(template.id, name='test')
     self.client.get('/build/1/edit?method=DELETE')
     self.assertEquals(len(DocumentBase.query.all()), 0)
Exemplo n.º 6
0
 def setUp(self):
     super(DocumentTest, self).setUp()
     self.template = util.insert_new_template()
     util.insert_new_placeholder(template_id=self.template.id)
     util.insert_new_section()
     self.document = util.insert_new_document(self.template.id)