Пример #1
0
    def test_snippet_list(self):
        url1 = ('https://api.bitbucket.org/2.0/snippets' + '?role=owner')
        example1 = data_from_file(self.test_dir,
                                  'example_snippets_page_1.json')
        httpretty.register_uri(httpretty.GET,
                               url1,
                               content_type='application/json',
                               body=example1,
                               status=200)
        snips = Snippet.find_snippets_for_role(SnippetRole.OWNER,
                                               client=self.client)
        snippet_list = []
        snippet_list.append(next(snips))
        snippet_list.append(next(snips))
        snippet_list.append(next(snips))

        url2 = ('https://' + 'staging.bitbucket.org/api' + '/2.0/snippets' +
                '?role=owner&page=2')
        example2 = data_from_file(self.test_dir,
                                  'example_snippets_page_2.json')
        httpretty.register_uri(httpretty.GET,
                               url2,
                               content_type='application/json',
                               body=example2,
                               status=200)
        snippet_list.append(next(snips))
        snippet_list.append(next(snips))
        assert 5 == len(snippet_list)
    def setup_class(cls):
        cls.test_dir, current_file = path.split(path.abspath(__file__))
        cls.client = Client(FakeAuth())

        example_commit = json.loads(data_from_file(cls.test_dir,
                                                   'Commit.json'))
        cls.commit = cls.client.convert_to_object(example_commit)
Пример #3
0
def main(args):
    if args.debug:
        import pdb
        pdb.set_trace()

    if args.from_file:
        goals, world, p, stage_info = data_from_file(args.from_file)
        world.traj_func = traj_from_file
    else:
        # objects
        radius = 5.0
        manip_obj = Circle(radius, Position(5.0, radius))
        finger0 = Circle(1.0, Position(-5.0, -5.0))
        finger1 = Circle(1.0, Position(15.0, -5.0))

        # initial contact information
        contact_state = OrderedDict([
            (finger0, Contact(f=(0.0, 0.0), ro=(-7., -7.), c=.5)),
            (finger1, Contact(f=(0.0, 0.0), ro=(7., -7.), c=.5))
        ])
        goals = [Position(5.0, 20.0)]

        world = World(manip_obj, [finger0, finger1], contact_state)

        stage_weights = [
            StageWeights(w_CI=0.1, w_physics=0.1, w_kinematics=0.0,
                         w_task=1.0),
            StageWeights(w_CI=10.**1,
                         w_physics=10.**0,
                         w_kinematics=0.,
                         w_task=10.**1)
        ]
        p = Params(world,
                   K=10,
                   delT=0.05,
                   delT_phase=0.5,
                   mass=1.0,
                   mu=0.9,
                   lamb=10**-3,
                   stage_weights=stage_weights)

    traj_data = None
    if args.from_file:
        traj_data = goals, world, p, stage_info

    start_stage = 0
    if args.start_stage:
        start_stage = args.start_stage

    stage_info = CIO(goals,
                     world,
                     p,
                     start_stage=start_stage,
                     traj_data=traj_data,
                     single=args.single)

    if args.save:
        save_run(args.save, goals, world, p, stage_info)
    def test_two_pages_of_items(self):
        url1 = (
            self.client.get_bitbucket_url() +
            '/2.0/snippets' +
            '?role=owner')
        example1 = data_from_file(
            self.test_dir,
            'example_snippets_page_1.json')
        httpretty.register_uri(
            httpretty.GET,
            url1,
            match_querystring=True,
            content_type='application/json',
            body=example1,
            status=200)
        snip_iter = self.client.remote_relationship(url1)

        snippet_list = list()
        snippet_list.append(next(snip_iter))
        snippet_list.append(next(snip_iter))
        snippet_list.append(next(snip_iter))

        url2 = (
            'https://' +
            'staging.bitbucket.org/api' +
            '/2.0/snippets' +
            '?role=owner&page=2')
        example2 = data_from_file(
            self.test_dir,
            'example_snippets_page_2.json')
        httpretty.register_uri(
            httpretty.GET,
            url2,
            match_querystring=True,
            content_type='application/json',
            body=example2,
            status=200)

        for snip in snip_iter:
            snippet_list.append(snip)

        s = "%s" % snippet_list[0]
        assert s.startswith('Snippet id:')
        assert 5 == len(snippet_list)
Пример #5
0
 def test_commit_comments(self):
     commit_hash = 'c021208234c65439f57b8244517a2b850b3ecf44'
     commit = self.load_example_commit()
     url = ('https://' + 'api.bitbucket.org' + '/2.0/repositories/' +
            'teamsinspace/teamsinspace.bitbucket.org' + '/commit/' +
            commit_hash + '/comments')
     example = data_from_file(self.test_dir, 'Comment_list.json')
     httpretty.register_uri(httpretty.GET,
                            url,
                            content_type='application/json',
                            body=example,
                            status=200)
     assert list(commit.comments())
     assert isinstance(next(commit.comments()), Comment)
Пример #6
0
    def test_commit_approval(self):
        commit_hash = 'c021208234c65439f57b8244517a2b850b3ecf44'
        commit = self.load_example_commit()
        url = ('https://' + 'api.bitbucket.org' + '/2.0/repositories/' +
               'teamsinspace/teamsinspace.bitbucket.org' + '/commit/' +
               commit_hash + '/approve')
        example = data_from_file(self.test_dir, 'example_approve_commit.json')
        httpretty.register_uri(httpretty.POST,
                               url,
                               content_type='application/json',
                               body=example,
                               status=200)
        assert commit.approve()

        httpretty.register_uri(httpretty.DELETE, url, status=204)
        assert commit.unapprove()
 def test_one_page_of_items(self):
     url = (
         'https://' +
         'api.bitbucket.org' +
         '/2.0/repositories')
     example = data_from_file(
         self.test_dir,
         'Repository_list.json')
     httpretty.register_uri(
         httpretty.GET,
         url,
         content_type='application/json',
         body=example,
         status=200)
     repo_list = list(self.client.remote_relationship(url))
     s = "%s" % repo_list[0]
     assert s.startswith('Repository full_name:')
     assert 2 == len(repo_list)
Пример #8
0
 def test_find_commit_by_revision(self):
     commit_hash = 'c021208234c65439f57b8244517a2b850b3ecf44'
     url = (self.client.get_bitbucket_url() + '/2.0/repositories/' +
            'teamsinspace/teamsinspace.bitbucket.org' + '/commit/' +
            commit_hash)
     example = data_from_file(self.test_dir, 'Commit.json')
     httpretty.register_uri(httpretty.GET,
                            url,
                            content_type='application/json',
                            body=example,
                            status=200)
     commit = Commit.find_commit_in_repository_by_revision(
         'teamsinspace',
         'teamsinspace.bitbucket.org',
         commit_hash,
         client=self.client)
     assert isinstance(commit, Commit)
     assert commit_hash == commit.hash
     assert 'Testing with some copied html' == commit.message
 def test_snippet_creator_and_owner_are_users(self):
     example = json.loads(data_from_file(self.test_dir, 'Snippet.json'))
     my_snip = self.client.convert_to_object(example)
     assert isinstance(my_snip, Snippet)
     assert isinstance(my_snip.owner, User)
     assert isinstance(my_snip.creator, User)
Пример #10
0
 def test_repository_owner_is_a_team(self):
     example = json.loads(data_from_file(self.test_dir, 'Repository.json'))
     my_repo = self.client.convert_to_object(example)
     assert isinstance(my_repo, Repository)
     assert isinstance(my_repo.owner, Team)
Пример #11
0
 def test_webhook_subject_is_a_repository(self):
     example = json.loads(data_from_file(self.test_dir, 'Hook.json'))
     my_hook = self.client.convert_to_object(example)
     assert isinstance(my_hook, Hook)
     assert isinstance(my_hook.subject, Repository)