|  | @@ -10,6 +10,7 @@ import transaction
 | 
	
		
			
			| 10 | 10 |  
 | 
	
		
			
			| 11 | 11 |  # from tracim.lib.content import ContentApi
 | 
	
		
			
			| 12 | 12 |  from tracim.exceptions import ContentRevisionUpdateError
 | 
	
		
			
			|  | 13 | +from tracim.lib.content import ContentApi
 | 
	
		
			
			| 13 | 14 |  from tracim.models import Content
 | 
	
		
			
			| 14 | 15 |  from tracim.models.revision_protection import new_revision
 | 
	
		
			
			| 15 | 16 |  from tracim.models import User
 | 
	
	
		
			
			|  | @@ -25,55 +26,82 @@ class TestContent(StandardTest):
 | 
	
		
			
			| 25 | 26 |      @raises(ContentRevisionUpdateError)
 | 
	
		
			
			| 26 | 27 |      def test_update_without_prepare(self):
 | 
	
		
			
			| 27 | 28 |          content1 = self.test_create()
 | 
	
		
			
			| 28 |  | -        content1.description = 'FOO'  # Raise ContentRevisionUpdateError because revision can't be updated
 | 
	
		
			
			| 29 |  | -
 | 
	
		
			
			| 30 |  | -    # TODO - G.M - 28-03-2018 - [libContent] Reenable this test when libContent is available
 | 
	
		
			
			| 31 |  | -    # def test_query(self):
 | 
	
		
			
			| 32 |  | -    #     content1 = self.test_create()
 | 
	
		
			
			| 33 |  | -    #     with new_revision(content1):
 | 
	
		
			
			| 34 |  | -    #         content1.description = 'TEST_CONTENT_DESCRIPTION_1_UPDATED'
 | 
	
		
			
			| 35 |  | -    #     DBSession.flush()
 | 
	
		
			
			| 36 |  | -    #
 | 
	
		
			
			| 37 |  | -    #     content2 = self.test_create(key='2')
 | 
	
		
			
			| 38 |  | -    #     with new_revision(content2):
 | 
	
		
			
			| 39 |  | -    #         content2.description = 'TEST_CONTENT_DESCRIPTION_2_UPDATED'
 | 
	
		
			
			| 40 |  | -    #     DBSession.flush()
 | 
	
		
			
			| 41 |  | -    #
 | 
	
		
			
			| 42 |  | -    #     workspace1 = DBSession.query(Workspace).filter(Workspace.label == 'TEST_WORKSPACE_1').one()
 | 
	
		
			
			| 43 |  | -    #     workspace2 = DBSession.query(Workspace).filter(Workspace.label == 'TEST_WORKSPACE_2').one()
 | 
	
		
			
			| 44 |  | -    #
 | 
	
		
			
			| 45 |  | -    #     # To get Content in database we have to join Content and ContentRevisionRO with particular condition:
 | 
	
		
			
			| 46 |  | -    #     # Join have to be on most recent revision
 | 
	
		
			
			| 47 |  | -    #     join_sub_query = DBSession.query(ContentRevisionRO.revision_id)\
 | 
	
		
			
			| 48 |  | -    #         .filter(ContentRevisionRO.content_id == Content.id)\
 | 
	
		
			
			| 49 |  | -    #         .order_by(ContentRevisionRO.revision_id.desc())\
 | 
	
		
			
			| 50 |  | -    #         .limit(1)\
 | 
	
		
			
			| 51 |  | -    #         .correlate(Content)
 | 
	
		
			
			| 52 |  | -    #
 | 
	
		
			
			| 53 |  | -    #     base_query = DBSession.query(Content)\
 | 
	
		
			
			| 54 |  | -    #         .join(ContentRevisionRO, and_(Content.id == ContentRevisionRO.content_id,
 | 
	
		
			
			| 55 |  | -    #                                       ContentRevisionRO.revision_id == join_sub_query))
 | 
	
		
			
			| 56 |  | -    #
 | 
	
		
			
			| 57 |  | -    #     pattern = 'TEST_CONTENT_DESCRIPTION_%_UPDATED'
 | 
	
		
			
			| 58 |  | -    #     eq_(2, base_query.filter(Content.description.like(pattern)).count())
 | 
	
		
			
			| 59 |  | -    #
 | 
	
		
			
			| 60 |  | -    #     eq_(1, base_query.filter(Content.workspace == workspace1).count())
 | 
	
		
			
			| 61 |  | -    #     eq_(1, base_query.filter(Content.workspace == workspace2).count())
 | 
	
		
			
			| 62 |  | -    #
 | 
	
		
			
			| 63 |  | -    #     content1_from_query = base_query.filter(Content.workspace == workspace1).one()
 | 
	
		
			
			| 64 |  | -    #     eq_(content1.id, content1_from_query.id)
 | 
	
		
			
			| 65 |  | -    #     eq_('TEST_CONTENT_DESCRIPTION_1_UPDATED', content1_from_query.description)
 | 
	
		
			
			| 66 |  | -    #
 | 
	
		
			
			| 67 |  | -    #     user_admin = DBSession.query(User).filter(User.email == 'admin@admin.admin').one()
 | 
	
		
			
			| 68 |  | -    #
 | 
	
		
			
			| 69 |  | -    #     api = ContentApi(None)
 | 
	
		
			
			| 70 |  | -    #
 | 
	
		
			
			| 71 |  | -    #     content1_from_api = api.get_one(content1.id, ContentType.Page, workspace1)
 | 
	
		
			
			|  | 29 | +        content1.description = 'FOO'
 | 
	
		
			
			|  | 30 | +        # Raise ContentRevisionUpdateError because revision can't be updated
 | 
	
		
			
			|  | 31 | +
 | 
	
		
			
			|  | 32 | +    def test_query(self):
 | 
	
		
			
			|  | 33 | +        content1 = self.test_create()
 | 
	
		
			
			|  | 34 | +        with new_revision(
 | 
	
		
			
			|  | 35 | +                session=self.session,
 | 
	
		
			
			|  | 36 | +                tm=transaction.manager,
 | 
	
		
			
			|  | 37 | +                content=content1,
 | 
	
		
			
			|  | 38 | +        ):
 | 
	
		
			
			|  | 39 | +            content1.description = 'TEST_CONTENT_DESCRIPTION_1_UPDATED'
 | 
	
		
			
			|  | 40 | +        self.session.flush()
 | 
	
		
			
			|  | 41 | +
 | 
	
		
			
			|  | 42 | +        content2 = self.test_create(key='2')
 | 
	
		
			
			|  | 43 | +        with new_revision(
 | 
	
		
			
			|  | 44 | +            session=self.session,
 | 
	
		
			
			|  | 45 | +            tm=transaction.manager,
 | 
	
		
			
			|  | 46 | +            content=content2,
 | 
	
		
			
			|  | 47 | +        ):
 | 
	
		
			
			|  | 48 | +            content2.description = 'TEST_CONTENT_DESCRIPTION_2_UPDATED'
 | 
	
		
			
			|  | 49 | +        self.session.flush()
 | 
	
		
			
			|  | 50 | +
 | 
	
		
			
			|  | 51 | +        workspace1 = self.session.query(Workspace)\
 | 
	
		
			
			|  | 52 | +            .filter(Workspace.label == 'TEST_WORKSPACE_1').one()
 | 
	
		
			
			|  | 53 | +        workspace2 = self.session.query(Workspace)\
 | 
	
		
			
			|  | 54 | +            .filter(Workspace.label == 'TEST_WORKSPACE_2').one()
 | 
	
		
			
			|  | 55 | +
 | 
	
		
			
			|  | 56 | +        # To get Content in database
 | 
	
		
			
			|  | 57 | +        # we have to join Content and ContentRevisionRO
 | 
	
		
			
			|  | 58 | +        # with particular condition:
 | 
	
		
			
			|  | 59 | +        # Join have to be on most recent revision
 | 
	
		
			
			|  | 60 | +        join_sub_query = self.session.query(ContentRevisionRO.revision_id)\
 | 
	
		
			
			|  | 61 | +            .filter(ContentRevisionRO.content_id == Content.id)\
 | 
	
		
			
			|  | 62 | +            .order_by(ContentRevisionRO.revision_id.desc())\
 | 
	
		
			
			|  | 63 | +            .limit(1)\
 | 
	
		
			
			|  | 64 | +            .correlate(Content)
 | 
	
		
			
			|  | 65 | +
 | 
	
		
			
			|  | 66 | +        base_query = self.session.query(Content).join(
 | 
	
		
			
			|  | 67 | +            ContentRevisionRO,
 | 
	
		
			
			|  | 68 | +            and_(
 | 
	
		
			
			|  | 69 | +                Content.id == ContentRevisionRO.content_id,
 | 
	
		
			
			|  | 70 | +                ContentRevisionRO.revision_id == join_sub_query
 | 
	
		
			
			|  | 71 | +            )
 | 
	
		
			
			|  | 72 | +        )
 | 
	
		
			
			|  | 73 | +
 | 
	
		
			
			|  | 74 | +        pattern = 'TEST_CONTENT_DESCRIPTION_%_UPDATED'
 | 
	
		
			
			|  | 75 | +        eq_(2, base_query.filter(Content.description.like(pattern)).count())
 | 
	
		
			
			|  | 76 | +
 | 
	
		
			
			|  | 77 | +        eq_(1, base_query.filter(Content.workspace == workspace1).count())
 | 
	
		
			
			|  | 78 | +        eq_(1, base_query.filter(Content.workspace == workspace2).count())
 | 
	
		
			
			|  | 79 | +
 | 
	
		
			
			|  | 80 | +        content1_from_query = base_query\
 | 
	
		
			
			|  | 81 | +            .filter(Content.workspace == workspace1).one()
 | 
	
		
			
			|  | 82 | +        eq_(content1.id, content1_from_query.id)
 | 
	
		
			
			|  | 83 | +        eq_(
 | 
	
		
			
			|  | 84 | +            'TEST_CONTENT_DESCRIPTION_1_UPDATED',
 | 
	
		
			
			|  | 85 | +            content1_from_query.description
 | 
	
		
			
			|  | 86 | +        )
 | 
	
		
			
			|  | 87 | +
 | 
	
		
			
			|  | 88 | +        user_admin = self.session.query(User)\
 | 
	
		
			
			|  | 89 | +            .filter(User.email == 'admin@admin.admin').one()
 | 
	
		
			
			|  | 90 | +
 | 
	
		
			
			|  | 91 | +        api = ContentApi(current_user=None, session=self.session)
 | 
	
		
			
			|  | 92 | +
 | 
	
		
			
			|  | 93 | +        content1_from_api = api.get_one(
 | 
	
		
			
			|  | 94 | +            content1.id,
 | 
	
		
			
			|  | 95 | +            ContentType.Page,
 | 
	
		
			
			|  | 96 | +            workspace1
 | 
	
		
			
			|  | 97 | +        )
 | 
	
		
			
			| 72 | 98 |  
 | 
	
		
			
			| 73 | 99 |      def test_update(self):
 | 
	
		
			
			| 74 | 100 |          created_content = self.test_create()
 | 
	
		
			
			| 75 |  | -        content = self.session.query(Content).filter(Content.id == created_content.id).one()
 | 
	
		
			
			| 76 |  | -        eq_(1, self.session.query(ContentRevisionRO).filter(ContentRevisionRO.label == 'TEST_CONTENT_1').count())
 | 
	
		
			
			|  | 101 | +        content = self.session.query(Content)\
 | 
	
		
			
			|  | 102 | +            .filter(Content.id == created_content.id).one()
 | 
	
		
			
			|  | 103 | +        eq_(1, self.session.query(ContentRevisionRO)
 | 
	
		
			
			|  | 104 | +            .filter(ContentRevisionRO.label == 'TEST_CONTENT_1').count())
 | 
	
		
			
			| 77 | 105 |  
 | 
	
		
			
			| 78 | 106 |          with new_revision(
 | 
	
		
			
			| 79 | 107 |                  session=self.session,
 | 
	
	
		
			
			|  | @@ -84,8 +112,18 @@ class TestContent(StandardTest):
 | 
	
		
			
			| 84 | 112 |              content.description = 'TEST_CONTENT_DESCRIPTION_1_UPDATED'
 | 
	
		
			
			| 85 | 113 |          self.session.flush()
 | 
	
		
			
			| 86 | 114 |  
 | 
	
		
			
			| 87 |  | -        eq_(2, self.session.query(ContentRevisionRO).filter(ContentRevisionRO.label == 'TEST_CONTENT_1').count())
 | 
	
		
			
			| 88 |  | -        eq_(1, self.session.query(Content).filter(Content.id == created_content.id).count())
 | 
	
		
			
			|  | 115 | +        eq_(
 | 
	
		
			
			|  | 116 | +            2,
 | 
	
		
			
			|  | 117 | +            self.session.query(ContentRevisionRO).filter(
 | 
	
		
			
			|  | 118 | +                ContentRevisionRO.label == 'TEST_CONTENT_1'
 | 
	
		
			
			|  | 119 | +            ).count()
 | 
	
		
			
			|  | 120 | +        )
 | 
	
		
			
			|  | 121 | +        eq_(
 | 
	
		
			
			|  | 122 | +            1,
 | 
	
		
			
			|  | 123 | +            self.session.query(Content).filter(
 | 
	
		
			
			|  | 124 | +                Content.id == created_content.id
 | 
	
		
			
			|  | 125 | +            ).count()
 | 
	
		
			
			|  | 126 | +        )
 | 
	
		
			
			| 89 | 127 |  
 | 
	
		
			
			| 90 | 128 |          with new_revision(
 | 
	
		
			
			| 91 | 129 |                  session=self.session,
 | 
	
	
		
			
			|  | @@ -97,15 +135,28 @@ class TestContent(StandardTest):
 | 
	
		
			
			| 97 | 135 |              content.label = 'TEST_CONTENT_1_UPDATED_2'
 | 
	
		
			
			| 98 | 136 |          self.session.flush()
 | 
	
		
			
			| 99 | 137 |  
 | 
	
		
			
			| 100 |  | -        eq_(1, self.session.query(ContentRevisionRO).filter(ContentRevisionRO.label == 'TEST_CONTENT_1_UPDATED_2').count())
 | 
	
		
			
			| 101 |  | -        eq_(1, self.session.query(Content).filter(Content.id == created_content.id).count())
 | 
	
		
			
			|  | 138 | +        eq_(
 | 
	
		
			
			|  | 139 | +            1,
 | 
	
		
			
			|  | 140 | +            self.session.query(ContentRevisionRO).filter(
 | 
	
		
			
			|  | 141 | +                ContentRevisionRO.label == 'TEST_CONTENT_1_UPDATED_2'
 | 
	
		
			
			|  | 142 | +            ).count()
 | 
	
		
			
			|  | 143 | +        )
 | 
	
		
			
			|  | 144 | +        eq_(
 | 
	
		
			
			|  | 145 | +            1,
 | 
	
		
			
			|  | 146 | +            self.session.query(Content).filter(
 | 
	
		
			
			|  | 147 | +                Content.id == created_content.id
 | 
	
		
			
			|  | 148 | +            ).count()
 | 
	
		
			
			|  | 149 | +        )
 | 
	
		
			
			| 102 | 150 |  
 | 
	
		
			
			| 103 |  | -        revision_1 = self.session.query(ContentRevisionRO)\
 | 
	
		
			
			| 104 |  | -            .filter(ContentRevisionRO.description == 'TEST_CONTENT_DESCRIPTION_1').one()
 | 
	
		
			
			| 105 |  | -        revision_2 = self.session.query(ContentRevisionRO)\
 | 
	
		
			
			| 106 |  | -            .filter(ContentRevisionRO.description == 'TEST_CONTENT_DESCRIPTION_1_UPDATED').one()
 | 
	
		
			
			| 107 |  | -        revision_3 = self.session.query(ContentRevisionRO)\
 | 
	
		
			
			| 108 |  | -            .filter(ContentRevisionRO.description == 'TEST_CONTENT_DESCRIPTION_1_UPDATED_2').one()
 | 
	
		
			
			|  | 151 | +        revision_1 = self.session.query(ContentRevisionRO).filter(
 | 
	
		
			
			|  | 152 | +            ContentRevisionRO.description == 'TEST_CONTENT_DESCRIPTION_1'
 | 
	
		
			
			|  | 153 | +        ).one()
 | 
	
		
			
			|  | 154 | +        revision_2 = self.session.query(ContentRevisionRO).filter(
 | 
	
		
			
			|  | 155 | +            ContentRevisionRO.description == 'TEST_CONTENT_DESCRIPTION_1_UPDATED'  # nopep8
 | 
	
		
			
			|  | 156 | +        ).one()
 | 
	
		
			
			|  | 157 | +        revision_3 = self.session.query(ContentRevisionRO).filter(
 | 
	
		
			
			|  | 158 | +            ContentRevisionRO.description == 'TEST_CONTENT_DESCRIPTION_1_UPDATED_2'  # nopep8
 | 
	
		
			
			|  | 159 | +        ).one()
 | 
	
		
			
			| 109 | 160 |  
 | 
	
		
			
			| 110 | 161 |          # Updated dates must be different
 | 
	
		
			
			| 111 | 162 |          ok_(revision_1.updated < revision_2.updated < revision_3.updated)
 | 
	
	
		
			
			|  | @@ -113,14 +164,31 @@ class TestContent(StandardTest):
 | 
	
		
			
			| 113 | 164 |          ok_(revision_1.created == revision_2.created == revision_3.created)
 | 
	
		
			
			| 114 | 165 |  
 | 
	
		
			
			| 115 | 166 |      def test_creates(self):
 | 
	
		
			
			| 116 |  | -        eq_(0, self.session.query(ContentRevisionRO).filter(ContentRevisionRO.label == 'TEST_CONTENT_1').count())
 | 
	
		
			
			| 117 |  | -        eq_(0, self.session.query(Workspace).filter(Workspace.label == 'TEST_WORKSPACE_1').count())
 | 
	
		
			
			|  | 167 | +        eq_(
 | 
	
		
			
			|  | 168 | +            0,
 | 
	
		
			
			|  | 169 | +            self.session.query(ContentRevisionRO).filter(
 | 
	
		
			
			|  | 170 | +                ContentRevisionRO.label == 'TEST_CONTENT_1'
 | 
	
		
			
			|  | 171 | +            ).count()
 | 
	
		
			
			|  | 172 | +        )
 | 
	
		
			
			|  | 173 | +        eq_(
 | 
	
		
			
			|  | 174 | +            0,
 | 
	
		
			
			|  | 175 | +            self.session.query(Workspace).filter(
 | 
	
		
			
			|  | 176 | +                Workspace.label == 'TEST_WORKSPACE_1'
 | 
	
		
			
			|  | 177 | +            ).count()
 | 
	
		
			
			|  | 178 | +        )
 | 
	
		
			
			| 118 | 179 |  
 | 
	
		
			
			| 119 |  | -        user_admin = self.session.query(User).filter(User.email == 'admin@admin.admin').one()
 | 
	
		
			
			|  | 180 | +        user_admin = self.session.query(User).filter(
 | 
	
		
			
			|  | 181 | +            User.email == 'admin@admin.admin'
 | 
	
		
			
			|  | 182 | +        ).one()
 | 
	
		
			
			| 120 | 183 |          workspace = Workspace(label="TEST_WORKSPACE_1")
 | 
	
		
			
			| 121 | 184 |          self.session.add(workspace)
 | 
	
		
			
			| 122 | 185 |          self.session.flush()
 | 
	
		
			
			| 123 |  | -        eq_(1, self.session.query(Workspace).filter(Workspace.label == 'TEST_WORKSPACE_1').count())
 | 
	
		
			
			|  | 186 | +        eq_(
 | 
	
		
			
			|  | 187 | +            1,
 | 
	
		
			
			|  | 188 | +            self.session.query(Workspace).filter(
 | 
	
		
			
			|  | 189 | +                Workspace.label == 'TEST_WORKSPACE_1'
 | 
	
		
			
			|  | 190 | +            ).count()
 | 
	
		
			
			|  | 191 | +        )
 | 
	
		
			
			| 124 | 192 |  
 | 
	
		
			
			| 125 | 193 |          first_content = self._create_content(
 | 
	
		
			
			| 126 | 194 |              owner=user_admin,
 | 
	
	
		
			
			|  | @@ -133,9 +201,16 @@ class TestContent(StandardTest):
 | 
	
		
			
			| 133 | 201 |              is_archived=False,
 | 
	
		
			
			| 134 | 202 |          )
 | 
	
		
			
			| 135 | 203 |  
 | 
	
		
			
			| 136 |  | -        eq_(1, self.session.query(ContentRevisionRO).filter(ContentRevisionRO.label == 'TEST_CONTENT_1').count())
 | 
	
		
			
			|  | 204 | +        eq_(
 | 
	
		
			
			|  | 205 | +            1,
 | 
	
		
			
			|  | 206 | +            self.session.query(ContentRevisionRO).filter(
 | 
	
		
			
			|  | 207 | +                ContentRevisionRO.label == 'TEST_CONTENT_1'
 | 
	
		
			
			|  | 208 | +            ).count()
 | 
	
		
			
			|  | 209 | +        )
 | 
	
		
			
			| 137 | 210 |  
 | 
	
		
			
			| 138 |  | -        content = self.session.query(Content).filter(Content.id == first_content.id).one()
 | 
	
		
			
			|  | 211 | +        content = self.session.query(Content).filter(
 | 
	
		
			
			|  | 212 | +            Content.id == first_content.id
 | 
	
		
			
			|  | 213 | +        ).one()
 | 
	
		
			
			| 139 | 214 |          eq_('TEST_CONTENT_1', content.label)
 | 
	
		
			
			| 140 | 215 |          eq_('TEST_CONTENT_DESCRIPTION_1', content.description)
 | 
	
		
			
			| 141 | 216 |  
 | 
	
	
		
			
			|  | @@ -149,21 +224,43 @@ class TestContent(StandardTest):
 | 
	
		
			
			| 149 | 224 |              revision_type=ActionDescription.CREATION
 | 
	
		
			
			| 150 | 225 |          )
 | 
	
		
			
			| 151 | 226 |  
 | 
	
		
			
			| 152 |  | -        eq_(1, self.session.query(ContentRevisionRO).filter(ContentRevisionRO.label == 'TEST_CONTENT_2').count())
 | 
	
		
			
			|  | 227 | +        eq_(
 | 
	
		
			
			|  | 228 | +            1,
 | 
	
		
			
			|  | 229 | +            self.session.query(ContentRevisionRO).filter(
 | 
	
		
			
			|  | 230 | +                ContentRevisionRO.label == 'TEST_CONTENT_2'
 | 
	
		
			
			|  | 231 | +            ).count()
 | 
	
		
			
			|  | 232 | +        )
 | 
	
		
			
			| 153 | 233 |  
 | 
	
		
			
			| 154 |  | -        content = self.session.query(Content).filter(Content.id == second_content.id).one()
 | 
	
		
			
			|  | 234 | +        content = self.session.query(Content).filter(
 | 
	
		
			
			|  | 235 | +            Content.id == second_content.id
 | 
	
		
			
			|  | 236 | +        ).one()
 | 
	
		
			
			| 155 | 237 |          eq_('TEST_CONTENT_2', content.label)
 | 
	
		
			
			| 156 | 238 |          eq_('TEST_CONTENT_DESCRIPTION_2', content.description)
 | 
	
		
			
			| 157 | 239 |  
 | 
	
		
			
			| 158 | 240 |      def test_create(self, key='1'):
 | 
	
		
			
			| 159 |  | -        eq_(0, self.session.query(ContentRevisionRO).filter(ContentRevisionRO.label == 'TEST_CONTENT_%s' % key).count())
 | 
	
		
			
			| 160 |  | -        eq_(0, self.session.query(Workspace).filter(Workspace.label == 'TEST_WORKSPACE_%s' % key).count())
 | 
	
		
			
			|  | 241 | +        eq_(
 | 
	
		
			
			|  | 242 | +            0,
 | 
	
		
			
			|  | 243 | +            self.session.query(ContentRevisionRO).filter(
 | 
	
		
			
			|  | 244 | +                ContentRevisionRO.label == 'TEST_CONTENT_%s' % key).count()
 | 
	
		
			
			|  | 245 | +        )
 | 
	
		
			
			|  | 246 | +        eq_(
 | 
	
		
			
			|  | 247 | +            0,
 | 
	
		
			
			|  | 248 | +            self.session.query(Workspace).filter(
 | 
	
		
			
			|  | 249 | +                Workspace.label == 'TEST_WORKSPACE_%s' % key).count()
 | 
	
		
			
			|  | 250 | +        )
 | 
	
		
			
			| 161 | 251 |  
 | 
	
		
			
			| 162 |  | -        user_admin = self.session.query(User).filter(User.email == 'admin@admin.admin').one()
 | 
	
		
			
			|  | 252 | +        user_admin = self.session.query(User).filter(
 | 
	
		
			
			|  | 253 | +            User.email == 'admin@admin.admin'
 | 
	
		
			
			|  | 254 | +        ).one()
 | 
	
		
			
			| 163 | 255 |          workspace = Workspace(label="TEST_WORKSPACE_%s" % key)
 | 
	
		
			
			| 164 | 256 |          self.session.add(workspace)
 | 
	
		
			
			| 165 | 257 |          self.session.flush()
 | 
	
		
			
			| 166 |  | -        eq_(1, self.session.query(Workspace).filter(Workspace.label == 'TEST_WORKSPACE_%s' % key).count())
 | 
	
		
			
			|  | 258 | +        eq_(
 | 
	
		
			
			|  | 259 | +            1,
 | 
	
		
			
			|  | 260 | +            self.session.query(Workspace).filter(
 | 
	
		
			
			|  | 261 | +                Workspace.label == 'TEST_WORKSPACE_%s' % key
 | 
	
		
			
			|  | 262 | +            ).count()
 | 
	
		
			
			|  | 263 | +        )
 | 
	
		
			
			| 167 | 264 |  
 | 
	
		
			
			| 168 | 265 |          created_content = self._create_content(
 | 
	
		
			
			| 169 | 266 |              owner=user_admin,
 | 
	
	
		
			
			|  | @@ -174,9 +271,16 @@ class TestContent(StandardTest):
 | 
	
		
			
			| 174 | 271 |              revision_type=ActionDescription.CREATION
 | 
	
		
			
			| 175 | 272 |          )
 | 
	
		
			
			| 176 | 273 |  
 | 
	
		
			
			| 177 |  | -        eq_(1, self.session.query(ContentRevisionRO).filter(ContentRevisionRO.label == 'TEST_CONTENT_%s' % key).count())
 | 
	
		
			
			|  | 274 | +        eq_(
 | 
	
		
			
			|  | 275 | +            1,
 | 
	
		
			
			|  | 276 | +            self.session.query(ContentRevisionRO).filter(
 | 
	
		
			
			|  | 277 | +                ContentRevisionRO.label == 'TEST_CONTENT_%s' % key
 | 
	
		
			
			|  | 278 | +            ).count()
 | 
	
		
			
			|  | 279 | +        )
 | 
	
		
			
			| 178 | 280 |  
 | 
	
		
			
			| 179 |  | -        content = self.session.query(Content).filter(Content.id == created_content.id).one()
 | 
	
		
			
			|  | 281 | +        content = self.session.query(Content).filter(
 | 
	
		
			
			|  | 282 | +            Content.id == created_content.id
 | 
	
		
			
			|  | 283 | +        ).one()
 | 
	
		
			
			| 180 | 284 |          eq_('TEST_CONTENT_%s' % key, content.label)
 | 
	
		
			
			| 181 | 285 |          eq_('TEST_CONTENT_DESCRIPTION_%s' % key, content.description)
 | 
	
		
			
			| 182 | 286 |  
 |