def test_new_crashes(self):
        config = self.get_standard_config()
        sub_walker = SubmitterFileSystemWalkerSource(config)

        sequence = [
            './6611a662-e70f-4ba5-a397-69a3a2121129.json',
            './7611a662-e70f-4ba5-a397-69a3a2121129.json',
            './8611a662-e70f-4ba5-a397-69a3a2121129.json',
        ]
        crash_path = generator_for_sequence(*sequence)
        sub_walker.new_crashes = crash_path
        for a_row in sub_walker.new_crashes():
            eq_(a_row, sequence.pop())
    def test_new_crashes(self):
        config = self.get_standard_config()
        sub_walker = SubmitterFileSystemWalkerSource(config)

        sequence =  [
            './6611a662-e70f-4ba5-a397-69a3a2121129.json',
            './7611a662-e70f-4ba5-a397-69a3a2121129.json',
            './8611a662-e70f-4ba5-a397-69a3a2121129.json',
        ]
        crash_path =  generator_for_sequence(*sequence)
        sub_walker.new_crashes = crash_path
        for a_row in sub_walker.new_crashes():
            eq_(a_row, sequence.pop())
Example #3
0
    def test_new_crashes(self):
        config = self.get_standard_config()
        sub_walker = SubmitterFileSystemWalkerSource(config)

        crash_path = sequencer('./6611a662-e70f-4ba5-a397-69a3a2121129.json',
                               './7611a662-e70f-4ba5-a397-69a3a2121129.json',
                               './8611a662-e70f-4ba5-a397-69a3a2121129.json',
                               )
        sub_walker.new_crashes = mock.Mock(side_effect=crash_path)
        new_crashes = sub_walker.new_crashes()

        ok_(isinstance(new_crashes.next(), str))
        eq_(new_crashes.next(),
            './7611a662-e70f-4ba5-a397-69a3a2121129.json')
        ok_(new_crashes.next().endswith(".json"))
Example #4
0
    def test_new_crashes(self):
        config = self.get_standard_config()
        sub_walker = SubmitterFileSystemWalkerSource(config)

        crash_path = sequencer(
            './6611a662-e70f-4ba5-a397-69a3a2121129.json',
            './7611a662-e70f-4ba5-a397-69a3a2121129.json',
            './8611a662-e70f-4ba5-a397-69a3a2121129.json',
        )
        sub_walker.new_crashes = mock.Mock(side_effect=crash_path)
        new_crashes = sub_walker.new_crashes()

        ok_(isinstance(new_crashes.next(), str))
        eq_(new_crashes.next(), './7611a662-e70f-4ba5-a397-69a3a2121129.json')
        ok_(new_crashes.next().endswith(".json"))
    def test_new_crashes(self):
        sequence =  [
            (
                './',
                '6611a662-e70f-4ba5-a397-69a3a2121129.json',
                './6611a662-e70f-4ba5-a397-69a3a2121129.json',
            ),
            (
                './',
                '6611a662-e70f-4ba5-a397-69a3a2121129.upload.dump',
                './6611a662-e70f-4ba5-a397-69a3a2121129.upload.dump',
            ),
            (
                './',
                '7611a662-e70f-4ba5-a397-69a3a2121129.json',
                './7611a662-e70f-4ba5-a397-69a3a2121129.json',
            ),
            (
                './',
                '7611a662-e70f-4ba5-a397-69a3a2121129.other.dump',
                './7611a662-e70f-4ba5-a397-69a3a2121129.other.dump',
            ),
            (
                './',
                '7611a662-e70f-4ba5-a397-69a3a2121129.other.txt',
                './7611a662-e70f-4ba5-a397-69a3a2121129.other.txt',
            ),
            (
                './',
                '8611a662-e70f-4ba5-a397-69a3a2121129.json',
                './8611a662-e70f-4ba5-a397-69a3a2121129.json',
            )
        ]

        def findFileGenerator_mock_method(root, method):
            for x in sequence:
                if method(x):
                    yield x

        def listdir_mock_method(a_path):
            for x in sequence:
                yield x[1]

        config = self.get_standard_config()

        expected = [
            (
                ((
                    '6611a662-e70f-4ba5-a397-69a3a2121129',
                    [
                        './6611a662-e70f-4ba5-a397-69a3a2121129.json',
                        './6611a662-e70f-4ba5-a397-69a3a2121129.upload.dump'
                    ],
                ), ),
                {}
            ),
            (
                ((
                    '7611a662-e70f-4ba5-a397-69a3a2121129',
                    [
                        './7611a662-e70f-4ba5-a397-69a3a2121129.json',
                        './7611a662-e70f-4ba5-a397-69a3a2121129.other.dump'
                    ],
                ), ),
                {}
            ),
            (
                ((
                    '8611a662-e70f-4ba5-a397-69a3a2121129',
                    [
                        './8611a662-e70f-4ba5-a397-69a3a2121129.json'
                    ]
                ), ),
                {}
            ),
        ]

        find_patch_path = 'socorro.collector.submitter_app.findFileGenerator'
        with mock.patch(
            find_patch_path,
            new_callable=lambda: findFileGenerator_mock_method
        ):
            listdir_patch_path = 'socorro.collector.submitter_app.listdir'
            with mock.patch(
                listdir_patch_path,
                new_callable=lambda: listdir_mock_method
            ):

                sub_walker = SubmitterFileSystemWalkerSource(config)
                result = [x for x in sub_walker.new_crashes()]
                eq_(result, expected)
Example #6
0
    def test_new_crashes(self):
        sequence =  [
            (
                './',
                '6611a662-e70f-4ba5-a397-69a3a2121129.json',
                './6611a662-e70f-4ba5-a397-69a3a2121129.json',
            ),
            (
                './',
                '6611a662-e70f-4ba5-a397-69a3a2121129.upload.dump',
                './6611a662-e70f-4ba5-a397-69a3a2121129.upload.dump',
            ),
            (
                './',
                '7611a662-e70f-4ba5-a397-69a3a2121129.json',
                './7611a662-e70f-4ba5-a397-69a3a2121129.json',
            ),
            (
                './',
                '7611a662-e70f-4ba5-a397-69a3a2121129.other.dump',
                './7611a662-e70f-4ba5-a397-69a3a2121129.other.dump',
            ),
            (
                './',
                '7611a662-e70f-4ba5-a397-69a3a2121129.other.txt',
                './7611a662-e70f-4ba5-a397-69a3a2121129.other.txt',
            ),
            (
                './',
                '8611a662-e70f-4ba5-a397-69a3a2121129.json',
                './8611a662-e70f-4ba5-a397-69a3a2121129.json',
            )
        ]

        def findFileGenerator_mock_method(root, method):
            for x in sequence:
                if method(x):
                    yield x

        def listdir_mock_method(a_path):
            for x in sequence:
                yield x[1]

        config = self.get_standard_config()

        expected = [
            (
                ((
                    '6611a662-e70f-4ba5-a397-69a3a2121129',
                    [
                        './6611a662-e70f-4ba5-a397-69a3a2121129.json',
                        './6611a662-e70f-4ba5-a397-69a3a2121129.upload.dump'
                    ],
                ), ),
                {}
            ),
            (
                ((
                    '7611a662-e70f-4ba5-a397-69a3a2121129',
                    [
                        './7611a662-e70f-4ba5-a397-69a3a2121129.json',
                        './7611a662-e70f-4ba5-a397-69a3a2121129.other.dump'
                    ],
                ), ),
                {}
            ),
            (
                ((
                    '8611a662-e70f-4ba5-a397-69a3a2121129',
                    [
                        './8611a662-e70f-4ba5-a397-69a3a2121129.json'
                    ]
                ), ),
                {}
            ),
        ]

        find_patch_path = 'socorro.collector.submitter_app.findFileGenerator'
        with mock.patch(
            find_patch_path,
            new_callable=lambda: findFileGenerator_mock_method
        ):
            listdir_patch_path = 'socorro.collector.submitter_app.listdir'
            with mock.patch(
                listdir_patch_path,
                new_callable=lambda: listdir_mock_method
            ):

                sub_walker = SubmitterFileSystemWalkerSource(config)
                result = [x for x in sub_walker.new_crashes()]
                eq_(result, expected)