Exemple #1
0
 def test_quote_paths(self):
     tracked_files = ['some file', 'main file']
     loop = Loop(parameters=tracked_files)
     attrs = loop._get_attrs_as_dict_of_strs()
     for key, expected in [
         ('tracked_files', ' '.join(imap(quote, tracked_files))),
         ('main_file', quote(tracked_files[0])),
         ('bin', quote(tracked_files[0])),
     ]:
         actual = attrs[key]
         assert_equals(actual, expected)
Exemple #2
0
    def test_spaceseparated_sequences(self):
        loop = Loop(parameters=['Albert E.', 'Fiedel C.'])
        loop.pintores = ('Salvador D.', 'Pablo P.')
        attrs = loop._get_attrs_as_dict_of_strs()

        for key, expected in [
            ('tracked_files', ' '.join(imap(quote, loop.tracked_files))),
            ('pintores', ' '.join(imap(quote, loop.pintores))),
        ]:
            actual = attrs[key]
            assert_equals(actual, expected)
Exemple #3
0
    def test_spaceseparated_sequences(self):
        loop = Loop(parameters=['Albert E.', 'Fiedel C.'])
        loop.pintores = ('Salvador D.', 'Pablo P.')
        attrs = loop._get_attrs_as_dict_of_strs()

        for key, expected in [
            ('tracked_files', ' '.join(imap(quote, loop.tracked_files))),
            ('pintores', ' '.join(imap(quote, loop.pintores))),
        ]:
            actual = attrs[key]
            assert_equals(actual, expected)
Exemple #4
0
 def test_quote_paths(self):
     tracked_files = ['some file', 'main file']
     loop = Loop(parameters=tracked_files)
     attrs = loop._get_attrs_as_dict_of_strs()
     for key, expected in [
         ('tracked_files', ' '.join(imap(quote, tracked_files))),
         ('main_file', quote(tracked_files[0])),
         ('bin', quote(tracked_files[0])),
     ]:
         actual = attrs[key]
         assert_equals(actual, expected)
Exemple #5
0
    def test_parse_input(self):
        # parameters
        parameters = ['+']
        passed_special = True

        tracked_files = ['foo', 'bar']
        parameters.extend(tracked_files)

        main_file = tracked_files[0]

        bin = main_file

        args = '-3 --verbose reset --hard'
        parameters.extend(args.split())

        # test
        loop = Loop(parameters=parameters)
        for actual, expected in [
            (loop.raw, ' '.join(parameters)),
            (loop.passed_special, passed_special),
            (loop.tracked_files, tracked_files),
            (loop.main_file, main_file),
            (loop.bin, bin),
            (loop.args, args),
        ]:
            assert_equals(actual, expected)
Exemple #6
0
 def test_set_default_values_on_clean_init(self):
     loop = Loop(parameters=[])
     for actual, expected in [
         (loop.raw, ''),
         (loop.passed_special, False),
         (loop.tracked_files, []),
         (loop.main_file, ''),
         (loop.bin, ''),
         (loop.args, ''),
     ]:
         assert_equals(actual, expected)
Exemple #7
0
    def test_represent_attributes_as_dict_of_strs(self):
        passed_special = 'False'
        main_file = 'baz'
        bin = main_file
        tracked_files = main_file + ' foo bar'
        args = '--waka -waka waka'
        raw = tracked_files + ' ' + args

        expected = {
            'raw': raw,
            'passed_special': passed_special,
            'tracked_files': tracked_files,
            'main_file': main_file,
            'bin': bin,
            'args': args,
        }

        loop = Loop(parameters=raw.split())
        actual = loop._get_attrs_as_dict_of_strs()

        assert_equals(actual, expected)
Exemple #8
0
    def test_represent_attributes_as_dict_of_strs(self):
        passed_special = 'False'
        main_file = 'baz'
        bin = main_file
        tracked_files = main_file + ' foo bar'
        args = '--waka -waka waka'
        raw = tracked_files + ' ' + args

        expected = {
            'raw': raw,
            'passed_special': passed_special,
            'tracked_files': tracked_files,
            'main_file': main_file,
            'bin': bin,
            'args': args,
        }

        loop = Loop(parameters=raw.split())
        actual = loop._get_attrs_as_dict_of_strs()

        assert_equals(actual, expected)
Exemple #9
0
 def test_nonstr_stuff_in_sequences_to_str(self):
     loop = Loop()
     loop.seq = [0, None, False]
     attrs = loop._get_attrs_as_dict_of_strs()
     assert_equals(attrs['seq'], '0 None False')
Exemple #10
0
 def test_use_userdefined_attributes(self):
     loop = Loop(parameters=[])
     loop.foo = None
     expected = 'None'
     actual = loop._get_attrs_as_dict_of_strs()['foo']
     assert_equals(actual, expected)
Exemple #11
0
 def test_quote_raw(self):
     expected = "'foo bar' baz"
     actual = Loop(parameters=['foo bar', 'baz']).raw
     assert_equals(actual, expected)
Exemple #12
0
 def test_strip_main_file_extension_in_bin(self):
     expected = 'foo'
     actual = Loop(parameters=[expected + '.bar']).bin
     assert_equals(actual, expected)
Exemple #13
0
 def test_nonstr_stuff_in_sequences_to_str(self):
     loop = Loop()
     loop.seq = [0, None, False]
     attrs = loop._get_attrs_as_dict_of_strs()
     assert_equals(attrs['seq'], '0 None False')
Exemple #14
0
 def test_use_userdefined_attributes(self):
     loop = Loop(parameters=[])
     loop.foo = None
     expected = 'None'
     actual = loop._get_attrs_as_dict_of_strs()['foo']
     assert_equals(actual, expected)