This file is indexed.

/usr/lib/python2.7/dist-packages/trytond/tests/test_sequence.py is in tryton-server 3.8.3-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# -*- coding: utf-8 -*-
# This file is part of Tryton.  The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import unittest
import datetime
from trytond.tests.test_tryton import POOL, DB_NAME, USER, CONTEXT, \
        install_module
from trytond.transaction import Transaction
from trytond.exceptions import UserError


class SequenceTestCase(unittest.TestCase):
    'Test Sequence'

    def setUp(self):
        install_module('tests')
        self.sequence = POOL.get('ir.sequence')

    def test0010incremental(self):
        'Test incremental'
        with Transaction().start(DB_NAME, USER,
                context=CONTEXT) as transaction:
            sequence, = self.sequence.create([{
                        'name': 'Test incremental',
                        'code': 'test',
                        'prefix': '',
                        'suffix': '',
                        'type': 'incremental',
                        }])
            self.assertEqual(self.sequence.get_id(sequence), '1')

            self.sequence.write([sequence], {
                    'number_increment': 10,
                    })
            self.assertEqual(self.sequence.get_id(sequence), '2')
            self.assertEqual(self.sequence.get_id(sequence), '12')

            self.sequence.write([sequence], {
                    'padding': 3,
                    })
            self.assertEqual(self.sequence.get_id(sequence), '022')

            transaction.cursor.rollback()

    def test0020decimal_timestamp(self):
        'Test Decimal Timestamp'
        with Transaction().start(DB_NAME, USER,
                context=CONTEXT) as transaction:
            sequence, = self.sequence.create([{
                        'name': 'Test decimal timestamp',
                        'code': 'test',
                        'prefix': '',
                        'suffix': '',
                        'type': 'decimal timestamp',
                        }])
            timestamp = self.sequence.get_id(sequence)
            self.assertEqual(timestamp, str(sequence.last_timestamp))

            self.assertNotEqual(self.sequence.get_id(sequence), timestamp)

            next_timestamp = self.sequence._timestamp(sequence)
            self.assertRaises(UserError, self.sequence.write, [sequence], {
                    'last_timestamp': next_timestamp + 100,
                    })

            transaction.cursor.rollback()

    def test0030hexadecimal_timestamp(self):
        'Test Hexadecimal Timestamp'
        with Transaction().start(DB_NAME, USER,
                context=CONTEXT) as transaction:
            sequence, = self.sequence.create([{
                        'name': 'Test hexadecimal timestamp',
                        'code': 'test',
                        'prefix': '',
                        'suffix': '',
                        'type': 'hexadecimal timestamp',
                        }])
            timestamp = self.sequence.get_id(sequence)
            self.assertEqual(timestamp,
                hex(int(sequence.last_timestamp))[2:].upper())

            self.assertNotEqual(self.sequence.get_id(sequence), timestamp)

            next_timestamp = self.sequence._timestamp(sequence)
            self.assertRaises(UserError, self.sequence.write, [sequence], {
                    'last_timestamp': next_timestamp + 100,
                    })

            transaction.cursor.rollback()

    def test0040prefix_suffix(self):
        'Test prefix/suffix'
        with Transaction().start(DB_NAME, USER, context=CONTEXT):
            sequence, = self.sequence.create([{
                        'name': 'Test incremental',
                        'code': 'test',
                        'prefix': 'prefix/',
                        'suffix': '/suffix',
                        'type': 'incremental',
                        }])
            self.assertEqual(self.sequence.get_id(sequence),
                'prefix/1/suffix')

            self.sequence.write([sequence], {
                    'prefix': '${year}-${month}-${day}/',
                    'suffix': '/${day}.${month}.${year}',
                    })
            with Transaction().set_context(date=datetime.date(2010, 8, 15)):
                self.assertEqual(self.sequence.get_id(sequence),
                    '2010-08-15/2/15.08.2010')


def suite():
    return unittest.TestLoader().loadTestsFromTestCase(SequenceTestCase)