1#!/usr/bin/env python3
 2
 3"""Test a few functions from the `common` module."""
 4
 5import numpy
 6import logging
 7
 8from chart.products.sf00 import sf
 9from chart.products.eps import gpfs
10from chart.products.eps import isp
11
12logger = logging.getLogger()
13
14def test_header_size():
15    """Make sure header size is 64 bytes."""
16    header = numpy.zeros((1,), dtype=sf.sf_header1_desc)
17    assert header.itemsize == 64
18
19
20def test_gentime_datetime():
21    """Convert some gentimes to datetimes."""
22    for gt in ('20070225085705Z', '20000101000000Z'):
23        dt = gpfs.gentime_to_datetime(gt)
24        ngt = gpfs.datetime_to_gentime(dt)
25        logger.info(str(gt) + str(ngt))
26        assert gt == ngt
27
28
29def test_ccsds_conversion():
30    """Convert some gentimes to ISP times."""
31    for gt in ('20070225085705Z', '20000101000000Z'):
32        cc = isp.gentime_to_ccsds(gt)
33        dt = isp.ccsds_to_datetime(cc)
34        ngt = gpfs.datetime_to_gentime(dt)
35        assert gt == ngt