import re
import unittest
from ir_datasets.datasets.wapo import WapoDoc, WapoDocMedia, TrecBackgroundLinkingQuery
from ir_datasets.formats import GenericQrel, GenericQuery, TrecQuery, TrecQrel
from .base import DatasetIntegrationTest


class TestWapo(DatasetIntegrationTest):
    def test_docs(self):
        self._test_docs('wapo/v2', count=595037, items={
            0: WapoDoc('b2e89334-33f9-11e1-825f-dabc29fd7071', 'https://www.washingtonpost.com/sports/colleges/danny-coale-jarrett-boykin-are-a-perfect-1-2-punch-for-virginia-tech/2011/12/31/gIQAAaW4SP_story.html', re.compile('^Danny Coale, Jarrett .* Virginia Tech$', flags=48), 'Mark Giannotto', 1325376562000, 'Colleges', re.compile('^Virginia Tech wide receiver Danny Coale \\(19\\) was lightly recruited out of Episcopal in Alexandria bu.{2838} on him and he’ll be there\\. I know when I look back, part of my Tech experience is going to be him\\.”$', flags=48), (re.compile('<span class="dateline">NEW.*North Carolina comes up.', flags=48),re.compile('Midway through the first.*position coach, said recently.', flags=48),re.compile('Now that Boykin and.*taken a different stance.', flags=48),re.compile('“I still don’t think.*him nodding in agreement.', flags=48),re.compile('Just add that to.*have had to overcome.', flags=48),re.compile('Boykin has been <a.*any other Hokies receiver.', flags=48),re.compile('Coale, an Episcopal.*to be open.”', flags=48),re.compile('And yet neither warranted.*participated in the voting.', flags=48),re.compile('In retrospect, Boykin.*a first-year quarterback.', flags=48),re.compile('“There’s just some things.*up there with them.', flags=48),re.compile('“It’s great playing wide.*and 22 touchdowns.”', flags=48),re.compile('The other issue is.*wide receivers these days.', flags=48),re.compile('Coale has graduated with.*field or in games.', flags=48),re.compile('Coming out of high.*under the radar.”', flags=48),re.compile('But their accomplishments haven’t.*ball,” he said.', flags=48),re.compile('Years of lining up.*championship game this year.', flags=48),re.compile('Boykin was supposed to.*to take his place.', flags=48),re.compile('“I’ve been through his.*to be him.”', flags=48)),(WapoDocMedia(type='image', url=re.compile('https://img.washingtonpost.com.*Images/Virginia_Tech_Georgia_Tech_Football_0cf3f.jpg', flags=48), text=re.compile('Virginia Tech wide receiver.*John Bazemore/AP', flags=48)),)),
            9: WapoDoc('153127ee-341e-11e1-825f-dabc29fd7071', 'https://www.washingtonpost.com/sports/capitals/capitals-vs-blue-jackets-alex-ovechkin-scores-twice-as-washington-wins/2011/12/31/gIQA1deHTP_story.html', re.compile('^Capitals vs. Blue .* Washington wins$', flags=48), 'Katie Carrera', 1325387427000, 'Capitals/NHL', re.compile("^Columbus goalie Steve Mason makes a save as Grant Clitsome \\(14\\) and Washington's Brooks Laich \\(21\\) l.{3476} the group into making sure it didn’t let the week of progress unravel in one night\\.\n\nCapitals note:$", flags=48), (re.compile('<span class="dateline">COLUMBUS.*team in the NHL.', flags=48),re.compile('A furious third-period.*winning streak since October.', flags=48),re.compile('Three goals in the.*entering the third period.', flags=48),re.compile('The victory improved the.*a> in ninth place.', flags=48),re.compile('“For a while here.*need to be.”', flags=48),re.compile('Columbus, which has.*at the Blue Jackets.', flags=48),re.compile('“We had nothing to.*credit to them.”', flags=48),re.compile('Hunter wanted pressure from.*slap pass from Wideman.', flags=48),re.compile('The defenseman set up.*for matching roughing minors.', flags=48),re.compile('Twenty-eight seconds later.*as the game-winner.', flags=48),re.compile('Ovechkin added his second.*the past eight games.', flags=48),re.compile('“Everybody was upset how.*on our side.”', flags=48),re.compile('Until the final period.*minutes of scoreless action.', flags=48),re.compile('Early in the game.*in as many nights.', flags=48),re.compile('As the first period.*in a scoreless tie.', flags=48),re.compile('In the second,.*47 of the second.', flags=48),re.compile('Samuel Pahlsson made it.*unravel in one night.', flags=48),re.compile('“It’s a big win.*we can get.”', flags=48),re.compile('<b>Capitals note:</b.*on-ice workout Saturday.', flags=48)),(WapoDocMedia(type='image', url=re.compile('https://img.washingtonpost.com.*Images/Capitals_Blue_Jackets_Hockey_0ed19.jpg', flags=48), text=re.compile("Columbus goalie Steve Mason.*Jay LaPrete/Associated Press", flags=48)),WapoDocMedia(type='image', url=re.compile('https://img.washingtonpost.com.*Images/Capitals_Blue_Jackets_Hockey_09796.jpg', flags=48), text=re.compile("Washington's Dmitry Orlov.*Jay LaPrete/Associated Press", flags=48)))),
            595036: WapoDoc('fffbc452-b422-11e2-9a98-4be1688d7d84', 'https://www.washingtonpost.com/business/capitalbusiness/gwu-studentshelp-small-groups-raise-money/2013/05/05/fffbc452-b422-11e2-9a98-4be1688d7d84_story.html', re.compile('^GWU students .* raise money$', flags=48), 'Vanessa Small', 1367797043000, 'Capital Business', re.compile('^Dylan Fox, right, is founder and chief executive of Crowdvance, a new online fundraising platform\\. H.{3696}d,” Fox said\\. “I think you can only be successful if you’re not only creating a profit but a value\\.”$', flags=48), (re.compile('While most students at.*approval from business executives.', flags=48),re.compile('The student entrepreneur started.*its creation last September.', flags=48),re.compile('Crowdvance recently won first.*values and social impact.', flags=48),re.compile('Now Crowdvance is competing.*incentives to attract givers.', flags=48),re.compile('Crowdvance is something like.*enter a national competition.', flags=48),re.compile('When making a donation.*com and Ice.com.', flags=48),re.compile('Fox .* revenue.', flags=48),re.compile('“Small organizations can’t generate.*burns out donors.”', flags=48),re.compile('Crowdvance’s biggest success stories.*to be registered nonprofits.', flags=48),re.compile('Fox has been an.*to students each month.', flags=48),re.compile('Then one afternoon last.*became the marketing officer.', flags=48),re.compile('Fox, who spent.*of raising seed money.', flags=48),re.compile('In between their busy.*to start social ventures.', flags=48),re.compile('“I don’t want to.*but a value.”', flags=48)),(WapoDocMedia(type='image', url=re.compile('https://img.washingtonpost.com.*Images/IMG_93451367464507.JPG', flags=48), text=re.compile('Dylan Fox, right.*THE WASHINGTON POST', flags=48)),)),
        })

        self._test_docs('wapo/v4', count=728626, items={
            0: WapoDoc('b2e89334-33f9-11e1-825f-dabc29fd7071', 'https://www.washingtonpost.com/sports/colleges/danny-coale-jarrett-boykin-are-a-perfect-1-2-punch-for-virginia-tech/2011/12/31/gIQAAaW4SP_story.html', 'Danny Coale, Jarrett Boykin are a perfect 1-2 punch for Virginia Tech', 'Mark Giannotto', 1325376562000, 'Colleges', re.compile('^Virginia Tech wide receiver Danny Coale \\(19\\) was lightly recruited out of Episcopal in Alexandria bu.{2838} on him and he’ll be there\\. I know when I look back, part of my Tech experience is going to be him\\.”$', flags=48), ('<span class="dateline">NEW ORLEANS —</span> Whenever a <a href="http://www.washingtonpost.com/blogs/hokies-journal" title="www.washingtonpost.com">Virginia Tech</a> offensive coach is asked how the most prolific receiving duo in school history came to be, inevitably the first road game in 2008 against North Carolina comes up.', 'Midway through the first quarter, Virginia Tech had to call two timeouts in a row because then-freshmen <a href="http://stats.washingtonpost.com/cfb/players.asp?id=168641&team=16" title="stats.washingtonpost.com">Jarrett Boykin</a> and <a href="http://stats.washingtonpost.com/cfb/players.asp?id=155812&team=16" title="stats.washingtonpost.com">Danny Coale</a> couldn’t seem to line up right, and “they had those big eyes out there looking around,” Kevin Sherman, their position coach, said recently.', 'Now that Boykin and Coale have only Tuesday’s Sugar Bowl remaining before leaving Virginia Tech with every major school record for a wide receiver, they’ve taken a different stance.', '“I still don’t think that was on us. Macho [Harris] was in the game and he lined up wrong,” said Boykin, as Coale sat next to him nodding in agreement.', 'Just add that to the list of slights these seniors have had to overcome.', 'Boykin has been <a href="http://stats.washingtonpost.com/cfb/teamstats.asp?team=16&report=stats" title="stats.washingtonpost.com">the team’s leading receiver</a> the past three seasons, using hands that need size XXXL gloves and a knack for out-maneuvering opposing cornerbacks in the air to set a single-season school record for receptions this year (57). He will end his career with more catches (180) and yards (2,854) than any other Hokies receiver.', 'Coale, an Episcopal High graduate, leads Virginia Tech with 785 receiving yards this year. He is right behind Boykin in the school record books and became the team’s starting punter by the end of this season. Coach Frank Beamer has frequently marveled how “Danny just always seems to be open.”', 'And yet neither warranted even honorable mention all-ACC status this year, a snub that quarterback <a href="http://stats.washingtonpost.com/cfb/players.asp?id=181182&team=16" title="stats.washingtonpost.com">Logan Thomas</a> said made him “extremely upset” and left Beamer wondering about the media members who participated in the voting.', 'In retrospect, Boykin said he recognizes the lack of notoriety is partly due to Virginia Tech’s offensive philosophy. The Hokies have always been known for their rushing attack, and this year was no different. Running back <a href="http://stats.washingtonpost.com/cfb/players.asp?id=181186&team=16" title="stats.washingtonpost.com">David Wilson</a> earned ACC player of the year honors during a year when Thomas set multiple records for a first-year quarterback.', '“There’s just some things that we were held back from being able to show,” Boykin said, “that we’re just as good as [South Carolina wide receiver] <a href="http://stats.washingtonpost.com/cfb/players.asp?id=180564&team=70" title="stats.washingtonpost.com">Alshon Jeffrey</a> and [Oklahoma State wide receiver] <a href="http://stats.washingtonpost.com/cfb/players.asp?id=166655&team=25" title="stats.washingtonpost.com">Justin Blackmon</a>. I feel like they’re great athletes, but at the same time we’re right up there with them.', '“It’s great playing wide receiver here because once we throw the ball, you have opportunities to get big chunks of yardage. What we can’t do is we’re not going to catch 100 balls for 1,500 yards and 22 touchdowns.”', 'The other issue is that neither has the sort of attention-grabbing personality or pedigree associated with big-time wide receivers these days.', 'Coale has graduated with a degree in finance and was named the ACC’s top scholar-athlete this year. He speaks in measured tones reminiscent of a CEO and has yet to join Facebook or Twitter. Boykin is so quiet around the team facility that Beamer said he sometimes doesn’t notice him until he’s making catches on the practice field or in games.', 'Coming out of high school, Coale was barely recruited. Before showing up to a camp in Blacksburg one summer, his only scholarship offer was from VMI, where his father is the head of strength and conditioning. Coale still jokes that when he spent his redshirt year (2007) on the scout team, former Virginia Tech wide receivers and future NFL wideouts Eddie Royal, Andre Davis and Josh Morgan “must have thought I was a walk-on. I prefer to just fly under the radar.”', 'But their accomplishments haven’t gone unnoticed now that the clock is ticking on their careers. Quarterbacks coach Mike O’Cain said Thomas’s comfort level during his record-setting first year under center is a direct reflection of Boykin and Coale. “Not only are they gonna run the right route with the right timing, you know they’re gonna catch the ball,” he said.', 'Years of lining up together has also created a special bond between the two, and it played out before the ACC championship game this year.', 'Boykin was supposed to deliver the pregame speech, but always reticent about public speaking, he was afraid he might stutter and not be taken seriously. He asked Coale to take his place.', '“I’ve been through his struggles, he’s been through mine,” Coale said. “He’s a guy that I know I can count on, whether it’s five years from now, I just know I can count on him and he’ll be there. I know when I look back, part of my Tech experience is going to be him.”'), (WapoDocMedia('image', 'https://img.washingtonpost.com/rw/2010-2019/WashingtonPost/2011/11/12/Sports/Images/Virginia_Tech_Georgia_Tech_Football_0cf3f.jpg', 'Virginia Tech wide receiver Danny Coale (19) was lightly recruited out of Episcopal in Alexandria but has teamed with Jarrett Boykin for a record-breaking receiving duo. (John Bazemore/AP)'),)),
            9: WapoDoc('153127ee-341e-11e1-825f-dabc29fd7071', 'https://www.washingtonpost.com/sports/capitals/capitals-vs-blue-jackets-alex-ovechkin-scores-twice-as-washington-wins/2011/12/31/gIQA1deHTP_story.html', 'Capitals vs. Blue Jackets: Alex Ovechkin scores twice as Washington wins', 'Katie Carrera', 1325387427000, 'Capitals/NHL', re.compile("^Columbus goalie Steve Mason makes a save as Grant Clitsome \\(14\\) and Washington's Brooks Laich \\(21\\) l.{3476} the group into making sure it didn’t let the week of progress unravel in one night\\.\n\nCapitals note:$", flags=48), ('<span class="dateline">COLUMBUS, Ohio — </span> As the <a href="http://www.washingtonpost.com/sports/capitals">Washington Capitals</a> headed to their dressing room after 40 minutes of play on Saturday night, some players slammed their sticks in the tunnel while others threw their heads back and stared at the ceiling. It looked as though the team’s 2011 might end with a whimper against the worst team in the NHL.', 'A furious third-period comeback instead launched Washington into 2012 with its first three-game winning streak since October.', 'Three goals in the span of 2 minutes 53 seconds erased a two-goal deficit and <a href="http://stats.washingtonpost.com/nhl/boxscore.asp?gamecode=2011123129&home=29&vis=23&final=true">fueled the Capitals to a 4-2 win over the Columbus Blue Jackets</a> at Nationwide Arena. It marked just the third time this season that Washington has rallied to win a game after trailing entering the third period.', 'The victory improved the Capitals to 5-2-1 in their past eight contests and gave them a much-needed two points to complete a run of three wins in four nights. <a href="http://www.washingtonpost.com/wp-srv/sports/capitals/2011-2012-schedule/index.html">Washington (20-15-2)</a> holds 42 points but is sitting outside the <a href="http://stats.washingtonpost.com/nhl/standings_conference.asp">Eastern Conference playoff picture</a> in ninth place.', '“For a while here we were going win one, win two, lose a couple — we were going back and forth,” defenseman Dennis Wideman said. “We needed to string some together. The top teams are starting to pull away from us and we’re getting into that time of year where you need to crank it up and start running some wins together to try to get back up there were we need to be.”', 'Columbus, which has just 10 wins in 38 games, outworked the Capitals through the first two periods and carried a two-goal advantage into the final period of regulation. No one in the visitors’ dressing room was pleased with the effort. But rather than accept a subpar fate, Washington opted to throw everything it had at the Blue Jackets.', '“We had nothing to lose,” Coach Dale Hunter said. “We were down 2-0, it’s an all-out blitz and the guys did a great job skating, playing hard, never quit, and it’s a credit to them.”', 'Hunter wanted pressure from all areas, with defensemen pinching to help keep offensive play alive. Ovechkin began the onslaught when he recorded his first goal of the night 4:23 into the third. Though scored as unassisted, his one-timer from the left faceoff circle that broke Steve Mason’s shutout bid was set up by a slap pass from Wideman.', 'The defenseman set up another tally when he found Alexander Semin, whose wicked wrister at 6:48 evened the score at 2 during four-on-four play while the Capitals’ Dmitry Orlov and Grant Clitsome of Columbus were in the penalty box for matching roughing minors.', 'Twenty-eight seconds later Wideman added a goal of his own, his first in nine games. The blast of a slap shot, which also came during four-on-four play, deflected off a Blue Jacket’s stick to beat Mason (22 saves) and stood as the game-winner.', 'Ovechkin added his second of the night and 16th of the season as insurance with just less than nine minutes remaining in regulation with a slap shot on the power play. The star left wing has seven goals in the past eight games.', '“Everybody was upset how we playing [in the first two periods]. I don’t think we play at all our game,” Ovechkin said. “So we just play hard and again this kind of win that we need and all the momentum on our side.”', 'Until the final period, though, the contest was hardly under the Capitals’ control. The game featured choppy play with turnovers aplenty, an abundance of whistles and more than 34 minutes of scoreless action.', 'Early in the game, the Blue Jackets showed a willingness to win battles for the puck in corners and along the boards, forcing the issue against Washington, which looked beleaguered in its second game in as many nights.', 'As the first period wore on, <a href="http://stats.washingtonpost.com/nhl/teamstats.asp?teamno=29&type=schedule">Columbus (10-23-5)</a> gained some momentum and in the final five minutes of the period peppered netminder Tomas Vokoun (35 saves) with shots from all angles and speeds. The veteran goaltender remained composed and helped Washington reach the intermission in a scoreless tie.', 'In the second, what was already a slow-moving contest regressed to more of a crawl as whistles for offsides, high sticks, icings or shots off the netting occurred with stunning frequency. With the play continuing in spurts, the first goal grew in importance, and Columbus got it when a turnover by Jason Chimera turned into a goal by John Moore at 14:47 of the second.', 'Samuel Pahlsson made it 2-0 with just 34.9 seconds remaining in the second, but that tally, which could have set Washington on its heels, galvanized the group into making sure it didn’t let the week of progress unravel in one night.', '“It’s a big win for us. Losing here would have erased the big effort against <a href="http://www.washingtonpost.com/sports/capitals-vs-sabres-alex-ovechkin-scores-two-goals-as-washington-beats-buffalo-at-verizon-center/2011/12/30/gIQAR2ZVRP_story.html">Buffalo</a> and <a href="http://www.washingtonpost.com/sports/capitals-vs-rangers-alexander-semins-two-goals-tomas-vokouns-31-saves-spark-victory/2011/12/28/gIQATySVNP_story.html">Rangers</a> earlier this week,” Vokoun said. “We need these points. We’re not sitting in the second or first place where we can say, ‘Well we have a nice comfortable cushion.’ We’re actually outside the playoffs so we need every point we can get.”', '<b>Capitals note:</b> Mike Green missed a 23rd consecutive contest with a strained right groin muscle. He made the trip with the team, however, and took part in an optional on-ice workout Saturday.'), (WapoDocMedia('image', 'https://img.washingtonpost.com/rw/2010-2019/WashingtonPost/2012/01/01/Production/Daily/Sports/Images/Capitals_Blue_Jackets_Hockey_0ed19.jpg', "Columbus goalie Steve Mason makes a save as Grant Clitsome (14) and Washington's Brooks Laich (21) look for the rebound. (Jay LaPrete/Associated Press)"), WapoDocMedia('image', 'https://img.washingtonpost.com/rw/2010-2019/WashingtonPost/2012/01/01/Production/Daily/Sports/Images/Capitals_Blue_Jackets_Hockey_09796.jpg', "Washington's Dmitry Orlov, and the Blue Jackets' R.J. Umberger (18) fight for a loose puck during the second period. (Jay LaPrete/Associated Press)"),)),
            728625: WapoDoc('DIB2IVWJNVG5FNEDFUFAFZWLUU', '/opinions/2020/12/29/worst-things-trump-did-2020/', 'The 10 worst things Trump did in 2020', 'Marc Thiessen', None, 'Opinions', re.compile('^\n10\\. He pardoned war criminals\n9\\. He vetoed the bipartisan National Defense Authorization Act\\.\n8\\. He.{624} from Marc A\\. Thiessen:\n\n\nThe 10 worst things Trump did in 2018\nThe 10 best things Trump did in 2018$', flags=48), ('This week, I offer my <a href="https://www.washingtonpost.com/opinions/2019/12/30/worst-things-trump-did/" target=_blank>annual </a>lists of the <a href="https://www.washingtonpost.com/opinions/2020/12/31/best-things-trump-did-2020/" target=_blank>10 best</a> and 10 worst things President Trump did this year. Since 2020 was such a horrible year, we’ll start with the worst things first:', '<b>10. He pardoned war criminals</b>. Trump showed a flagrant disregard of the rule of law by <a href="https://www.washingtonpost.com/national-security/trump-pardon-blackwater-contractors-iraq/2020/12/22/603da1f4-44b8-11eb-a277-49a6d1f9dff1_story.html" target=_blank>pardoning Blackwater contractors</a> who massacred unarmed Iraqi civilians, including innocent women and children.', '<b>9. He vetoed the bipartisan National Defense Authorization Act.</b> Trump vetoed $741 billion in military spending and a 3 percent pay raise for our troops over an unrelated issue, and put Republicans who voted for it in the difficult position of having to choose whether to flip-flop or override his veto.', '<b>8. He ordered the drawdown of nearly all U.S. forces in Afghanistan and Iraq</b>. Trump was apparently talked out of a complete withdrawal, but reducing to <a href="https://www.washingtonpost.com/national-security/trump-afghan-war-troop-cuts/2020/11/16/6cc2655c-2827-11eb-b847-66c66ace1afb_story.html" target=_blank>2,500 troops</a> in each country makes no strategic sense. Despite an ongoing terrorist threat, we will have fewer troops in Afghanistan or Iraq than we do in <a href="https://www.pewresearch.org/fact-tank/2017/08/22/u-s-active-duty-military-presence-overseas-is-at-its-smallest-in-decades/" target=_blank>Spain</a>.', '<b>7. He put millions in limbo by threatening to veto coronavirus relief.</b> After Democrats refused multiple GOP offers since July, Congress finally approved an aid package just as much pandemic relief was expiring. But Trump refused to sign the bill for almost a week — forcing millions of Americans to spend Christmas wondering whether they would be left to fend for themselves during the worst of the pandemic.', '<b>6. He failed to ban travel from Europe in January</b>. Trump <a href="https://www.washingtonpost.com/health/trumps-strong-wall-to-block-covid-19-from-china-had-holes/2020/07/04/48061dc2-bdff-11ea-97c1-6cf116ffe26c_story.html" target="_blank">announced </a>a travel ban on Jan. 31 on non-U.S. residents who had recently been in mainland China, saving countless lives. But he did not shut down travel from Europe until <a href="https://www.nytimes.com/2020/03/12/world/europe/trump-travel-ban-coronavirus.html" target="_blank">March 11</a> — almost six weeks later — because of objections from his economic advisers. The outbreak in New York was <a href="https://www.nytimes.com/2020/04/08/science/new-york-coronavirus-cases-europe-genomes.html">seeded by travelers from Italy</a>, and New York then seeded the rest of the country, becoming <a href="https://www.nytimes.com/2020/04/08/science/new-york-coronavirus-cases-europe-genomes.html" target="_blank">the primary source of new infections across the United States</a>.', '<b>5. His jarring fights with reporters during coronavirus briefings alienated rather than united us. </b>Trump proudly compared his press briefings to a <a href="https://www.washingtonpost.com/elections/interactive/2020/trump-pandemic-coronavirus-election/">Mike Tyson boxing match</a>, but frightened Americans didn’t want a boxing match; they wanted information and reassurance. In mid-March, 50.6 percent <a href="https://www.realclearpolitics.com/epolls/other/public_approval_of_president_trumps_handling_of_the_coronavirus-7088.html" target=_blank>approved</a> of Trump’s handling of the pandemic, but by April, he lost the American people — and never recovered.', '<b>4. His reluctance to embrace masks cost lives</b>. His refusal to require masks at his Tulsa rally, the maskless superspreader event at the White House to announce Amy Coney Barrett’s Supreme Court nomination, and the scene of him dramatically <a href="https://www.washingtonpost.com/nation/2020/10/06/trump-coronavirus-mask-doctors/" target=_blank>removing his mask</a> on the White House balcony after returning from Walter Reed all became symbols of his covid response failures.', '<b>3. He is failing to distribute more than half the available doses of vaccine</b>. His administration is <a href="https://www.washingtonpost.com/opinions/2020/12/24/trump-administration-is-holding-back-over-half-its-vaccine-doses-distribute-them-now/">undermining the success of Operation Warp Speed</a> by distributing only about 18 million doses this year when about <a href="https://www.marketwatch.com/story/officials-plan-to-distribute-6-4-million-covid-19-vaccine-doses-in-december-aiming-for-40-million-doses-by-end-of-year-11606251786" target="_blank">40 million will be available</a> — leaving about 22 million Americans without any immunity during the deadliest period since the pandemic began.', '<b>2. He lost a winnable election and then refused to accept the results — or his own responsibility for losing.</b> Trump lost because he alienated millions who approved of his policies but were tired of chaos. His mocking of Joe Biden’s cognitive struggles offended seniors, and their support for Trump <a href="https://www.cnn.com/election/2020/exit-polls/president/arizona" target=_blank>declined</a> by <a href="https://www.cnn.com/election/2016/results/exit-polls/arizona/president" target=_blank>five points</a> in Arizona and <a href="https://www.cnn.com/election/2016/results/exit-polls/georgia/president" target=_blank>11 points</a> in <a href="https://www.cnn.com/election/2020/exit-polls/president/georgia" target=_blank>Georgia</a> compared with 2016. And after winning <a href="https://www.foxnews.com/politics/voter-analysis-bidens-path-presidency" target=_blank>suburban voters</a> by two points in 2016, he lost them by 10 this year. If he had performed with these groups the way he did four years ago, no amount of real or imagined fraud could have deprived him of a second term.', '<b>1. He discussed imposing martial law at an Oval Office meeting</b>. The suggestion by Michael Flynn that Trump declare martial law and use the military to re-run the election in swing states is insane. That Trump took it seriously enough to <a href="https://www.washingtonpost.com/politics/trump-assembles-a-ragtag-crew-of-conspiracy-minded-allies-in-flailing-bid-to-reverse-election-loss/2020/12/21/d7674cd2-43b2-11eb-b0e4-0f182923a025_story.html">discuss</a> it in the Oval Office is shameful, as are his calls for elected Republicans to overturn the results.', 'Finally, one of the worst things Trump did is not on the list because the results are not yet in: He has barely lifted a finger in Georgia to save Republican control of the Senate. He is so focused on overturning the presidential election that he could very well hand Democrats control of the Senate on Jan. 5 — and with it, unchecked power to reverse his achievements and enact a radical agenda. If that happens, Trump will leave the White House in infamy.', 'That is the worst list of worsts I have compiled in four years. But 2020 also saw some of the greatest accomplishments of Trump’s presidency. Does the good outweigh the bad? <a href="https://www.washingtonpost.com/opinions/2020/12/31/best-things-trump-did-2020/" target=_blank>Here’s my next column, reviewing</a> the 10 best things Trump did in 2020.', '<b>Watch Opinions videos: </b>', '<b>Read more from Marc A. Thiessen:</b>', '<a href="https://www.washingtonpost.com/opinions/2019/12/30/worst-things-trump-did/" target=_blank>The 10 worst things Trump did in 2019</a>', '<a href="https://www.washingtonpost.com/opinions/2019/12/26/best-things-trump-has-done/" target=_blank>The 10 best things Trump did in 2019</a>', '<a href="https://www.washingtonpost.com/opinions/the-10-worst-things-trump-did-in-2018/2019/01/02/f4025456-0eb0-11e9-84fc-d58c33d6c8c7_story.html?tid=lk_inline_manual_24&itid=lk_inline_manual_29">The 10 worst things Trump did in 2018</a>', '<a href="https://www.washingtonpost.com/opinions/the-10-best-things-trump-has-done-in-2018/2018/12/31/a2de64b6-0d1b-11e9-84fc-d58c33d6c8c7_story.html?itid=lk_inline_manual_28">The 10 best things Trump did in 2018</a>', '<a href="https://www.washingtonpost.com/opinions/the-10-worst-things-trump-has-done-in-his-first-year-in-office/2017/12/29/2446d9f6-eca8-11e7-b698-91d4e35920a3_story.html" target=_blank>The 10 worst things Trump did in his first year in office</a>', '<a href="https://www.washingtonpost.com/opinions/the-10-best-things-trump-has-done-in-his-first-year-in-office/2017/12/27/c79ce93c-ea7e-11e7-9f92-10a2203f6c8d_story.html" target=_blank>The 10 best things Trump did in his first year in office</a>'), ()),
        })


    def test_queries(self):
        self._test_queries('wapo/v2/trec-core-2018', count=50, items={
            0: TrecQuery('321', 'Women in Parliaments', 'Pertinent documents will reflect the fact that women continue to be poorly represented in parliaments across the world, and the gap in political power between the sexes is very wide, particularly in the Third World.', 'Pertinent documents relating to this issue will discuss the lack of representation by women, the countries that mandate the inclusion of a certain percentage of women in their legislatures, decreases if any in female representation in legislatures, and those countries in which there is no representation of women.'),
            9: TrecQuery('378', 'euro opposition', 'Identify documents that discuss opposition to the use of the euro, the European currency.', 'A relevant document should include the countries or individuals who oppose the use of the euro and the reason(s) for their opposition to its use.'),
            49: TrecQuery('825', 'ethanol and food prices', 'Does diversion of U.S. corn crops into ethanol for fuel increase food prices?', 'Identify documents that discuss the impact of growing corn with the intention of using it for ethanol fuel on food prices in the U.S.'),
        })
        self._test_queries('wapo/v2/trec-news-2018', count=50, items={
            0: TrecBackgroundLinkingQuery('321', '9171debc316e5e2782e0d2404ca7d09d', 'https://www.washingtonpost.com/news/worldviews/wp/2016/09/01/women-are-half-of-the-world-but-only-22-percent-of-its-parliaments/<url>'),
            9: TrecBackgroundLinkingQuery('378', '3c5be31e-24ab-11e5-b621-b55e495e9b78', 'https://www.washingtonpost.com/world/europe/to-greeks-german-offers-of-help-sound-more-like-a-threat/2015/07/07/3c5be31e-24ab-11e5-b621-b55e495e9b78_story.html<url>'),
            49: TrecBackgroundLinkingQuery('825', 'a1c41a70-35c7-11e3-8a0e-4e2cf80831fc', 'https://www.washingtonpost.com/business/economy/cellulosic-ethanol-once-the-way-of-the-future-is-off-to-a-delayed-boisterous-start/2013/11/08/a1c41a70-35c7-11e3-8a0e-4e2cf80831fc_story.html'),
        })
        self._test_queries('wapo/v2/trec-news-2019', count=60, items={
            0: TrecBackgroundLinkingQuery('826', '96ab542e-6a07-11e6-ba32-5a4bf5aad4fa', 'https://www.washingtonpost.com/sports/nationals/the-minor-leagues-life-in-pro-baseballs-shadowy-corner/2016/08/26/96ab542e-6a07-11e6-ba32-5a4bf5aad4fa_story.html'),
            9: TrecBackgroundLinkingQuery('835', 'c0c4e2d0-628f-11e7-a4f7-af34fc1d9d39', 'https://www.washingtonpost.com/local/social-issues/a-healthy-mystery-over-attending-houses-of-worship/2017/07/07/c0c4e2d0-628f-11e7-a4f7-af34fc1d9d39_story.html'),
            59: TrecBackgroundLinkingQuery('885', '5ae44bfd66a49bcad7b55b29b55d63b6', 'https://www.washingtonpost.com/news/capital-weather-gang/wp/2017/07/14/sun-erupts-to-mark-another-bastille-day-aurora-possible-in-new-england-sunday-night/'),
        })
        self._test_queries('wapo/v3/trec-news-2020', count=50, items={
            0: TrecBackgroundLinkingQuery('886', 'AEQZNZSVT5BGPPUTTJO7SNMOLE', 'https://www.washingtonpost.com/politics/2019/06/05/trump-says-transgender-troops-cant-serve-because-troops-cant-take-any-drugs-hes-wrong-many-ways/'),
            9: TrecBackgroundLinkingQuery('895', '615f0d53ac8f1e05c51bfebf4fdaf0e5', 'https://www.washingtonpost.comhttps://www.washingtonpost.com/news/to-your-health/wp/2015/04/09/sabra-pulls-30000-cases-of-hummus-off-store-shelves-due-to-listeria-fears/'),
            49: TrecBackgroundLinkingQuery('935', 'CCUJNXOJNFEJFBL57GD27EHMWI', 'https://www.washingtonpost.com/news/to-your-health/wp/2018/05/30/this-mock-pandemic-killed-150-million-people-next-time-it-might-not-be-a-drill/'),
        })

    def test_qrels(self):
        self._test_qrels('wapo/v2/trec-core-2018', count=26233, items={
            0: TrecQrel('321', '004c6120d0aa69da29cc045da0562168', 0, '0'),
            9: TrecQrel('321', '01664d72845d37c958a504b9b4085883', 0, '0'),
            26232: TrecQrel('825', 'ff3a25b0-0ba4-11e4-8341-b8072b1e7348', 0, '0'),
        })
        self._test_qrels('wapo/v2/trec-news-2018', count=8508, items={
            0: TrecQrel('321', '00f57310e5c8ec7833d6756ba637332e', 16, '0'),
            9: TrecQrel('321', '09b3167f0d1aa5cfa8be932bb704d75a', 8, '0'),
            8507: TrecQrel('825', 'f66b624ba8689d704872fa776fb52860', 0, '0'),
        })
        self._test_qrels('wapo/v2/trec-news-2019', count=15655, items={
            0: TrecQrel('826', '0154349511cd8c49ab862d6cb0d8f6a8', 2, '0'),
            9: TrecQrel('826', '054be3904bde907f71d684b268e2273d', 0, '0'),
            15654: TrecQrel('885', 'fde80cb0-b4f0-11e2-bbf2-a6f9e9d79e19', 0, '0'),
        })
        self._test_qrels('wapo/v3/trec-news-2020', count=17764, items={
            0: TrecQrel('886', '00183d98-741b-11e5-8248-98e0f5a2e830', 0, '0'),
            9: TrecQrel('886', '03c3c222-0e01-11e4-8c9a-923ecc0c7d23', 0, '0'),
            17763: TrecQrel('935', 'ff0a760128ecdbcc096cafc8cd553255', 0, '0'),
        })


if __name__ == '__main__':
    unittest.main()
