Exemple #1
0
    def test_empty_qs(self):
        qs = []
        gf = GapFiller(qs, WEEKLY, self.date_key, DATE_FORMAT_WEEKLY)

        result = gf.fill_gaps()
        expected = []
        self.assertEqual(result, expected)
Exemple #2
0
    def test_multiple_params(self):
        qs = [{
            "date": "2015-01",
            "a": 1,
            "b": 1
        }, {
            "date": "2015-03",
            "a": 3,
            "b": 4
        }]

        gf = GapFiller(qs, MONTHLY, self.date_key, DATE_FORMAT_MONTHLY)

        result = gf.fill_gaps()
        expected = [
            {
                "date": "2015-01",
                "a": 1,
                "b": 1
            },
            {
                "date": "2015-02",
                "a": 0,
                "b": 0
            },
            {
                "date": "2015-03",
                "a": 3,
                "b": 4
            },
        ]
        self.assertEqual(result, expected)
Exemple #3
0
    def test_empty_qs(self):
        qs = []
        gf = GapFiller(qs, WEEKLY, self.date_key, DATE_FORMAT_WEEKLY)

        result = gf.fill_gaps()
        expected = []
        self.assertEqual(result, expected)
Exemple #4
0
    def test_no_gaps(self):
        qs = [
            {
                "date": "2015-01",
                "param": 1
            },
            {
                "date": "2015-02",
                "param": 0
            },
            {
                "date": "2015-03",
                "param": 3
            },
        ]

        gf = GapFiller(qs, WEEKLY, self.date_key, DATE_FORMAT_WEEKLY)

        result = gf.fill_gaps()
        expected = [
            {
                "date": "2015-01",
                "param": 1
            },
            {
                "date": "2015-02",
                "param": 0
            },
            {
                "date": "2015-03",
                "param": 3
            },
        ]
        self.assertEqual(result, expected)
Exemple #5
0
    def test_one_element(self):
        qs = [{"date": "2015-01", "param": 1}]

        gf = GapFiller(qs, MONTHLY, self.date_key, DATE_FORMAT_MONTHLY)

        result = gf.fill_gaps()
        expected = [{"date": "2015-01", "param": 1}]
        self.assertEqual(result, expected)
Exemple #6
0
    def test_one_element(self):
        qs = [
            {'date': "2015-01", 'param': 1}
        ]

        gf = GapFiller(qs, MONTHLY, self.date_key, DATE_FORMAT_MONTHLY)

        result = gf.fill_gaps()
        expected = [
            {'date': "2015-01", 'param': 1}
        ]
        self.assertEqual(result, expected)
Exemple #7
0
    def test_multiple_month_gaps(self):
        qs = [
            {
                "date": "2015-01",
                "param": 1
            },
            {
                "date": "2015-03",
                "param": 3
            },
            {
                "date": "2015-07",
                "param": 7
            },
        ]

        gf = GapFiller(qs, MONTHLY, self.date_key, DATE_FORMAT_MONTHLY)

        result = gf.fill_gaps()
        expected = [
            {
                "date": "2015-01",
                "param": 1
            },
            {
                "date": "2015-02",
                "param": 0
            },
            {
                "date": "2015-03",
                "param": 3
            },
            {
                "date": "2015-04",
                "param": 0
            },
            {
                "date": "2015-05",
                "param": 0
            },
            {
                "date": "2015-06",
                "param": 0
            },
            {
                "date": "2015-07",
                "param": 7
            },
        ]
        self.assertEqual(result, expected)
Exemple #8
0
    def test_multiple_params(self):
        qs = [
            {'date': "2015-01", 'a': 1, 'b': 1},
            {'date': "2015-03", 'a': 3, 'b': 4}
        ]

        gf = GapFiller(qs, MONTHLY, self.date_key, DATE_FORMAT_MONTHLY)

        result = gf.fill_gaps()
        expected = [
            {'date': "2015-01", 'a': 1, 'b': 1},
            {'date': "2015-02", 'a': 0, 'b': 0},
            {'date': "2015-03", 'a': 3, 'b': 4}
        ]
        self.assertEqual(result, expected)
Exemple #9
0
    def test_single_week_gap(self):
        qs = [
            {'date': "2015-01", 'param': 1},
            {'date': "2015-03", 'param': 3}
        ]

        gf = GapFiller(qs, WEEKLY, self.date_key, DATE_FORMAT_WEEKLY)

        result = gf.fill_gaps()
        expected = [
            {'date': "2015-01", 'param': 1},
            {'date': "2015-02", 'param': 0},
            {'date': "2015-03", 'param': 3}
        ]
        self.assertEqual(result, expected)
Exemple #10
0
    def test_multiple_month_gaps(self):
        qs = [
            {'date': "2015-01", 'param': 1},
            {'date': "2015-03", 'param': 3},
            {'date': "2015-07", 'param': 7}
        ]

        gf = GapFiller(qs, MONTHLY, self.date_key, DATE_FORMAT_MONTHLY)

        result = gf.fill_gaps()
        expected = [
            {'date': "2015-01", 'param': 1},
            {'date': "2015-02", 'param': 0},
            {'date': "2015-03", 'param': 3},
            {'date': "2015-04", 'param': 0},
            {'date': "2015-05", 'param': 0},
            {'date': "2015-06", 'param': 0},
            {'date': "2015-07", 'param': 7}
        ]
        self.assertEqual(result, expected)