Beispiel #1
0
    def test_ajax_call(self):
        """
        Check the AJAX call itself.
        """
        ts1 = datetime.datetime(year=2014, month=2, day=1)
        ts2 = datetime.datetime(year=2014, month=2, day=2)
        ts3 = datetime.datetime(year=2014, month=3, day=2)

        original_hits = [
            Hits(ts=ts1, hits=5, app_id=2),
            Hits(ts=ts2, hits=6, app_id=2),
            Hits(ts=ts3, hits=8, app_id=2)
        ]

        s = sqla.db()
        for h in original_hits:
            s.add(h)
        s.commit()

        ret = self.flask_app.get("/ajax/hits/2?granularity=monthly")
        assert ret.status_code == 200

        resp = json.loads(ret.data)

        h1 = resp[0]
        h2 = resp[1]

        print resp

        assert h1["hits"] == 11
        assert h2["hits"] == 8
Beispiel #2
0
    def test_ajax_call(self):
        """
        Check the AJAX call itself.
        """
        ts1 = datetime.datetime(year=2014, month=2, day=1)
        ts2 = datetime.datetime(year=2014, month=2, day=2)
        ts3 = datetime.datetime(year=2014, month=3, day=2)

        original_hits = [
            Hits(ts=ts1, hits=5, app_id=2),
            Hits(ts=ts2, hits=6, app_id=2),
            Hits(ts=ts3, hits=8, app_id=2)
        ]

        s = sqla.db()
        for h in original_hits:
            s.add(h)
        s.commit()

        ret = self.flask_app.get("/ajax/hits/2?granularity=monthly")
        assert ret.status_code == 200

        resp = json.loads(ret.data)

        h1 = resp[0]
        h2 = resp[1]

        print resp

        assert h1["hits"] == 11
        assert h2["hits"] == 8
Beispiel #3
0
    def test_apps_add(self):
        """
        Test the add apps page
        """
        ret = self.flask_app.get("/test/addapp")
        assert ret.status_code == 200
        assert "submit" in ret.data

        ret = self.flask_app.post("/test/addapp",
                                  data=dict(name="Test App",
                                            description="Description"))
        assert ret.status_code == 302

        # Check that the hit was added successfully.
        s = sqla.db()
        apps = s.query(Application).all()
        names = [app.name for app in apps]
        assert "Test App" in names
Beispiel #4
0
    def test_apps_add(self):
        """
        Test the add apps page
        """
        ret = self.flask_app.get("/test/addapp")
        assert ret.status_code == 200
        assert "submit" in ret.data

        ret = self.flask_app.post("/test/addapp", data=dict(
            name="Test App",
            description="Description"
        ))
        assert ret.status_code == 302

        # Check that the hit was added successfully.
        s = sqla.db()
        apps = s.query(Application).all()
        names = [app.name for app in apps]
        assert "Test App" in names
Beispiel #5
0
    def test_hits_add(self):
        """
        Test the add hits page
        """
        ret = self.flask_app.get("/test/addhits")
        assert ret.status_code == 200
        assert "submit" in ret.data

        ret = self.flask_app.post("/test/addhits",
                                  data=dict(datetime="2014-09-26T11:27:45",
                                            appid=1,
                                            hits=22))
        assert ret.status_code == 302

        # Check that the hit was added successfully.
        s = sqla.db()
        hits = s.query(Hits).all()
        assert len(hits) == 1

        h = hits[0]
        assert h.hits == 22
Beispiel #6
0
    def test_hits_add(self):
        """
        Test the add hits page
        """
        ret = self.flask_app.get("/test/addhits")
        assert ret.status_code == 200
        assert "submit" in ret.data

        ret = self.flask_app.post("/test/addhits", data=dict(
            datetime="2014-09-26T11:27:45",
            appid=1,
            hits=22
        ))
        assert ret.status_code == 302

        # Check that the hit was added successfully.
        s = sqla.db()
        hits = s.query(Hits).all()
        assert len(hits) == 1

        h = hits[0]
        assert h.hits == 22