Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2.0 Testing 'stored' timestamp (in test/v2_0/E.Data4.0-SpecialDataTypesAndRules.js) #281

Open
raif-s-naffah opened this issue Jan 17, 2025 · 0 comments

Comments

@raif-s-naffah
Copy link

Hi there,

While running the CTS, sometimes i get a failure like the following:

        "tests": [
            {
                "title": "Special Data Types and Rules (Data 4.0)",
                "name": "Special Data Types and Rules",
                "requirement": [
                    "Data.md#4.0"
                ],
                "log": "",
                "status": "failed",
                "tests": [
                    {
                        "title": "A Timestamp MUST preserve precision to at least milliseconds, 3 decimal points beyond seconds. (Data 4.5.s1.b3, XAPI-00122)",
                        "name": "A Timestamp MUST preserve precision to at least milliseconds, 3 decimal points beyond seconds.",
                        "requirement": [
                            "Data.md#4.5.s1.b3"
                        ],
                        "log": "",
                        "status": "failed",
                        "tests": [
                            {
                                "title": "retrieve statements, test a stored property",
                                "name": "retrieve statements, test a stored property",
...
                                "status": "failed",
                                "error": "AssertionError: expected 0 to be above 0",
                                "tests": []
                            }
                        ]
                    }
                ]
            }
        ]

I believe this is caused by a failed expect in the .js file in the subject line inside the milliChecker function starting on line #470.

The failure seems to be caused by timestamps with a milliseconds field that have 0 as their last decimal digit.

The following code demonstrates the issue:

import moment from 'moment';
import chai from 'chai';

var expect = chai.expect;

var tv = [
    "2025-01-17T00:52:14.590+00:00",
    "2008-09-15T15:53:00.601Z",
    "2025-01-17T00:52:14.591+00:00",
    "2008-09-15T15:53:00.600Z"
];

for (let i = 0; i < tv.length; i++) {
    try {
        var ts = moment(tv[i], moment.ISO_8601);
        expect(ts.isValid()).to.be.true;
        var millis = ts._pf.parsedDateParts[6];
        expect(isNaN(millis)).to.be.false;
        expect(millis % 10).to.be.above(0);
        console.info(`+ TV #${i} (${millis}) pass`);
    } catch (x) {
        console.error(`- TV #${i} (${millis}) fail: ${x.message}`);
        continue
    }
}

It outputs:

- TV #0 (590) fail: expected 0 to be above 0
+ TV #1 (601) pass
+ TV #2 (591) pass
- TV #3 (600) fail: expected 0 to be above 0

Would appreciate it if somebody can confirm if it's indeed a bug or a misunderstanding on my part.

cheers;
rsn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant