From 35839ef732b93c01f265fbc68b2f66668f9fd114 Mon Sep 17 00:00:00 2001 From: grasdk Date: Thu, 14 Mar 2024 10:41:41 +0100 Subject: [PATCH] test-fixing --- src/common/Utils.ts | 2 +- .../assets/sidecar/20240107_110258.json | 2 +- .../assets/sidecar/20240121_102400.json | 2 +- .../assets/sidecar/20240128_105420.json | 2 +- .../assets/sidecar/20240128_120909.json | 2 +- .../assets/sidecar/20240128_185808.json | 2 +- .../{bunny_1sec.mp4.json => bunny_1sec.json} | 2 +- .../backend/assets/sidecar/bunny_1sec_v2.json | 16 +++++++++++++++ ...ny_1sec_v3.mp4.json => bunny_1sec_v3.json} | 2 +- .../{metadata.jpg.json => metadata.json} | 0 ...{metadata_v2.jpg.json => metadata_v2.json} | 0 ...{no_metadata.jpg.json => no_metadata.json} | 0 ...tadata_v2.jpg.json => no_metadata_v2.json} | 0 ...tadata_v3.jpg.json => no_metadata_v3.json} | 0 .../model/threading/MetaDataLoader.spec.ts | 20 +++++++++---------- 15 files changed, 34 insertions(+), 18 deletions(-) rename test/backend/assets/sidecar/{bunny_1sec.mp4.json => bunny_1sec.json} (85%) create mode 100644 test/backend/assets/sidecar/bunny_1sec_v2.json rename test/backend/assets/sidecar/{bunny_1sec_v3.mp4.json => bunny_1sec_v3.json} (84%) rename test/backend/assets/sidecar/{metadata.jpg.json => metadata.json} (100%) rename test/backend/assets/sidecar/{metadata_v2.jpg.json => metadata_v2.json} (100%) rename test/backend/assets/sidecar/{no_metadata.jpg.json => no_metadata.json} (100%) rename test/backend/assets/sidecar/{no_metadata_v2.jpg.json => no_metadata_v2.json} (100%) rename test/backend/assets/sidecar/{no_metadata_v3.jpg.json => no_metadata_v3.json} (100%) diff --git a/src/common/Utils.ts b/src/common/Utils.ts index 3d76b241..f707c883 100644 --- a/src/common/Utils.ts +++ b/src/common/Utils.ts @@ -154,7 +154,7 @@ export class Utils { if (UTCTimestamp && timestamp) { //offset in minutes is the difference between gps timestamp and given timestamp //to calculate this correctly, we have to work with the same offset - const offsetMinutes = (timestampToMS(timestamp, '+00:00')- timestampToMS(UTCTimestamp, '+00:00')) / 1000 / 60; + const offsetMinutes = (Utils.timestampToMS(timestamp, '+00:00')- Utils.timestampToMS(UTCTimestamp, '+00:00')) / 1000 / 60; return Utils.getOffsetString(offsetMinutes); } else { return undefined; diff --git a/test/backend/assets/sidecar/20240107_110258.json b/test/backend/assets/sidecar/20240107_110258.json index 537f61d2..6052ac14 100644 --- a/test/backend/assets/sidecar/20240107_110258.json +++ b/test/backend/assets/sidecar/20240107_110258.json @@ -7,7 +7,7 @@ "make": "samsung", "model": "SM-A715F" }, - "creationDate": 1704621779177, + "creationDate": 1704625379177, "creationDateOffset": "+01:00", "fileSize": 15126, "size": { diff --git a/test/backend/assets/sidecar/20240121_102400.json b/test/backend/assets/sidecar/20240121_102400.json index 79005c08..b3579d2b 100644 --- a/test/backend/assets/sidecar/20240121_102400.json +++ b/test/backend/assets/sidecar/20240121_102400.json @@ -8,7 +8,7 @@ "make": "NIKON CORPORATION", "model": "NIKON Z 30" }, - "creationDate": 1705829040930, + "creationDate": 1705832640930, "creationDateOffset": "+01:00", "fileSize": 25556, "size": { diff --git a/test/backend/assets/sidecar/20240128_105420.json b/test/backend/assets/sidecar/20240128_105420.json index 977a736f..40587ac4 100644 --- a/test/backend/assets/sidecar/20240128_105420.json +++ b/test/backend/assets/sidecar/20240128_105420.json @@ -1,6 +1,6 @@ { "bitRate": 184871, - "creationDate": 1706432060000, + "creationDate": 1706435660000, "duration": 1000, "fileSize": 23132, "size": { diff --git a/test/backend/assets/sidecar/20240128_120909.json b/test/backend/assets/sidecar/20240128_120909.json index c13e4602..c8e2ddd0 100644 --- a/test/backend/assets/sidecar/20240128_120909.json +++ b/test/backend/assets/sidecar/20240128_120909.json @@ -1,6 +1,6 @@ { "bitRate": 183168, - "creationDate": 1706436545000, + "creationDate": 1706440145000, "duration": 1000, "fileSize": 22896, "size": { diff --git a/test/backend/assets/sidecar/20240128_185808.json b/test/backend/assets/sidecar/20240128_185808.json index 3ac57a61..7afeb9d9 100644 --- a/test/backend/assets/sidecar/20240128_185808.json +++ b/test/backend/assets/sidecar/20240128_185808.json @@ -8,7 +8,7 @@ "make": "NIKON CORPORATION", "model": "NIKON Z 30" }, - "creationDate": 1706464688660, + "creationDate": 1706468288660, "creationDateOffset": "+01:00", "fileSize": 47059, "size": { diff --git a/test/backend/assets/sidecar/bunny_1sec.mp4.json b/test/backend/assets/sidecar/bunny_1sec.json similarity index 85% rename from test/backend/assets/sidecar/bunny_1sec.mp4.json rename to test/backend/assets/sidecar/bunny_1sec.json index 29d2cb74..eec9a09a 100644 --- a/test/backend/assets/sidecar/bunny_1sec.mp4.json +++ b/test/backend/assets/sidecar/bunny_1sec.json @@ -5,7 +5,7 @@ }, "bitRate": 1794127, "duration": 290, - "creationDate": 1709052692000, + "creationDate": 1542482851000, "fileSize": 65073, "fps": 40000, "keywords": [ diff --git a/test/backend/assets/sidecar/bunny_1sec_v2.json b/test/backend/assets/sidecar/bunny_1sec_v2.json new file mode 100644 index 00000000..eec9a09a --- /dev/null +++ b/test/backend/assets/sidecar/bunny_1sec_v2.json @@ -0,0 +1,16 @@ +{ + "size": { + "width": 640, + "height": 360 + }, + "bitRate": 1794127, + "duration": 290, + "creationDate": 1542482851000, + "fileSize": 65073, + "fps": 40000, + "keywords": [ + "rabbit", + "test" + ], + "rating": 4 +} diff --git a/test/backend/assets/sidecar/bunny_1sec_v3.mp4.json b/test/backend/assets/sidecar/bunny_1sec_v3.json similarity index 84% rename from test/backend/assets/sidecar/bunny_1sec_v3.mp4.json rename to test/backend/assets/sidecar/bunny_1sec_v3.json index 8cd3db65..d3abbdba 100644 --- a/test/backend/assets/sidecar/bunny_1sec_v3.mp4.json +++ b/test/backend/assets/sidecar/bunny_1sec_v3.json @@ -5,7 +5,7 @@ }, "bitRate": 1794127, "duration": 290, - "creationDate": 1709052692000, + "creationDate": 1542482851000, "fileSize": 65073, "fps": 40000, "keywords": [ diff --git a/test/backend/assets/sidecar/metadata.jpg.json b/test/backend/assets/sidecar/metadata.json similarity index 100% rename from test/backend/assets/sidecar/metadata.jpg.json rename to test/backend/assets/sidecar/metadata.json diff --git a/test/backend/assets/sidecar/metadata_v2.jpg.json b/test/backend/assets/sidecar/metadata_v2.json similarity index 100% rename from test/backend/assets/sidecar/metadata_v2.jpg.json rename to test/backend/assets/sidecar/metadata_v2.json diff --git a/test/backend/assets/sidecar/no_metadata.jpg.json b/test/backend/assets/sidecar/no_metadata.json similarity index 100% rename from test/backend/assets/sidecar/no_metadata.jpg.json rename to test/backend/assets/sidecar/no_metadata.json diff --git a/test/backend/assets/sidecar/no_metadata_v2.jpg.json b/test/backend/assets/sidecar/no_metadata_v2.json similarity index 100% rename from test/backend/assets/sidecar/no_metadata_v2.jpg.json rename to test/backend/assets/sidecar/no_metadata_v2.json diff --git a/test/backend/assets/sidecar/no_metadata_v3.jpg.json b/test/backend/assets/sidecar/no_metadata_v3.json similarity index 100% rename from test/backend/assets/sidecar/no_metadata_v3.jpg.json rename to test/backend/assets/sidecar/no_metadata_v3.json diff --git a/test/backend/unit/model/threading/MetaDataLoader.spec.ts b/test/backend/unit/model/threading/MetaDataLoader.spec.ts index 48a62827..9b62eb58 100644 --- a/test/backend/unit/model/threading/MetaDataLoader.spec.ts +++ b/test/backend/unit/model/threading/MetaDataLoader.spec.ts @@ -102,61 +102,61 @@ describe('MetadataLoader', () => { }); it('should load sidecar file with file extension for video', async () => { const data = await MetadataLoader.loadVideoMetadata(path.join(__dirname, '/../../../assets/sidecar/bunny_1sec.mp4')); - const expected = require(path.join(__dirname, '/../../../assets/sidecar/bunny_1sec.mp4.json')); + const expected = require(path.join(__dirname, '/../../../assets/sidecar/bunny_1sec.json')); expect(Utils.clone(data)).to.be.deep.equal(expected); }); it('should load sidecar file without file extension for video', async () => { const data = await MetadataLoader.loadVideoMetadata(path.join(__dirname, '/../../../assets/sidecar/bunny_1sec_v2.mp4')); - const expected = require(path.join(__dirname, '/../../../assets/sidecar/bunny_1sec.mp4.json'));//sidecar "bunny_1sec_v2.xmp" is identical to "bunny_1sec.mp4.xmp" so we expect the same result + const expected = require(path.join(__dirname, '/../../../assets/sidecar/bunny_1sec.json'));//sidecar "bunny_1sec_v2.xmp" is identical to "bunny_1sec.mp4.xmp" so we expect the same result expect(Utils.clone(data)).to.be.deep.equal(expected); }); it('should retrieve both keywords from sidecar file for video', async () => { const data = await MetadataLoader.loadVideoMetadata(path.join(__dirname, '/../../../assets/sidecar/bunny_1sec.mp4')); - const expected = require(path.join(__dirname, '/../../../assets/sidecar/bunny_1sec.mp4.json')); + const expected = require(path.join(__dirname, '/../../../assets/sidecar/bunny_1sec.json')); expect(Utils.clone(data)).to.be.deep.equal(expected); }); it('should retrieve one keyword from sidecar file for video', async () => { const data = await MetadataLoader.loadVideoMetadata(path.join(__dirname, '/../../../assets/sidecar/bunny_1sec_v3.mp4')); - const expected = require(path.join(__dirname, '/../../../assets/sidecar/bunny_1sec_v3.mp4.json')); + const expected = require(path.join(__dirname, '/../../../assets/sidecar/bunny_1sec_v3.json')); expect(Utils.clone(data)).to.be.deep.equal(expected); }); it('should load sidecar file with file extension for photo', async () => { const data = await MetadataLoader.loadPhotoMetadata(path.join(__dirname, '/../../../assets/sidecar/no_metadata.jpg')); - const expected = require(path.join(__dirname, '/../../../assets/sidecar/no_metadata.jpg.json')); + const expected = require(path.join(__dirname, '/../../../assets/sidecar/no_metadata.json')); expect(Utils.clone(data)).to.be.deep.equal(expected); }); it('should load sidecar file without file extension for photo', async () => { const data = await MetadataLoader.loadPhotoMetadata(path.join(__dirname, '/../../../assets/sidecar/no_metadata_v2.jpg')); - const expected = require(path.join(__dirname, '/../../../assets/sidecar/no_metadata_v2.jpg.json')); + const expected = require(path.join(__dirname, '/../../../assets/sidecar/no_metadata_v2.json')); expect(Utils.clone(data)).to.be.deep.equal(expected); }); it('should retrieve both keywords from sidecar file for photo', async () => { const data = await MetadataLoader.loadPhotoMetadata(path.join(__dirname, '/../../../assets/sidecar/no_metadata.jpg')); - const expected = require(path.join(__dirname, '/../../../assets/sidecar/no_metadata.jpg.json')); + const expected = require(path.join(__dirname, '/../../../assets/sidecar/no_metadata.json')); expect(Utils.clone(data)).to.be.deep.equal(expected); }); it('should retrieve one keyword from sidecar file for photo', async () => { const data = await MetadataLoader.loadPhotoMetadata(path.join(__dirname, '/../../../assets/sidecar/no_metadata_v3.jpg')); - const expected = require(path.join(__dirname, '/../../../assets/sidecar/no_metadata_v3.jpg.json')); + const expected = require(path.join(__dirname, '/../../../assets/sidecar/no_metadata_v3.json')); expect(Utils.clone(data)).to.be.deep.equal(expected); }); it('should read keywords from photo without sidecar file', async () => { const data = await MetadataLoader.loadPhotoMetadata(path.join(__dirname, '/../../../assets/sidecar/metadata.jpg')); - const expected = require(path.join(__dirname, '/../../../assets/sidecar/metadata.jpg.json')); + const expected = require(path.join(__dirname, '/../../../assets/sidecar/metadata.json')); expect(Utils.clone(data)).to.be.deep.equal(expected); }); it('should merge keywords from photo with keywords from sidecar', async () => { const data = await MetadataLoader.loadPhotoMetadata(path.join(__dirname, '/../../../assets/sidecar/metadata_v2.jpg')); - const expected = require(path.join(__dirname, '/../../../assets/sidecar/metadata_v2.jpg.json')); //"metadata_v2.jpg" is identical to "metadata.jpg" and "metadata_v2.xmp" contains 2 different keywords + const expected = require(path.join(__dirname, '/../../../assets/sidecar/metadata_v2.json')); //"metadata_v2.jpg" is identical to "metadata.jpg" and "metadata_v2.xmp" contains 2 different keywords expect(Utils.clone(data)).to.be.deep.equal(expected); });