Exemplo n.º 1
0
    def test_cant_have_same_member_twice(self):
        u1 = UserFactory.create()
        u2 = UserFactory.create()

        try:
            Team.create(name="test-team-same-member-twice", owner=u1, members=[u2, u2])
        except ValueError:
            ex = sys.exc_info()[1]
            expect(ex).to_have_an_error_message_of("Can't have the same user twice in the members collection.")
            return
        assert False, "Should not have gotten this far"
Exemplo n.º 2
0
    def test_cant_have_owner_in_members(self):
        u1 = UserFactory.create()

        try:
            Team.create(name="test-team-owner-in-members", owner=u1, members=[u1])
        except ValueError:
            ex = sys.exc_info()[1]
            expect(ex).to_have_an_error_message_of("Can't have a team owner in the members collection.")
            return

        assert False, "Should not have gotten this far"
Exemplo n.º 3
0
    def test_cant_have_owner_in_members(self):
        u1 = UserFactory.create()

        try:
            Team.create(name="test-team-owner-in-members",
                        owner=u1,
                        members=[u1])
        except ValueError:
            ex = sys.exc_info()[1]
            expect(ex).to_have_an_error_message_of(
                "Can't have a team owner in the members collection.")
            return

        assert False, "Should not have gotten this far"
Exemplo n.º 4
0
    def test_cant_have_same_member_twice(self):
        u1 = UserFactory.create()
        u2 = UserFactory.create()

        try:
            Team.create(name="test-team-same-member-twice",
                        owner=u1,
                        members=[u2, u2])
        except ValueError:
            ex = sys.exc_info()[1]
            expect(ex).to_have_an_error_message_of(
                "Can't have the same user twice in the members collection.")
            return
        assert False, "Should not have gotten this far"
Exemplo n.º 5
0
    def test_can_create_empty_team(self):
        team = TeamFactory.create()

        retrieved = Team.objects(id=team.id)
        expect(retrieved.count()).to_equal(1)
        expect(retrieved.first().name).to_equal(team.name)

        expect(retrieved.first().owner.id).to_equal(team.owner.id)
Exemplo n.º 6
0
    def test_can_create_empty_team(self):
        team = TeamFactory.create()

        retrieved = Team.objects(id=team.id)
        expect(retrieved.count()).to_equal(1)
        expect(retrieved.first().name).to_equal(team.name)

        expect(retrieved.first().owner.id).to_equal(team.owner.id)
Exemplo n.º 7
0
    def test_can_create_team_with_members(self):
        team = TeamFactory.create()
        TeamFactory.add_members(team, 1)

        retrieved = Team.objects(id=team.id)
        expect(retrieved.count()).to_equal(1)
        expect(retrieved.first().name).to_equal(team.name)
        expect(retrieved.first().members).to_length(1)
        expect(retrieved.first().members[0].email).to_equal(team.members[0].email)
Exemplo n.º 8
0
    def test_can_create_team_with_members(self):
        team = TeamFactory.create()
        TeamFactory.add_members(team, 1)

        retrieved = Team.objects(id=team.id)
        expect(retrieved.count()).to_equal(1)
        expect(retrieved.first().name).to_equal(team.name)
        expect(retrieved.first().members).to_length(1)
        expect(retrieved.first().members[0].email).to_equal(
            team.members[0].email)
Exemplo n.º 9
0
    def get(self, name):
        user = {'user': {'email': self.current_user.email, 'teams': []}}
        teams = Team.objects(Q(members__contains=self.current_user) | Q(owner=self.current_user))

        for team in teams:
            role = 'owner' if team.owner == self.current_user else 'member'
            user['user']['teams'].append({'name': team.name, 'role': role})

        self.content_type = 'application/json'
        self.write(dumps(user))
        self.finish()
Exemplo n.º 10
0
    def post(self, team_name):
        name = self.get_argument("name").strip()
        team = Team.create(name, owner=self.current_user)

        if team is None:
            self.set_status(409)
            self.finish()
            return

        self.set_status(200)
        self.write("OK")
        self.finish()
Exemplo n.º 11
0
    def get(self, name):
        user = {'user': {'email': self.current_user.email, 'teams': []}}
        teams = Team.objects(
            Q(members__contains=self.current_user)
            | Q(owner=self.current_user))

        for team in teams:
            role = 'owner' if team.owner == self.current_user else 'member'
            user['user']['teams'].append({'name': team.name, 'role': role})

        self.content_type = 'application/json'
        self.write(dumps(user))
        self.finish()
Exemplo n.º 12
0
 def get(self, team_name, project_name, module, class_name, test_name):
     self.set_status(200)
     try:
         team = Team.objects(name=team_name).first()
         results = LoadTest.get_same_results_for_all_load_tests_from_project(team, project_name, module, class_name, test_name)
         response = []
         for result in results:
             response.append(result.to_dict())
         self.write(dumps(response))
     except DoesNotExist:
         self.set_status(404)
     finally:
         self.finish()
Exemplo n.º 13
0
 def get(self, team_name, project_name, module, class_name, test_name):
     self.set_status(200)
     try:
         team = Team.objects(name=team_name).first()
         results = LoadTest.get_same_results_for_all_load_tests_from_project(
             team, project_name, module, class_name, test_name)
         response = []
         for result in results:
             response.append(result.to_dict())
         self.write(dumps(response))
     except DoesNotExist:
         self.set_status(404)
     finally:
         self.finish()
Exemplo n.º 14
0
 def test_cant_have_null_owner(self):
     try:
         Team.create(name="null-owner-5", owner=None)
     except ValidationError:
         return
     assert False, "Should not have gotten this far"
Exemplo n.º 15
0
 def test_cant_create_team_with_same_name(self):
     team = TeamFactory.create()
     team = Team.create(name=team.name, owner=team.owner)
     expect(team).to_be_null()
Exemplo n.º 16
0
 def test_cant_have_null_owner(self):
     try:
         Team.create(name="null-owner-5", owner=None)
     except ValidationError:
         return
     assert False, "Should not have gotten this far"
Exemplo n.º 17
0
 def test_cant_create_team_with_same_name(self):
     team = TeamFactory.create()
     team = Team.create(name=team.name, owner=team.owner)
     expect(team).to_be_null()