def testPostForDeduplication(self):
        symInitial = self.createSymbolFile('initial.sym')
        symDup = self.createSymbolFile(
            'dup.sym', status=upload_symbols.SymbolFile.DUPLICATE)
        symUploaded = self.createSymbolFile(
            'uploaded.sym', status=upload_symbols.SymbolFile.UPLOADED)

        symInitialItem = self.createSymbolFile('initialItem.sym', dedupe=True)

        symDupItem = self.createSymbolFile(
            'dupItem.sym',
            status=upload_symbols.SymbolFile.DUPLICATE,
            dedupe=True)
        # This is the only symbol file which should be pushed to isolate.
        symUploadedItem = self.createSymbolFile(
            'upItem.sym',
            status=upload_symbols.SymbolFile.UPLOADED,
            dedupe=True)

        symbols = (symInitial, symDup, symUploaded, symInitialItem, symDupItem,
                   symUploadedItem)

        result = upload_symbols.PostForDeduplication(symbols, 'namespace')
        self.assertEqual(list(result), list(symbols))
        self.assertEqual(self.push_mock.mock_calls, [
            mock.call(
                symUploadedItem.dedupe_item, 'push_state',
                ["SymbolHeader(cpu='cpu', id='id', name='name', os='os')"])
        ])
  def testPostForDeduplicationPushFail(self):
    self.push_mock.side_effect = Exception

    sym1 = self.createSymbolFile(
        'sym1.sym', status=upload_symbols.SymbolFile.UPLOADED, dedupe=True)
    sym2 = self.createSymbolFile(
        'sym2.sym', status=upload_symbols.SymbolFile.UPLOADED, dedupe=True)

    result = upload_symbols.PostForDeduplication((sym1, sym2), 'namespace')
    self.assertEqual(list(result), [sym1, sym2])
    self.assertEqual(self.push_mock.call_count, 1)