Esempio n. 1
0
 def test_0020_tasklists_post1(self):
     """
     Test post with logged in and invalid organisation slug
     """
     organisation = Organisation(
         name="open labs", slug=slugify("open labs")
     )
     organisation.save()
     team = Team(
         name="Developers", organisation=organisation,
         members=[self.user]
     )
     team.save()
     acl = AccessControlList(team=team, role="admin")
     project = Project(
         name="titan", organisation=organisation, acl=[acl],
         slug=slugify('titan project')
     )
     project.save()
     response = self.fetch(
         '/an-invalid-organisation/%s/tasklists' % project.slug,
         method="POST",
         follow_redirects=False,
         body=urlencode({'name': "Version 0.1"}),
         headers={'Cookie': self.get_login_cookie()}
     )
     self.assertEqual(response.code, 404)
Esempio n. 2
0
 def test_0060_slugverification_2(self):
     """
     Verify project slug which already exists under current organisations
     """
     organisation = Organisation(
         name="open labs", slug=slugify("open labs")
     )
     organisation.save()
     team = Team(
         name="Developers", organisation=organisation,
         members=[self.user]
     )
     team.save()
     acl = AccessControlList(team=team, role="admin")
     project = Project(
         name="titan", organisation=organisation, acl=[acl],
         slug=slugify('titan project')
     )
     project.save()
     response = self.fetch(
         '/%s/+slug-check' % organisation.slug,
         method="POST",
         follow_redirects=False,
         body=urlencode({
             'project_slug':slugify('titan project')
         }),
         headers= {'Cookie' : self.get_login_cookie()}
     )
     response = json.loads(response.body)
     self.assertEqual(response, False)
Esempio n. 3
0
 def test_0040_projects_post_2(self):
     """
     post with logged in and Project slug already exist
     """
     organisation = Organisation(
         name="open labs", slug=slugify("open labs")
     )
     organisation.save()
     team = Team(
         name="Developers", organisation=organisation,
         members=[self.user]
     )
     team.save()
     acl = AccessControlList(team=team, role="admin")
     project = Project(
         name="titan", organisation=organisation, acl=[acl],
         slug=slugify('titan project')
     )
     project.save()
     response = self.fetch(
         '/%s/projects/' % organisation.slug,
         method="POST",
         follow_redirects=False,
         body=urlencode({'name':'Titan', 'slug':slugify('titan project')}),
         headers= {'Cookie' : self.get_login_cookie()}
     )
     self.assertEqual(response.code, 200)
     self.assertEqual(
         response.body.count(
             u'A project with the same short code already exists'
         ), 1
     )
Esempio n. 4
0
    def test_0090_task_handler_get_1(self):
        """
        Try to render a particular task without being logged in
        """
        organisation = Organisation(
            name="open labs", slug=slugify("open labs")
        )
        organisation.save()
        team = Team(
            name="Developers", organisation=organisation,
            members=[self.user]
        )
        team.save()
        acl = AccessControlList(team=team, role="admin")
        project = Project(
            name="titan", organisation=organisation, acl=[acl],
            slug=slugify('titan project')
        )
        project.save()
        tasklist = TaskList(name="version 01", project=project)
        tasklist.save()

        response = self.fetch(
            '/%s/%s/%s/tasks/new' % (
                organisation.slug, project.slug, tasklist.sequence
            ),
            method="GET",
            follow_redirects=False,
        )
        self.assertEqual(response.code, 302)
Esempio n. 5
0
    def test_0160_task_handler_post_5(self):
        """
        Test TaskHandler 'post' method invalid form fields
        """
	organisation = Organisation(
            name="open labs", slug=slugify("open labs")
        )
	organisation.save()
        team = Team(
            name="Developers", organisation=organisation,
            members=[self.user]
        )
        team.save()
        acl = AccessControlList(team=team, role="admin")
        project = Project(
            name="titan", organisation=organisation, acl=[acl],
            slug=slugify('titan project')
        )
        project.save()
        tasklist = TaskList(name="version 01", project=project)
        tasklist.save()

        response = self.fetch(
            '/%s/%s/%s/tasks/new' % (
                organisation.slug, project.slug, tasklist.sequence
            ),
            method="POST",
            follow_redirects=False,
            body=urlencode({
                    "status": "new",
                    "assigned_to": str(self.user.id),
            }),
            headers={'Cookie': self.get_login_cookie()},
        )
        self.assertEqual(response.code, 200)
Esempio n. 6
0
    def test_0100_task_handler_get_2(self):
        """
        Try to render a particular task without providing Task Id
        If 'task id' is not provided, then it will return create task form.
        """
        organisation = Organisation(
            name="open labs", slug=slugify("open labs")
        )
        organisation.save()
        team = Team(
            name="Developers", organisation=organisation,
            members=[self.user]
        )
        team.save()
        acl = AccessControlList(team=team, role="admin")
        project = Project(
            name="titan", organisation=organisation, acl=[acl],
            slug=slugify('titan project')
        )
        project.save()
        tasklist = TaskList(name="version 01", project=project)
        tasklist.save()

        response = self.fetch(
            '/%s/%s/%s/tasks/new' % (
                organisation.slug, project.slug, tasklist.sequence
            ),
            method="GET",
            follow_redirects=False,
            headers={'Cookie': self.get_login_cookie()}
        )
        self.assertEqual(response.code, 200)
Esempio n. 7
0
    def test_0150_user_organisation(self):
        """
        Test the organisation property of user
        """
        user_2 = User(
            name="test-user",
            email="*****@*****.**",
        )
        user_2.set_password("openlabs")
        user_2.save()

        # Create organisations
        organisation_1 = Organisation(
            name="open labs", slug=slugify("open labs")
        )
        organisation_1.save()
        organisation_2 = Organisation(
            name="new organisation", slug=slugify("new organisation")
        )
        organisation_2.save()

        # Create teams
        team_developers = Team(
            name="Developers", organisation=organisation_1,
            members=[self.user, user_2]
        )
        team_developers.save()
        team_participants = Team(
            name="Paricipants", organisation=organisation_2,
            members=[self.user]
        )
        team_participants.save()
        self.assertEqual(len(self.user.organisations), 2)
        self.assertEqual(len(user_2.organisations), 1)
Esempio n. 8
0
 def test_0080_tasklist_get_1(self):
     """
     Test Task List with wrong organisation slug
     """
     organisation = Organisation(
         name="open labs", slug=slugify("open labs")
     )
     organisation.save()
     team = Team(
         name="Developers", organisation=organisation,
         members=[self.user]
     )
     team.save()
     acl = AccessControlList(team=team, role="admin")
     project = Project(
         name="titan", organisation=organisation, acl=[acl],
         slug=slugify('titan project')
     )
     project.save()
     tasklist = TaskList(name="version 01", project=project)
     tasklist.save()
     response = self.fetch(
         '/wrong-organisation/%s/%s' % (project.slug, tasklist.sequence),
         method="GET",
         follow_redirects=False,
         headers={'Cookie': self.get_login_cookie()}
     )
     self.assertEqual(response.code, 404)
Esempio n. 9
0
 def test_0070_projecthandler_1(self):
     """
     Test project page which already exist
     """
     organisation = Organisation(
         name="open labs", slug=slugify("open labs")
     )
     organisation.save()
     team = Team(
         name="Developers", organisation=organisation,
         members=[self.user]
     )
     team.save()
     acl = AccessControlList(team=team, role="admin")
     project = Project(
         name="titan", organisation=organisation, acl=[acl],
         slug=slugify('titan project')
     )
     project.save()
     response = self.fetch(
         '/%s/%s' % (organisation.slug, project.slug),
         method="GET",
         follow_redirects=False,
         headers= {'Cookie' : self.get_login_cookie()}
     )
     self.assertEqual(response.code, 200)
Esempio n. 10
0
 def test_0020_unique_slug(self):
     """
     'slug' must be a unique value in Organisation.
     """
     organisation = Organisation(
         name="open labs", slug=slugify("open labs")
     )
     organisation.save()
     organisation = Organisation(name="open lab", slug=slugify("open labs"))
     self.assertRaises(OperationError, organisation.save)
Esempio n. 11
0
def create_project(user, name, slug, organisation):
    """
    Create a new project and return the object.

    :param user: User collection object
    :param name: The name of the project
    :param slug: The slug used for the project.
    :param organisation: The organisation the project belongs to.
    :return: Created project as Document
    """
    acl_admin = AccessControlList(
        team=Team(
            name="Admin", organisation=organisation, members=[user]
        ).save(), role="admin"
    )
    acl_participant = AccessControlList(
        team=Team(
            name="Participant", organisation=organisation, members=[user]
        ).save(), role="participant"
    )
    project = Project(
        name=name, organisation=organisation, acl=[acl_admin, acl_participant],
        slug=slugify(slug)
    )
    return project
Esempio n. 12
0
    def test_0010_tasklistshandler_get(self):
        """
        Test tasklists handler get method
        """
        organisation = Organisation(
            name="open labs", slug=slugify("open labs")
        )
        organisation.save()
        team = Team(
            name="Developers", organisation=organisation,
            members=[self.user]
        )
        team.save()
        acl = AccessControlList(team=team, role="admin")
        project = Project(
            name="titan", organisation=organisation, acl=[acl],
            slug=slugify('titan project')
        )
        project.save()

        # User not logged in
        response = self.fetch(
            '/%s/%s/tasklists' % (organisation.slug, project.slug),
            method="GET",
            follow_redirects=False
        )
        self.assertEqual(response.code, 302)

        # User logged in and an existing organisation
        cookies = self.get_login_cookie()
        response = self.fetch(
            '/%s/%s/tasklists' % (organisation.slug, project.slug),
            method="GET",
            follow_redirects=False,
            headers={'Cookie': cookies}
        )
        self.assertEqual(response.code, 200)

        # User logged in and Organisation not existing
        cookies = self.get_login_cookie()
        response = self.fetch(
            '/an-invalid-organisation/%s/tasklists' % project.slug,
            method="GET",
            follow_redirects=False,
            headers={'Cookie': cookies}
        )
        self.assertEqual(response.code, 404)
Esempio n. 13
0
    def test_0100_project_fields(self):
        """
        Test the fields required for the Project collection.
        """
        organisation = Organisation(
            name="open labs", slug=slugify("open labs")
        )
        organisation.save()
        # Create AccessControlList instances
        acl_developers = AccessControlList(
            team=Team(
                name="Admins", organisation=organisation, members=[self.user]
            ).save(), role="admin"
        )
        acl_participants = AccessControlList(
            team=Team(
                name="Viewers", organisation=organisation, members=[self.user]
            ).save(), role="participant"
        )

        # 'organisation' is a required field
        project = Project(
            name="titan", slug=slugify("titan project"), acl=[acl_developers,
            acl_participants]
        )
        self.assertRaises(ValidationError, project.save)

        # 'acl' is a a required field
        project = Project(name="New Titan", slug=slugify( "titan projects"),
            organisation=organisation
        )
        self.assertRaises(ValidationError, project.save)

        # 'name' is a required field
        project = Project(slug=slugify("titan project"),
            organisation=organisation, acl=[acl_developers, acl_participants]
        )
        self.assertRaises(ValidationError, project.save)

        # 'slug' is a required field
        project = Project(
            name="titan", organisation=organisation,
            acl=[acl_developers, acl_participants]
        )
        self.assertRaises(ValidationError, project.save)
Esempio n. 14
0
 def test_0090_same_slug(self):
     """
     We can use same project "slug" under different organisations
     """
     organisation = Organisation(
         name="open labs", slug=slugify("open labs")
     )
     organisation.save()
     project = create_project(
         self.user, "New Titan", "titan projects", organisation
     )
     project.save()
     new_organisation = Organisation(name="Infy", slug=slugify("infy labs"))
     new_organisation.save()
     project = create_project(
         self.user, "New Titan", "titan projects", new_organisation
     )
     project.save()
Esempio n. 15
0
 def test_0010_create_organisation(self):
     """
     Create an Organisation
     """
     organisation = Organisation(
         name="open labs", slug=slugify("open labs")
     )
     organisation.save()
     self.assertEqual(Organisation.objects().count(), 1)
Esempio n. 16
0
 def test_0080_create_organisation_2(self):
     """
     Test for creating an organisation which already existing
     """
     organisation = Organisation(
         name="openlabs", slug=slugify("new organisation")
     )
     organisation.save()
     cookies = self.get_login_cookie()
     slug = slugify('new organisation')
     response = self.fetch(
         '/my-organisations/', method="POST", follow_redirects=False,
         headers={
             'Cookie': cookies
         },
         body=urlencode({
             'name': 'organisation', 'slug': slug
         })
     )
     self.assertEqual(response.code, 200)
Esempio n. 17
0
    def test_0030_org_required_fields(self):
        """
        Test the required fields of Organisation collection.
        """
        # 'slug' is a required field
        organisation = Organisation(name="openlabs")
        self.assertRaises(ValidationError, organisation.save)

        # 'name' is a required field
        organisation = Organisation(slug=slugify("open labs"))
        self.assertRaises(ValidationError, organisation.save)
Esempio n. 18
0
 def test_0060_slug_verification_2(self):
     """
     verify slug which already exists
     """
     organisation = Organisation(
         name="openlabs", slug=slugify("new organisation")
     )
     organisation.save()
     slug = slugify("new organisation")
     response = self.fetch(
         '/+slug-check', method="POST",
         follow_redirects=False,
         headers={
             'Cookie': self.get_login_cookie()
         },
         body=urlencode({
             "slug": slug
         })
     )
     response = json.loads(response.body)
     self.assertEqual(response, False)
Esempio n. 19
0
 def test_0040_create_team(self):
     """
     Create a Team
     """
     organisation = Organisation(
         name="open labs", slug=slugify("open labs")
     )
     organisation.save()
     team = Team(
         name="Developers", organisation=organisation, members=[self.user]
     )
     team.save()
     self.assertEqual(Team.objects().count(), 1)
Esempio n. 20
0
 def test_0070_create_project(self):
     """
     Create project under organisation
     """
     organisation = Organisation(
         name="open labs", slug=slugify("open labs")
     )
     organisation.save()
     project = create_project(
         self.user, "Titan", "titan project", organisation
     )
     project.save()
     self.assertEqual(Project.objects().count(), 1)
Esempio n. 21
0
 def test_0110_create_tasklist(self):
     """
     Create task list under project
     """
     organisation = Organisation(
         name="open labs", slug=slugify("open labs")
     )
     organisation.save()
     project = create_project(
         self.user, 'Titan', 'titan project', organisation
     )
     project.save()
     task_list = TaskList(name="Version 0.1", project=project)
     task_list.save()
     self.assertEqual(TaskList.objects().count(), 1)
Esempio n. 22
0
 def test_0050_slugverification_1(self):
     """
     Verify project slug which does not exists under current organisations
     """
     organisation = Organisation(
         name="open labs", slug=slugify("open labs")
     )
     organisation.save()
     team = Team(
         name="Developers", organisation=organisation,
         members=[self.user]
     )
     team.save()
     response = self.fetch(
         '/%s/+slug-check' % organisation.slug,
         method="POST",
         follow_redirects=False,
         body=urlencode({
             'project_slug':slugify('titan project')
         }),
         headers= {'Cookie' : self.get_login_cookie()}
     )
     response = json.loads(response.body)
     self.assertEqual(response, True)
Esempio n. 23
0
 def test_0090_create_organisation_3(self):
     """
     Test for creating an organisation with empty form fields
     """
     slug = slugify('new organisation')
     cookies = self.get_login_cookie()
     response = self.fetch(
         '/my-organisations/', method="POST", follow_redirects=False,
         headers={
             'Cookie': cookies
         },
         body=urlencode({
             'name': 'organisation',
         })
     )
     self.assertEqual(response.code, 200)
Esempio n. 24
0
 def test_0070_create_organisation_1(self):
     """
     Test for creating an organisation which is does not exists
     """
     slug = slugify('new organisation')
     cookies = self.get_login_cookie()
     response = self.fetch(
         '/my-organisations/', method="POST", follow_redirects=False,
         headers={
             'Cookie': cookies
         },
         body=urlencode({
             'name': 'organisation', 'slug': slug
         })
     )
     self.assertEqual(response.code, 302)
Esempio n. 25
0
 def test_0080_unique_slug(self):
     """
     project "slug" must be unique under the current organisation
     """
     organisation = Organisation(
         name="open labs", slug=slugify("open labs")
     )
     organisation.save()
     project = create_project(
         self.user, "New Titan", "titan projects", organisation
     )
     project.save()
     project = create_project(
         self.user, "New Titan", "titan projects", organisation
     )
     self.assertRaises(ValidationError, project.save)
Esempio n. 26
0
    def test_0050_team_required_fields(self):
        """
        Test the required fields of Team collection
        """
        organisation = Organisation(
            name="open labs", slug=slugify("open labs")
        )
        organisation.save()

        # "organisation" is a required field
        team = Team(name="Developers", members=[self.user])
        self.assertRaises(ValidationError, team.save)

        # "name" is a required field
        team = Team(organisation=organisation, members=[self.user])
        self.assertRaises(ValidationError, team.save)
Esempio n. 27
0
 def test_0050_slug_verification_1(self):
     """
     Verify slug which does not exists
     """
     slug = slugify("a new organisation")
     response = self.fetch(
         '/+slug-check', method="POST",
         follow_redirects=False,
         headers={
             'Cookie': self.get_login_cookie()
         },
         body=urlencode({
             "slug": slug
         })
     )
     response = json.loads(response.body)
     self.assertEqual(response, True)
Esempio n. 28
0
 def test_0060_organisation_teams(self):
     """
     Testing the number of teams under the organisation
     """
     organisation = Organisation(
         name="open labs", slug=slugify("open labs")
     )
     organisation.save()
     team_developers = Team(
         name="Developers", organisation=organisation, members=[self.user]
     )
     team_developers.save()
     self.assertEqual(organisation.teams.count(), 1)
     team_participants = Team(
         name="participants", organisation=organisation, members=[self.user]
     )
     team_participants.save()
     self.assertEqual(organisation.teams.count(), 2)
Esempio n. 29
0
    def test_0140_task_required_fields(self):
        """
        Test the fields required for the Task collection.
        """
        organisation = Organisation(
            name="open labs", slug=slugify("open labs")
        )
        organisation.save()
        project = create_project(
            self.user, 'Titan', 'titan project', organisation
        )
        project.save()
        task_list = TaskList(name="Version 0.1", project=project)
        task_list.save()
        follow_up = FollowUp(message="Any message", from_status="resolved")

        #"title"  is a required field        
        task = Task(
            status ="resolved", assigned_to=self.user, watchers=[self.user],
            task_list=task_list, follow_ups=[follow_up]
        )
        self.assertRaises(ValidationError, task.save)

        # "Status" is a required Field
        task = Task(
            title="Create model design", assigned_to=self.user,
            watchers=[self.user], task_list=task_list, follow_ups=[follow_up]
        )
        self.assertRaises(ValidationError, task.save)

        # "assigned_to" is a required field
        task = Task(
            title="Create model desi", status ="resolved",
            watchers=[self.user], task_list=task_list, follow_ups=[follow_up]
        )
        self.assertRaises(ValidationError, task.save)

        # "task_list" is a required field
        task = Task(
            title="Create model design", status ="resolved",
            assigned_to=self.user,
        )
        self.assertRaises(ValidationError, task.save)
Esempio n. 30
0
    def test_0120_tasklist_fields(self):
        """
        Test the required fields of TaskList
        """
        organisation = Organisation(
            name="open labs", slug=slugify("open labs")
        )
        organisation.save()
        project = create_project(
            self.user, 'Titan', 'titan project', organisation
        )
        project.save()

        # 'project' is a required field
        task_list = TaskList(name="Version 0.1")
        self.assertRaises(ValidationError, task_list.save)

        # 'name' is a required field
        task_list = TaskList(project=project)
        self.assertRaises(ValidationError, task_list.save)