Exemplo n.º 1
0
    def test_paged_diffs_with_detect_copies(self):
        # setup
        h.set_context('test', 'src-weird', neighborhood='Projects')
        repo_dir = pkg_resources.resource_filename(
            'forgegit', 'tests/data')
        repo = GM.Repository(
            name='weird-chars.git',
            fs_path=repo_dir,
            url_path='/src-weird/',
            tool='git',
            status='creating')
        repo.refresh()
        ThreadLocalORMSession.flush_all()
        ThreadLocalORMSession.close_all()

        diffs = repo.paged_diffs('346c52c1dddc729e2c2711f809336401f0ff925e')  # Test copy
        expected = {
            'added': [],
            'removed': [],
            'copied': [{'new': u'README.copy', 'old': u'README', 'ratio': 1.0}],
            'renamed': [],
            'changed': [u'README'],
            'total': 2,
        }
        assert_equals(diffs, expected)
        diffs = repo.paged_diffs('3cb2bbcd7997f89060a14fe8b1a363f01883087f')  # Test rename
        expected = {
            'added': [],
            'removed': [],
            'copied': [],
            'renamed': [{'new': u'README', 'old': u'README-copy.md', 'ratio': 1.0}],
            'changed': [],
            'total': 1,
        }
        assert_equals(diffs, expected)
Exemplo n.º 2
0
def assert_value(ctx, path, value, wrapper=None):
    if 'data_impl' not in ctx.zato.response:
        raise ValueError('Assertion called but no format set')

    value = wrapper(value) if wrapper else value
    actual = get_pointer(ctx.zato.response.data_impl, path)
    assert_equals(value, actual)
    return True
Exemplo n.º 3
0
    def test_webhook_payload(self):
        user = M.User.upsert('cory')
        email = user.claim_address('*****@*****.**')
        email.confirmed = True
        session(email).flush(email)
        user = M.User.upsert('rick')
        email = user.claim_address('*****@*****.**')
        email.confirmed = True
        session(email).flush(email)

        sender = RepoPushWebhookSender()
        cids = list(self.repo.all_commit_ids())[:2]
        payload = sender.get_payload(commit_ids=cids, ref='refs/heads/zz')
        expected_payload = {
            'size': 2,
            'ref': u'refs/heads/zz',
            'after': u'5c47243c8e424136fd5cdd18cd94d34c66d1955c',
            'before': u'df30427c488aeab84b2352bdf88a3b19223f9d7a',
            'commits': [{
                'id': u'5c47243c8e424136fd5cdd18cd94d34c66d1955c',
                'url': u'http://localhost/p/test/src-git/ci/5c47243c8e424136fd5cdd18cd94d34c66d1955c/',
                'timestamp': datetime.datetime(2013, 3, 28, 18, 54, 16),
                'message': u'Not repo root',
                'author': {'name': u'Cory Johns',
                           'email': u'*****@*****.**',
                           'username': '******'},
                'committer': {'name': u'Cory Johns',
                              'email': u'*****@*****.**',
                              'username': '******'},
                'added': [u'bad'],
                'removed': [],
                'modified': [],
                'copied': [],
                'renamed': [],
            }, {
                'id': u'1e146e67985dcd71c74de79613719bef7bddca4a',
                'url': u'http://localhost/p/test/src-git/ci/1e146e67985dcd71c74de79613719bef7bddca4a/',
                'timestamp': datetime.datetime(2010, 10, 7, 18, 44, 11),
                'message': u'Change README',
                'author': {'name': u'Rick Copeland',
                           'email': u'*****@*****.**',
                           'username': '******'},
                'committer': {'name': u'Rick Copeland',
                              'email': u'*****@*****.**',
                              'username': '******'},
                'added': [],
                'removed': [],
                'modified': [u'README'],
                'copied': [],
                'renamed': [],
            }],
            'repository': {
                'name': u'Git',
                'full_name': u'/p/test/src-git/',
                'url': u'http://localhost/p/test/src-git/',
            },
        }
        assert_equals(payload, expected_payload)
Exemplo n.º 4
0
def test_assert_equal_simple_types():
    try:
        tools.assert_equals('a', 7)
    except:
        e = sys.exc_info()[1]
        assert_equal(type(e), AssertionError)
        assert_equal(str(e), dedent('''\
            'a' != 7'''))
    else:
        raise AssertionError("Should've raised an AssertionError")
Exemplo n.º 5
0
def test_assert_equal_simple():
    try:
        tools.assert_equals(True, False)
    except:
        e = sys.exc_info()[1]
        assert_equal(type(e), AssertionError)
        assert_equal(str(e), dedent('''\
            True != False'''))
    else:
        raise AssertionError("Should've raised an AssertionError")
Exemplo n.º 6
0
def test_assert_equal_msg():
    try:
        tools.assert_equals(3, 4, "whoops")
    except:
        e = sys.exc_info()[1]
        assert_equal(type(e), AssertionError,
                     "Raised exception should be AssertionError")
        assert_equal(str(e), "whoops")
    else:
        raise AssertionError("Should've raised an AssertionError")
Exemplo n.º 7
0
def diff_dict(left, right):
    for k in left.keys():
        left_value = left.get(k)
        right_value = right.get(k)
        try:
            diff_dict(dict(left_value), dict(right_value))
            assert_equals(dict(left_value), dict(right_value))
        except AssertionError, e:
            raise e
        except:
Exemplo n.º 8
0
 def test_merge_request_commits_tmp_dir(self):
     """
     repo.merge_request_commits should return the same result with and
     without scm.merge_list.git.use_tmp_dir option enabled
     """
     mr = self.merge_request
     res_without_tmp = self.repo.merge_request_commits(mr)
     opt = {'scm.merge_list.git.use_tmp_dir': True}
     with h.push_config(tg.config, **opt):
         res_with_tmp = self.repo.merge_request_commits(mr)
     assert_equals(res_without_tmp, res_with_tmp)
Exemplo n.º 9
0
def _then_json_pointer_contains(ctx, path, expected):
    actual_list = get_pointer(ctx.zato.response.data_impl, path)

    for item in actual_list:
        try:
            assert_equals(item, expected)
        except AssertionError:
            pass
        else:
            return True
    else:
        raise AssertionError('Expected data `{}` not in `{}`'.format(expected, actual_list))
Exemplo n.º 10
0
 def test_webhook_payload(self):
     sender = RepoPushWebhookSender()
     cids = list(self.repo.all_commit_ids())[:2]
     payload = sender.get_payload(commit_ids=cids)
     expected_payload = {
         'size': 2,
         'after': 'r6',
         'before': 'r4',
         'commits': [{
             'id': u'r6',
             'url': u'http://localhost/p/test/src/6/',
             'timestamp': datetime(2013, 11, 8, 13, 38, 11, 152000),
             'message': u'',
             'author': {'name': u'coldmind',
                        'email': u'',
                        'username': u''},
             'committer': {'name': u'coldmind',
                           'email': u'',
                           'username': u''},
             'added': [u'/ЗРЯЧИЙ_ТА_ПОБАЧИТЬ'],
             'removed': [],
             'modified': [],
             'copied': [],
             'renamed': [],
         }, {
             'id': u'r5',
             'url': u'http://localhost/p/test/src/5/',
             'timestamp': datetime(2010, 11, 18, 20, 14, 21, 515000),
             'message': u'Copied a => b',
             'author': {'name': u'rick446',
                        'email': u'',
                        'username': u''},
             'committer': {'name': u'rick446',
                           'email': u'',
                           'username': u''},
             'added': [],
             'removed': [],
             'modified': [],
             'copied': [
                 {'new': u'/b', 'old': u'/a', 'ratio': 1},
             ],
             'renamed': [],
         }],
         'repository': {
             'name': u'SVN',
             'full_name': u'/p/test/src/',
             'url': u'http://localhost/p/test/src/',
         },
     }
     assert_equals(payload, expected_payload)
Exemplo n.º 11
0
def event_test(agent, name, pre_func=None, post_func=None):
    req = json_data(name)
    resp_valid = json_data(name + '_resp')

    if pre_func is not None:
        pre_func(req)

    resp = agent.execute(req)
    if post_func is not None:
        post_func(req, resp)

    del resp["id"]
    del resp["time"]

    _diff_dict(JsonObject.unwrap(resp), JsonObject.unwrap(resp_valid))
    assert_equals(JsonObject.unwrap(resp), JsonObject.unwrap(resp_valid))

    return req, resp
Exemplo n.º 12
0
 def test_merge_request_commits(self):
     res = self.repo.merge_request_commits(self.merge_request)
     expected = [
         {'authored': {
             'date': datetime.datetime(2013, 3, 28, 18, 54, 16),
             'email': u'*****@*****.**',
             'name': u'Cory Johns'},
          'committed': {
              'date': datetime.datetime(2013, 3, 28, 18, 54, 16),
              'email': u'*****@*****.**',
              'name': u'Cory Johns'},
          'id': '5c47243c8e424136fd5cdd18cd94d34c66d1955c',
          'message': u'Not repo root\n',
          'parents': ['1e146e67985dcd71c74de79613719bef7bddca4a'],
          'refs': ['zz'],
          'rename_details': {},
          'size': None}]
     assert_equals(res, expected)
Exemplo n.º 13
0
def test_assert_equal_false():
    try:
        tools.assert_equals([3,4], [5,6])
    except:
        e = sys.exc_info()[1]
        assert_equal(type(e), AssertionError)
        assert_equal(str(e), dedent('''\
            
            --- a
            +++ b
            [
            @@ -0,1 +0,1 @@
            -3,
            -4,
            +5,
            +6,
            ]'''))
    else:
        raise AssertionError("Should've raised an AssertionError")
Exemplo n.º 14
0
    def test_paged_diffs_with_detect_copies(self):
        # setup
        h.set_context('test', 'src-weird', neighborhood='Projects')
        repo_dir = pkg_resources.resource_filename('forgegit', 'tests/data')
        repo = GM.Repository(name='weird-chars.git',
                             fs_path=repo_dir,
                             url_path='/src-weird/',
                             tool='git',
                             status='creating')
        repo.refresh()
        ThreadLocalORMSession.flush_all()
        ThreadLocalORMSession.close_all()

        diffs = repo.paged_diffs(
            '346c52c1dddc729e2c2711f809336401f0ff925e')  # Test copy
        expected = {
            'added': [],
            'removed': [],
            'copied': [{
                'new': u'README.copy',
                'old': u'README',
                'ratio': 1.0
            }],
            'renamed': [],
            'changed': [u'README'],
            'total': 2,
        }
        assert_equals(diffs, expected)
        diffs = repo.paged_diffs(
            '3cb2bbcd7997f89060a14fe8b1a363f01883087f')  # Test rename
        expected = {
            'added': [],
            'removed': [],
            'copied': [],
            'renamed': [{
                'new': u'README',
                'old': u'README-copy.md',
                'ratio': 1.0
            }],
            'changed': [],
            'total': 1,
        }
        assert_equals(diffs, expected)
Exemplo n.º 15
0
 def test_merge_request_commits(self):
     res = self.repo.merge_request_commits(self.merge_request)
     expected = [{
         'authored': {
             'date': datetime.datetime(2013, 3, 28, 18, 54, 16),
             'email': '*****@*****.**',
             'name': 'Cory Johns'
         },
         'committed': {
             'date': datetime.datetime(2013, 3, 28, 18, 54, 16),
             'email': '*****@*****.**',
             'name': 'Cory Johns'
         },
         'id': '5c47243c8e424136fd5cdd18cd94d34c66d1955c',
         'message': 'Not repo root\n',
         'parents': ['1e146e67985dcd71c74de79613719bef7bddca4a'],
         'refs': ['zz'],
         'rename_details': {},
         'size': None
     }]
     assert_equals(res, expected)
Exemplo n.º 16
0
def test_assert_equal_false():
    try:
        tools.assert_equals([3, 4], [5, 6])
    except:
        e = sys.exc_info()[1]
        assert_equal(type(e), AssertionError)
        assert_equal(
            str(e),
            dedent('''\
            
            --- a
            +++ b
            [
            @@ -0,1 +0,1 @@
            -3,
            -4,
            +5,
            +6,
            ]'''))
    else:
        raise AssertionError("Should've raised an AssertionError")
Exemplo n.º 17
0
    def test_paged_diffs(self):
        _id = self.repo._impl._oid(6)
        diffs = self.repo.commit(_id).diffs
        expected = {
            'added': ['/ЗРЯЧИЙ_ТА_ПОБАЧИТЬ'],
            'removed': [],
            'changed': [],
            'copied': [],
            'renamed': [],
            'total': 1,
        }
        assert_equals(diffs, expected)

        _id = self.repo._impl._oid(2)
        diffs = self.repo.commit(_id).diffs
        expected = {
            'added': ['/a', '/a/b', '/a/b/c', '/a/b/c/hello.txt'],
            'removed': [],
            'changed': [],
            'renamed': [],
            'copied': [],
            'total': 4,
        }
        assert_equals(diffs, expected)

        _id = self.repo._impl._oid(3)
        diffs = self.repo.commit(_id).diffs
        expected = {
            'added': [],
            'removed': [],
            'renamed': [],
            'changed': ['/README'],
            'copied': [],
            'total': 1,
        }
        assert_equals(diffs, expected)

        _id = self.repo._impl._oid(4)
        diffs = self.repo.commit(_id).diffs
        expected = {
            'added': [],
            'removed': ['/a/b/c/hello.txt'],
            'changed': [],
            'renamed': [],
            'copied': [],
            'total': 1,
        }
        assert_equals(diffs, expected)
Exemplo n.º 18
0
    def test_paged_diffs(self):
        diffs = self.rev.diffs
        expected = {
            'added': [u'/ЗРЯЧИЙ_ТА_ПОБАЧИТЬ'],
            'removed': [],
            'changed': [],
            'copied': [],
            'renamed': [],
            'total': 1,
        }
        assert_equals(diffs, expected)

        _id = self.repo._impl._oid(2)
        diffs = self.repo.commit(_id).diffs
        expected = {
            'added': [u'/a', u'/a/b', u'/a/b/c', u'/a/b/c/hello.txt'],
            'removed': [],
            'changed': [],
            'renamed': [],
            'copied': [],
            'total': 4,
        }
        assert_equals(diffs, expected)

        _id = self.repo._impl._oid(3)
        diffs = self.repo.commit(_id).diffs
        expected = {
            'added': [],
            'removed': [],
            'renamed': [],
            'changed': [u'/README'],
            'copied': [],
            'total': 1,
        }
        assert_equals(diffs, expected)

        _id = self.repo._impl._oid(4)
        diffs = self.repo.commit(_id).diffs
        expected = {
            'added': [],
            'removed': ['/a/b/c/hello.txt'],
            'changed': [],
            'renamed': [],
            'copied': [],
            'total': 1,
        }
        assert_equals(diffs, expected)
Exemplo n.º 19
0
def event_test(agent, name, pre_func=None, post_func=None, diff=True):
    req = json_data(name)
    valid_resp_file = json_data(name + '_resp')
    valid_resp = JsonObject.unwrap(valid_resp_file)

    if pre_func is not None:
        pre_func(req)

    resp = agent.execute(req)
    if post_func is not None:
        insp = inspect.getargspec(post_func)
        if len(insp.args) == 3:
            post_func(req, resp, valid_resp)
        else:
            post_func(req, resp)

    if diff:
        del resp["id"]
        del resp["time"]

        diff_dict(valid_resp, JsonObject.unwrap(resp))
        assert_equals(valid_resp, JsonObject.unwrap(resp))

    return req, resp
Exemplo n.º 20
0
def event_test(agent, name, pre_func=None, post_func=None, diff=True):
    req = json_data(name)
    valid_resp_file = json_data(name + '_resp')
    valid_resp = JsonObject.unwrap(valid_resp_file)

    if pre_func is not None:
        pre_func(req)

    resp = agent.execute(req)
    if post_func is not None:
        insp = inspect.getargspec(post_func)
        if len(insp.args) == 3:
            post_func(req, resp, valid_resp)
        else:
            post_func(req, resp)

    if diff:
        del resp["id"]
        del resp["time"]

        diff_dict(valid_resp, JsonObject.unwrap(resp))
        assert_equals(valid_resp, JsonObject.unwrap(resp))

    return req, resp
Exemplo n.º 21
0
def then_json_pointer_is_a_base64_object(ctx, path, path2, value):
    actual = get_pointer(ctx.zato.response.data_impl, path)
    decoded_value = json.loads(base64.b64decode(actual))
    actual = get_pointer(decoded_value, path2)

    return assert_equals(actual, value)
Exemplo n.º 22
0
 def test_diff_copy(self):
     entry = self.repo.commit(self.repo.log(5, id_only=True, limit=1).next())
     assert_equals(dict(entry.diffs), dict(
             copied=[{'new': u'/b', 'old': u'/a', 'ratio': 1}],  renamed=[],
             changed=[], removed=[], added=[], total=1))
Exemplo n.º 23
0
    def test_paged_diffs(self):
        # setup
        h.set_context('test', 'src-weird', neighborhood='Projects')
        repo_dir = pkg_resources.resource_filename(
            'forgegit', 'tests/data')
        repo = GM.Repository(
            name='weird-chars.git',
            fs_path=repo_dir,
            url_path='/src-weird/',
            tool='git',
            status='creating')
        repo.refresh()
        ThreadLocalORMSession.flush_all()
        ThreadLocalORMSession.close_all()

        # spaces and unicode filenames
        diffs = repo.paged_diffs('407950e8fba4dbc108ffbce0128ed1085c52cfd7')
        expected = {
            'removed': [],
            'changed': [],
            'renamed': [],
            'added': ['with space.txt', 'привіт.txt'],
            'copied': [],
            'total': 2,
        }
        assert_equals(diffs, expected)

        diffs = repo.paged_diffs('f3de6a0e7601cdde326054a1cc708afdc1dbe70b')
        expected = {
            'added': [],
            'removed': [],
            'copied': [],
            'renamed': [],
            'changed': ['привіт.txt'],
            'total': 1,
        }
        assert_equals(diffs, expected)

        # initial commit is special, but must work too
        diffs = repo.paged_diffs('afaa6d93eb5661fb04f8e10e9ba1039b7441a6c7')
        expected = {
            'added': ['README.md'],
            'removed': [],
            'changed': [],
            'copied': [],
            'renamed': [],
            'total': 1,
        }
        assert_equals(diffs, expected)

        # pagination
        diffs = repo.paged_diffs('407950e8fba4dbc108ffbce0128ed1085c52cfd7', start=0, end=1)
        expected = {
            'added': ['with space.txt'],
            'removed': [],
            'copied': [],
            'renamed': [],
            'changed': [],
            'total': 2,  # there are two total changes but result is limited to first
        }
        assert_equals(diffs, expected)
        diffs = repo.paged_diffs('407950e8fba4dbc108ffbce0128ed1085c52cfd7', start=1, end=2)
        expected = {
            'added': ['привіт.txt'],
            'removed': [],
            'copied': [],
            'renamed': [],
            'changed': [],
            'total': 2,  # there are two total changes but result is limited to second
        }
        assert_equals(diffs, expected)
        diffs = repo.paged_diffs('346c52c1dddc729e2c2711f809336401f0ff925e')  # Test copy
        expected = {
            'added': ['README.copy'],
            'removed': [],
            'copied': [],
            'renamed': [],
            'changed': ['README'],
            'total': 2,
        }
        assert_equals(diffs, expected)
        diffs = repo.paged_diffs('3cb2bbcd7997f89060a14fe8b1a363f01883087f')  # Test rename
        expected = {
            'added': ['README'],
            'removed': ['README-copy.md'],
            'copied': [],
            'renamed': [],
            'changed': [],
            'total': 2,
        }
        assert_equals(diffs, expected)
        diffs = repo.paged_diffs('616d24f8dd4e95cadd8e93df5061f09855d1a066')  # Test type change
        expected = {
            'added': [],
            'removed': [],
            'copied': [],
            'renamed': [],
            'changed': ['README.copy'],
            'total': 1,
        }
        assert_equals(diffs, expected)
Exemplo n.º 24
0
def json_response_is_equal_to(ctx, expected):
    assert_equals(expected, ctx.zato.response.data_impl)
    return True
Exemplo n.º 25
0
    def test_webhook_payload(self):
        user = M.User.upsert('cory')
        email = user.claim_address('*****@*****.**')
        email.confirmed = True
        session(email).flush(email)
        user = M.User.upsert('rick')
        email = user.claim_address('*****@*****.**')
        email.confirmed = True
        session(email).flush(email)

        sender = RepoPushWebhookSender()
        cids = list(self.repo.all_commit_ids())[:2]
        payload = sender.get_payload(commit_ids=cids, ref='refs/heads/zz')
        expected_payload = {
            'size':
            2,
            'ref':
            'refs/heads/zz',
            'after':
            '5c47243c8e424136fd5cdd18cd94d34c66d1955c',
            'before':
            'df30427c488aeab84b2352bdf88a3b19223f9d7a',
            'commits': [{
                'id': '5c47243c8e424136fd5cdd18cd94d34c66d1955c',
                'url':
                'http://localhost/p/test/src-git/ci/5c47243c8e424136fd5cdd18cd94d34c66d1955c/',
                'timestamp': datetime.datetime(2013, 3, 28, 18, 54, 16),
                'message': 'Not repo root',
                'author': {
                    'name': 'Cory Johns',
                    'email': '*****@*****.**',
                    'username': '******'
                },
                'committer': {
                    'name': 'Cory Johns',
                    'email': '*****@*****.**',
                    'username': '******'
                },
                'added': ['bad'],
                'removed': [],
                'modified': [],
                'copied': [],
                'renamed': [],
            }, {
                'id': '1e146e67985dcd71c74de79613719bef7bddca4a',
                'url':
                'http://localhost/p/test/src-git/ci/1e146e67985dcd71c74de79613719bef7bddca4a/',
                'timestamp': datetime.datetime(2010, 10, 7, 18, 44, 11),
                'message': 'Change README',
                'author': {
                    'name': 'Rick Copeland',
                    'email': '*****@*****.**',
                    'username': '******'
                },
                'committer': {
                    'name': 'Rick Copeland',
                    'email': '*****@*****.**',
                    'username': '******'
                },
                'added': [],
                'removed': [],
                'modified': ['README'],
                'copied': [],
                'renamed': [],
            }],
            'repository': {
                'name': 'Git',
                'full_name': '/p/test/src-git/',
                'url': 'http://localhost/p/test/src-git/',
            },
        }
        assert_equals(payload, expected_payload)
Exemplo n.º 26
0
def test_assert_equal_true():
    # nothing raised
    assert_equal(None, tools.assert_equals(7, 7))
Exemplo n.º 27
0
 def test_webhook_payload(self):
     sender = RepoPushWebhookSender()
     all_commits = list(self.repo.all_commit_ids())
     start = len(
         all_commits
     ) - 6  # only get a few so test doesn't have to change after new testdata commits
     cids = all_commits[start:start + 2]
     payload = sender.get_payload(commit_ids=cids)
     expected_payload = {
         'size':
         2,
         'after':
         'r6',
         'before':
         'r4',
         'commits': [{
             'id': 'r6',
             'url': 'http://localhost/p/test/src/6/',
             'timestamp': datetime(2013, 11, 8, 13, 38, 11, 152000),
             'message': '',
             'author': {
                 'name': 'coldmind',
                 'email': '',
                 'username': ''
             },
             'committer': {
                 'name': 'coldmind',
                 'email': '',
                 'username': ''
             },
             'added': ['/ЗРЯЧИЙ_ТА_ПОБАЧИТЬ'],
             'removed': [],
             'modified': [],
             'copied': [],
             'renamed': [],
         }, {
             'id': 'r5',
             'url': 'http://localhost/p/test/src/5/',
             'timestamp': datetime(2010, 11, 18, 20, 14, 21, 515000),
             'message': 'Copied a => b',
             'author': {
                 'name': 'rick446',
                 'email': '',
                 'username': ''
             },
             'committer': {
                 'name': 'rick446',
                 'email': '',
                 'username': ''
             },
             'added': [],
             'removed': [],
             'modified': [],
             'copied': [
                 {
                     'new': '/b',
                     'old': '/a',
                     'ratio': 1
                 },
             ],
             'renamed': [],
         }],
         'repository': {
             'name': 'SVN',
             'full_name': '/p/test/src/',
             'url': 'http://localhost/p/test/src/',
         },
     }
     assert_equals(payload, expected_payload)
Exemplo n.º 28
0
def test_assert_equal_true():
    # nothing raised
    assert_equal(None, tools.assert_equals(7, 7))
Exemplo n.º 29
0
    def test_paged_diffs(self):
        # setup
        h.set_context('test', 'src-weird', neighborhood='Projects')
        repo_dir = pkg_resources.resource_filename(
            'forgegit', 'tests/data')
        repo = GM.Repository(
            name='weird-chars.git',
            fs_path=repo_dir,
            url_path='/src-weird/',
            tool='git',
            status='creating')
        repo.refresh()
        ThreadLocalORMSession.flush_all()
        ThreadLocalORMSession.close_all()

        # spaces and unicode filenames
        diffs = repo.paged_diffs('407950e8fba4dbc108ffbce0128ed1085c52cfd7')
        expected = {
            'added': [u'with space.txt', u'привіт.txt'],
            'removed': [],
            'changed': [],
            'copied': [],
            'renamed': [],
            'total': 2,
        }
        assert_equals(diffs, expected)

        diffs = repo.paged_diffs('f3de6a0e7601cdde326054a1cc708afdc1dbe70b')
        expected = {
            'added': [],
            'removed': [],
            'copied': [],
            'renamed': [],
            'changed': [u'привіт.txt'],
            'total': 1,
        }
        assert_equals(diffs, expected)

        # initial commit is special, but must work too
        diffs = repo.paged_diffs('afaa6d93eb5661fb04f8e10e9ba1039b7441a6c7')
        expected = {
            'added': [u'README.md'],
            'removed': [],
            'changed': [],
            'copied': [],
            'renamed': [],
            'total': 1,
        }
        assert_equals(diffs, expected)

        # pagination
        diffs = repo.paged_diffs('407950e8fba4dbc108ffbce0128ed1085c52cfd7', start=0, end=1)
        expected = {
            'added': [u'with space.txt'],
            'removed': [],
            'copied': [],
            'renamed': [],
            'changed': [],
            'total': 2,
        }
        assert_equals(diffs, expected)
        diffs = repo.paged_diffs('407950e8fba4dbc108ffbce0128ed1085c52cfd7', start=1, end=2)
        expected = {
            'added': [u'привіт.txt'],
            'removed': [],
            'copied': [],
            'renamed': [],
            'changed': [],
            'total': 2,
        }
        assert_equals(diffs, expected)
        diffs = repo.paged_diffs('346c52c1dddc729e2c2711f809336401f0ff925e')  # Test copy
        expected = {
            'added': [u'README.copy'],
            'removed': [],
            'copied': [],
            'renamed': [],
            'changed': [u'README'],
            'total': 2,
        }
        assert_equals(diffs, expected)
        diffs = repo.paged_diffs('3cb2bbcd7997f89060a14fe8b1a363f01883087f')  # Test rename
        expected = {
            'added': [u'README'],
            'removed': [u'README-copy.md'],
            'copied': [],
            'renamed': [],
            'changed': [],
            'total': 2,
        }
        assert_equals(diffs, expected)
Exemplo n.º 30
0
 def test_diff_copy(self):
     entry = self.repo.commit(self.repo.log(5, id_only=True, limit=1).next())
     assert_equals(dict(entry.diffs), dict(
             copied=[{'new': u'/b', 'old': u'/a', 'ratio': 1}],  renamed=[],
             changed=[], removed=[], added=[], total=1))
Exemplo n.º 31
0
def json_response_is_equal_to(ctx, expected):
    assert_equals(expected, ctx.zato.response.data_impl)
    return True
Exemplo n.º 32
0
def then_json_pointer_is_a_base64_object(ctx, path, path2, value):
    actual = get_pointer(ctx.zato.response.data_impl, path)
    decoded_value = json.loads(base64.b64decode(actual))
    actual = get_pointer(decoded_value, path2)

    return assert_equals(actual, value)