Skip to content

Commit

Permalink
Tidy nitf test fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
bryophyta committed Dec 23, 2024
1 parent df86c99 commit f6de1a7
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 293 deletions.
254 changes: 0 additions & 254 deletions poller-lambdas/src/pollers/AP/fixtures/fixture.1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,257 +5,3 @@ export const fixture1 = `
</p><p>Copyright Business Wire 2024.
</p><p>PUB: 12/05/2024 06:00 AM/DISC: 12/05/2024 06:01 AM</p><p>http://www.businesswire.com/news/home/20241205994409/en</p></block></body.content></body></nitf>
`;

// const feedJson = {
// item: {
// uri: 'https://api.ap.org/media/v/content/5da975d19a5546368f13900c618102c1?qt=JesjMKn1BleS&et=0a2aza0c0',
// altids: {
// itemid: '5da975d19a5546368f13900c618102c1',
// etag: '5da975d19a5546368f13900c618102c1_0a2aza0c0',
// friendlykey: '2408080701031997',
// },
// version: 0,
// type: 'text',
// versioncreated: '2024-12-05T11:01:08Z',
// firstcreated: '2024-12-05T11:00:00Z',
// pubstatus: 'usable',
// signals: ['newscontent'],
// headline:
// 'Shop Holiday Deals Now: BJ’s Wholesale Club Offers Unbeatable Savings on Holiday Gifts Through December 24th',
// datelinelocation: {
// city: 'Marlborough',
// countryname: 'United States',
// countryareaname: 'Massachusetts',
// geometry_geojson: { coordinates: [-71.55229, 42.34593], type: 'Point' },
// },
// copyrightnotice: 'Copyright Business Wire 2024.',
// usageterms: [
// 'This content is intended for editorial use only. For other uses, additional clearances may be required.',
// ],
// provider: 'Business Wire',
// infosource: [
// {
// name: 'Business Wire',
// type: 'ThirdParty',
// url: 'http://www.businesswire.com',
// },
// ],
// associations: {
// '1': {
// uri: 'https://api.ap.org/media/v/content/5b470e5a3f4026f5b40feb49c76459f6?qt=JesjMKn1BleS&et=0a1aza3c0&ai=5da975d19a5546368f13900c618102c1',
// altids: {
// itemid: '5b470e5a3f4026f5b40feb49c76459f6',
// etag: '5b470e5a3f4026f5b40feb49c76459f6_0a1aza3c0',
// },
// version: 0,
// type: 'picture',
// headline:
// 'Shop Holiday Deals Now: BJ’s Wholesale Club Offers Unbeatable Savings on Holiday Gifts Through December 24th',
// },
// '2': {
// uri: 'https://api.ap.org/media/v/content/895245b957d893640784e3385e03e217?qt=JesjMKn1BleS&et=0a1aza3c0&ai=5da975d19a5546368f13900c618102c1',
// altids: {
// itemid: '895245b957d893640784e3385e03e217',
// etag: '895245b957d893640784e3385e03e217_0a1aza3c0',
// },
// version: 0,
// type: 'picture',
// headline:
// 'Shop Holiday Deals Now: BJ’s Wholesale Club Offers Unbeatable Savings on Holiday Gifts Through December 24th',
// },
// '3': {
// uri: 'https://api.ap.org/media/v/content/4cb197fe97e4bf5edf0b44f7367bb55e?qt=JesjMKn1BleS&et=0a1aza3c0&ai=5da975d19a5546368f13900c618102c1',
// altids: {
// itemid: '4cb197fe97e4bf5edf0b44f7367bb55e',
// etag: '4cb197fe97e4bf5edf0b44f7367bb55e_0a1aza3c0',
// },
// version: 0,
// type: 'picture',
// headline:
// 'Shop Holiday Deals Now: BJ’s Wholesale Club Offers Unbeatable Savings on Holiday Gifts Through December 24th',
// },
// '4': {
// uri: 'https://api.ap.org/media/v/content/530c2ce1c8dda81ffad88d514e157599?qt=JesjMKn1BleS&et=0a1aza3c0&ai=5da975d19a5546368f13900c618102c1',
// altids: {
// itemid: '530c2ce1c8dda81ffad88d514e157599',
// etag: '530c2ce1c8dda81ffad88d514e157599_0a1aza3c0',
// },
// version: 0,
// type: 'picture',
// headline:
// 'Shop Holiday Deals Now: BJ’s Wholesale Club Offers Unbeatable Savings on Holiday Gifts Through December 24th',
// },
// '5': {
// uri: 'https://api.ap.org/media/v/content/d84537c40641f7535b6dc58f8bffae11?qt=JesjMKn1BleS&et=0a1aza3c0&ai=5da975d19a5546368f13900c618102c1',
// altids: {
// itemid: 'd84537c40641f7535b6dc58f8bffae11',
// etag: 'd84537c40641f7535b6dc58f8bffae11_0a1aza3c0',
// },
// version: 0,
// type: 'picture',
// headline:
// 'Shop Holiday Deals Now: BJ’s Wholesale Club Offers Unbeatable Savings on Holiday Gifts Through December 24th',
// },
// '6': {
// uri: 'https://api.ap.org/media/v/content/e0f825d96f21af0e46405ef218fea464?qt=JesjMKn1BleS&et=0a1aza3c0&ai=5da975d19a5546368f13900c618102c1',
// altids: {
// itemid: 'e0f825d96f21af0e46405ef218fea464',
// etag: 'e0f825d96f21af0e46405ef218fea464_0a1aza3c0',
// },
// version: 0,
// type: 'picture',
// headline:
// 'Shop Holiday Deals Now: BJ’s Wholesale Club Offers Unbeatable Savings on Holiday Gifts Through December 24th',
// },
// '7': {
// uri: 'https://api.ap.org/media/v/content/77eab6b9fdf9e1dda820d64c2ff4e034?qt=JesjMKn1BleS&et=0a1aza3c0&ai=5da975d19a5546368f13900c618102c1',
// altids: {
// itemid: '77eab6b9fdf9e1dda820d64c2ff4e034',
// etag: '77eab6b9fdf9e1dda820d64c2ff4e034_0a1aza3c0',
// },
// version: 0,
// type: 'picture',
// headline:
// 'Shop Holiday Deals Now: BJ’s Wholesale Club Offers Unbeatable Savings on Holiday Gifts Through December 24th',
// },
// '8': {
// uri: 'https://api.ap.org/media/v/content/792178894001a8f68b5d51ae27948503?qt=JesjMKn1BleS&et=0a1aza3c0&ai=5da975d19a5546368f13900c618102c1',
// altids: {
// itemid: '792178894001a8f68b5d51ae27948503',
// etag: '792178894001a8f68b5d51ae27948503_0a1aza3c0',
// },
// version: 0,
// type: 'picture',
// headline:
// 'Shop Holiday Deals Now: BJ’s Wholesale Club Offers Unbeatable Savings on Holiday Gifts Through December 24th',
// },
// '9': {
// uri: 'https://api.ap.org/media/v/content/fd763a071bc5f6d22f97299b8638a69f?qt=JesjMKn1BleS&et=0a1aza3c0&ai=5da975d19a5546368f13900c618102c1',
// altids: {
// itemid: 'fd763a071bc5f6d22f97299b8638a69f',
// etag: 'fd763a071bc5f6d22f97299b8638a69f_0a1aza3c0',
// },
// version: 0,
// type: 'picture',
// headline:
// 'Shop Holiday Deals Now: BJ’s Wholesale Club Offers Unbeatable Savings on Holiday Gifts Through December 24th',
// },
// '10': {
// uri: 'https://api.ap.org/media/v/content/476ceb4466cf036c4bc12899ef274283?qt=JesjMKn1BleS&et=0a1aza3c0&ai=5da975d19a5546368f13900c618102c1',
// altids: {
// itemid: '476ceb4466cf036c4bc12899ef274283',
// etag: '476ceb4466cf036c4bc12899ef274283_0a1aza3c0',
// },
// version: 0,
// type: 'picture',
// headline:
// 'Shop Holiday Deals Now: BJ’s Wholesale Club Offers Unbeatable Savings on Holiday Gifts Through December 24th',
// },
// '11': {
// uri: 'https://api.ap.org/media/v/content/281303bb0d7d589f29eb798cb0ed7dce?qt=JesjMKn1BleS&et=0a1aza3c0&ai=5da975d19a5546368f13900c618102c1',
// altids: {
// itemid: '281303bb0d7d589f29eb798cb0ed7dce',
// etag: '281303bb0d7d589f29eb798cb0ed7dce_0a1aza3c0',
// },
// version: 0,
// type: 'picture',
// headline:
// 'Shop Holiday Deals Now: BJ’s Wholesale Club Offers Unbeatable Savings on Holiday Gifts Through December 24th',
// },
// '12': {
// uri: 'https://api.ap.org/media/v/content/db94012557ae703b2590f9b7b3999fe3?qt=JesjMKn1BleS&et=0a1aza3c0&ai=5da975d19a5546368f13900c618102c1',
// altids: {
// itemid: 'db94012557ae703b2590f9b7b3999fe3',
// etag: 'db94012557ae703b2590f9b7b3999fe3_0a1aza3c0',
// },
// version: 0,
// type: 'picture',
// headline:
// 'Shop Holiday Deals Now: BJ’s Wholesale Club Offers Unbeatable Savings on Holiday Gifts Through December 24th',
// },
// },
// renditions: {
// nitf: {
// title: 'NITF Story Download',
// rel: 'Story',
// format: 'IIM',
// type: 'text',
// mimetype: 'text/xml',
// fileextension: 'xml',
// words: 743,
// contentid: '63c01905a8fb493f93e062750b878f01',
// href: 'https://api.ap.org/media/v/content/5da975d19a5546368f13900c618102c1/download?type=text&format=NITF&rid=63c01905a8fb493f93e062750b878f01&cid=0&fid=6b193ac5663a4d6fa50fd7deb5e85919&trf=&qt=JesjMKn1BleS&dt=UcXbYZTl7t&et=0a2aza0c0',
// mediafilterid: '2',
// },
// },
// },
// };

// const fingerpostVersion = `
// Shop Holiday Deals Now- BJ’s Wholesale Club Offers Unbeatable Savings on Holiday Gifts Through December 24th

// Shop Holiday Deals Now: BJ’s Wholesale Club Offers Unbeatable Savings on Holiday Gifts Through December 24th
// The Associated Press
// MARLBOROUGH, Mass.--(BUSINESS WIRE)--Dec 5, 2024--

// BJ's Wholesale Club (NYSE: BJ), a leading operator of membership warehouse clubs, announced its December Gifting Event running from December 6 - December 24, 2024. The event offers members exceptional deals on toys, video games, kitchen appliances, gift baskets, electronics and more, making it easy for shoppers to cross the last few names off their list in one simple stop. Additionally, BJ’s One® Mastercard® cardholders can earn Double Rewards (up to 10% back) on eligible items.

// This press release features multimedia. View the full release here: https://www.businesswire.com/news/home/20241205994409/en/

// Hatchimals Alive Mystery Hatch Toy (Photo: Business Wire)

// “We know that this can be a busy and costly time of year for families,” said Tim Morningstar, Chief Membership Officer, BJ’s Wholesale Club. “BJ’s provides members with convenient one-stop shopping and unbeatable value on the season’s most in-demand gifts. The December Gifting Event gives our members an opportunity to take advantage of exclusive deals and help those last-minute holiday shoppers.”

// The December Gifting Event includes up to 30% off on some of the year’s most wish list-worthy toy brands, such as Bluey, Hot Wheels, Barbie and more. Top toy deals include:
// Hatchimals Alive Mystery Hatch Toy, $39.99 after $15 savings Bluey Family Celebration Home and Backyard Fun, $39.99 after $10 savings Barbie Hugs 'N' Horses Playset, $44.99 after $5 savings Hot Wheels Tunnel Twist Car Wash, $18.99 after $4 savings Can-Am Renegade ATV Ride-on, $174.99 after $75 savings Bestway Wonderzone Kids Inflatable Mega Bounce House, $169.99 after $30 savings
// In addition to toys, there will be incredible deals on items across categories that will satisfy even the most hard-to-shop-for people on your list, including:
// Sony PlayStation 5 Console - Fortnite Cobalt Star Bundle, $419.99 after $5 savings Cinema Pop Up Movie Theater Kit V2, $89.99 after $60 savings HP 15.6" Touchscreen Laptop, Intel Core Ultra 7 155H, 16GB Memory, 512GB SSD, $579.99 after $220 savings Samsung 65" Q80DD QLED 4K Smart TV, $897.99 after $702 savings Samsung Galaxy 11" Tab A9+ Tablet, 64GB Bundle with Bonus Book Cover, $149.99 after $70 savings Arcade1Up Infinity Game Board, $399.99 after $100 savings
// Non-cardholders can apply for a BJ’s One® Mastercard® ahead of the savings event by visiting the member services desk at their local club or BJs.com/BJsone.

// BJ’s members can choose from several time-saving options whether shopping online or in-club. Curbside pickup, in-club pickup, same-day delivery and standard delivery are available on BJs.com, while members shopping in-club can use ExpressPay through the BJ’s mobile app to scan products as they shop and skip the checkout lines.

// To learn more about BJ’s Wholesale Club, shoppers can visit BJs.com. Full details about the BJ’s December Savings Event and BJ’s One® Mastercard® promotion can be found at BJs.com/deals.

// About BJ's Wholesale Club Holdings, Inc.

// BJ’s Wholesale Club Holdings, Inc. (NYSE: BJ) is a leading operator of membership warehouse clubs focused on delivering significant value to its members and serving a shared purpose: “We take care of the families who depend on us.” The company provides a wide assortment of fresh foods, produce, a full-service deli, fresh bakery, household essentials and gas. In addition, BJ’s offers the latest technology, home decor, small appliances, apparel, seasonal items and more to deliver unbeatable value to smart-saving families. Headquartered in Marlborough, Massachusetts, the company pioneered the warehouse club model in New England in 1984 and currently operates 247 clubs and 182 BJ's Gas® locations in 20 states. For more information, please visit us at www.BJs.com or on Facebook, and Instagram.

// View source version on businesswire.com:https://www.businesswire.com/news/home/20241205994409/en/

// CONTACT: Media:

// Kirk Saville

// Head of Corporate Communications

// BJ’s Wholesale Club

// [email protected]

// 774-512-5597Briana Keene

// Sr. Manager, External Communications

// BJ’s Wholesale Club

// [email protected]

// 774-512-6802

// KEYWORD: UNITED STATES NORTH AMERICA MASSACHUSETTS

// INDUSTRY KEYWORD: TECHNOLOGY DISCOUNT/VARIETY DEPARTMENT STORES TOYS SPECIALTY HOME GOODS RETAIL CONSUMER ELECTRONICS ONLINE RETAIL

// SOURCE: BJ's Wholesale Club

// Copyright Business Wire 2024.

// PUB: 12/05/2024 06:00 AM/DISC: 12/05/2024 06:01 AM

// http://www.businesswire.com/news/home/20241205994409/en

// Keyword MA-BJS-WHOLESALE-CLUB
// Reference 0
// Filename 05114884 Source ID Seq. No. 05114884 Take No.
// Source APAPIUS Cat. Code f Priority 4 Words 743
// Time 11:09 Date 05 / 12 / 2024 w4apus`;
37 changes: 37 additions & 0 deletions poller-lambdas/src/pollers/AP/fixtures/fixture.2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
export const fixture2 = `
<?xml version="1.0" encoding="utf-8"?>
<nitf xmlns="http://iptc.org/std/NITF/2006-10-18/" version="-//IPTC//DTD NITF 3.4//EN"
change.date="October 18, 2006" change.time="19:30">
<head>
<docdata>
<doc-id regsrc="AP" />
<date.issue norm="20241129T170043Z" />
<ed-msg info="Eds: UPDATES: with Browns injuries." />
<doc.copyright holder="AP" year="2024" />
<identified-content>
<classifier type="apcategorycode" value="s" />
</identified-content>
</docdata>
</head>
<body>
<body.head>
<hedline>
<hl1 id="headline">Ex-teammates Jerry Jeudy, Courtland Sutton are on hot streaks as Browns visit Broncos Monday night</hl1>
</hedline>
<byline>By The Associated Press</byline>
<distributor>The Associated Press</distributor>
<abstract>The Cleveland Browns are seeking just their second victory in Denver in their past nine tries when they visit the Broncos on Monday night. Both teams are coming off big wins and this game marks the return of former Broncos wide receiver Jerry Jeudy, who was traded to Cleveland in the offseason. Jeudy is on a roll with 19 catches over the past three games as he is developing good chemistry with Jaemis Winston. Broncos receiver Courtland Sutton is also on a hot streak. He is coming off his first career game with multiple touchdowns and has had at least 70 receiving yards for five consecutive games.</abstract>
</body.head>
<body.content>
<block>
<p>Cleveland (3-8) at Denver (7-5)</p>
<hl2>Browns player to watch</hl2>
<p>WR Jerry Jeudy. He returns to Denver,</p>
<hl2>Broncos player to watch</hl2>
<p>WR Courtland Sutton. He has come on strong with five consecutive</p>
<p>Intentionally including a second p tag here.</p>
</block>
</body.content>
</body>
</nitf>
`;
41 changes: 2 additions & 39 deletions poller-lambdas/src/pollers/AP/parseNiftContent.test.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,8 @@
import { parse } from 'node-html-parser';
import { fixture1 } from './fixtures/fixture.1';
import { fixture2 } from './fixtures/fixture.2';
import { nitfBlockToHtml, parseNitfContent } from './parseNitfContent';

const sample = `
<?xml version="1.0" encoding="utf-8"?>
<nitf xmlns="http://iptc.org/std/NITF/2006-10-18/" version="-//IPTC//DTD NITF 3.4//EN"
change.date="October 18, 2006" change.time="19:30">
<head>
<docdata>
<doc-id regsrc="AP" />
<date.issue norm="20241129T170043Z" />
<ed-msg info="Eds: UPDATES: with Browns injuries." />
<doc.copyright holder="AP" year="2024" />
<identified-content>
<classifier type="apcategorycode" value="s" />
</identified-content>
</docdata>
</head>
<body>
<body.head>
<hedline>
<hl1 id="headline">Ex-teammates Jerry Jeudy, Courtland Sutton are on hot streaks as Browns visit Broncos Monday night</hl1>
</hedline>
<byline>By The Associated Press</byline>
<distributor>The Associated Press</distributor>
<abstract>The Cleveland Browns are seeking just their second victory in Denver in their past nine tries when they visit the Broncos on Monday night. Both teams are coming off big wins and this game marks the return of former Broncos wide receiver Jerry Jeudy, who was traded to Cleveland in the offseason. Jeudy is on a roll with 19 catches over the past three games as he is developing good chemistry with Jaemis Winston. Broncos receiver Courtland Sutton is also on a hot streak. He is coming off his first career game with multiple touchdowns and has had at least 70 receiving yards for five consecutive games.</abstract>
</body.head>
<body.content>
<block>
<p>Cleveland (3-8) at Denver (7-5)</p>
<hl2>Browns player to watch</hl2>
<p>WR Jerry Jeudy. He returns to Denver,</p>
<hl2>Broncos player to watch</hl2>
<p>WR Courtland Sutton. He has come on strong with five consecutive</p>
<p>Intentionally including a second p tag here.</p>
</block>
</body.content>
</body>
</nitf>
`;

describe('nitfToHtml', () => {
it('should convert hl2 tags to h2 tags', () => {
const originalObject = parse('<block><hl2>hello world</hl2></block>');
Expand Down Expand Up @@ -94,7 +57,7 @@ describe('nitfToHtml', () => {

describe('parseNitfContent', () => {
it('should parse the content correctly', () => {
const result = parseNitfContent(sample);
const result = parseNitfContent(fixture2);

expect(result.abstract).toBe(
`The Cleveland Browns are seeking just their second victory in Denver in their past nine tries when they visit the Broncos on Monday night. Both teams are coming off big wins and this game marks the return of former Broncos wide receiver Jerry Jeudy, who was traded to Cleveland in the offseason. Jeudy is on a roll with 19 catches over the past three games as he is developing good chemistry with Jaemis Winston. Broncos receiver Courtland Sutton is also on a hot streak. He is coming off his first career game with multiple touchdowns and has had at least 70 receiving yards for five consecutive games.`,
Expand Down

0 comments on commit f6de1a7

Please sign in to comment.