1#
2#
3# Licensed to the Apache Software Foundation (ASF) under one
4# or more contributor license agreements.  See the NOTICE file
5# distributed with this work for additional information
6# regarding copyright ownership.  The ASF licenses this file
7# to you under the Apache License, Version 2.0 (the
8# "License"); you may not use this file except in compliance
9# with the License.  You may obtain a copy of the License at
10#
11#   http://www.apache.org/licenses/LICENSE-2.0
12#
13# Unless required by applicable law or agreed to in writing,
14# software distributed under the License is distributed on an
15# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16# KIND, either express or implied.  See the License for the
17# specific language governing permissions and limitations
18# under the License.
19#
20#
21import unittest, setup_path
22import svn.core
23
24class ChecksumTestCases(unittest.TestCase):
25    def test_checksum(self):
26        # Checking primarily the return type for the svn_checksum_create
27        # function
28        kind, expected_length = svn.core.svn_checksum_md5, 128/8
29        val = svn.core.svn_checksum_create(kind)
30        check_val = svn.core.svn_checksum_to_cstring_display(val)
31
32        self.assertTrue(isinstance(check_val, bytes),
33                              "Type of digest not string")
34        self.assertEqual(len(check_val), 2*expected_length,
35                         "Length of digest does not match kind")
36        self.assertEqual(int(check_val), 0,
37                         "Value of initialized digest is not 0")
38
39def suite():
40    return unittest.defaultTestLoader.loadTestsFromTestCase(ChecksumTestCases)
41
42if __name__ == '__main__':
43    runner = unittest.TextTestRunner()
44    runner.run(suite())
45
46
47
48
49