예제 #1
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)
예제 #2
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)
예제 #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
     )
예제 #4
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)
예제 #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)
예제 #6
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)
예제 #7
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)
예제 #8
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)
예제 #9
0
 def tearDown(self):
     """
     Drop each collection after each test.
     """
     User.drop_collection()
     Organisation.drop_collection()
     Team.drop_collection()
     Project.drop_collection()
     Task.drop_collection()
     TaskList.drop_collection()
예제 #10
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)
예제 #11
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)
예제 #12
0
 def test_0080_projecthandler_2(self):
     """
     Test project page which does not exist
     """
     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/an-invalid-slug' % organisation.slug,
         method="GET",
         follow_redirects=False,
         headers= {'Cookie' : self.get_login_cookie()}
     )
     self.assertEqual(response.code, 404)
예제 #13
0
    def test_0010_projectshandler_get(self):
        """
        Test ProjectsHandler 'get' method
        """
        organisation = Organisation(
            name="open labs", slug=slugify("open labs")
        )
        organisation.save()
        team = Team(
            name="Developers", organisation=organisation,
            members=[self.user]
        )
        team.save()

        # User not logged in
        response = self.fetch(
            '/%s/projects' % organisation.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/projects/' % organisation.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-url/projects/',
            method="GET",
            follow_redirects=False,
            headers ={'Cookie' : cookies}
        )
        self.assertEqual(response.code, 404)
예제 #14
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)
예제 #15
0
 def test_0020_projectshandler_post_1(self):
     """
     Test post with logged in and project slug does not exists
     """
     organisation = Organisation(
         name="open labs", slug=slugify("open labs")
     )
     organisation.save()
     team = Team(
         name="Developers", organisation=organisation,
         members=[self.user]
     )
     team.save()
     cookies = self.get_login_cookie()
     response = self.fetch(
         '/%s/projects/' % organisation.slug,
         method="POST",
         follow_redirects=False,
         headers ={'Cookie' : cookies},
         body=urlencode({'name':'Titan', 'slug':'titan', 'team': str(team.id)}),
     )
     self.assertEqual(response.code, 302)
예제 #16
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)
예제 #17
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)