コード例 #1
0
ファイル: test_api_key.py プロジェクト: chronosdb/pychronos
    def test_init___no_connection(self):

        with self.assertRaises(ConnectionError):
            pychronos.init(username=username,
                           password=password,
                           host="http://blabla.com",
                           port=port)
コード例 #2
0
ファイル: test_api_key.py プロジェクト: chronosdb/pychronos
    def test_init___wrong_port(self):

        with self.assertRaises(ConnectionError):
            pychronos.init(username=username,
                           password=password,
                           host="http://localhost",
                           port=8888)
コード例 #3
0
 def test_close___ok(self):
     # when
     chronos = pychronos.init(username="******",
                              password="******",
                              host="http://localhost",
                              port=9090,
                              base_path='/api')
コード例 #4
0
    def test_login___ok(self):
        # when
        chronos = pychronos.init(username="******",
                                 password="******",
                                 host="http://localhost",
                                 port=9090,
                                 base_path='/api')
        token = pychronos._configuration.access_token

        pychronos._user_api_instance.app_api_user_ping()

        chronos.logout()

        self.assertEqual("", pychronos._configuration.access_token)

        with self.assertRaises(ApiException) as e:
            pychronos._user_api_instance.app_api_user_ping()

        self.assertEqual(401, e.exception.status)

        time.sleep(1)

        chronos.login(username="******", password="******")

        self.assertEqual(len(token),
                         len(pychronos._configuration.access_token))
        self.assertNotEqual(token, pychronos._configuration.access_token)

        pychronos._user_api_instance.app_api_user_ping()
コード例 #5
0
    def setUp(self):

        self.space_name = fake.obj_name()
        self.coll_name = fake.obj_name()

        self.chronos = pychronos.init(username="******", password="******", host=HOST, port=PORT)

        if self.space_name in self.chronos.list_spaces():
            self.space = self.chronos[self.space_name]
            self.space.delete()

        self.space = self.chronos.create(self.space_name)

        if self.coll_name in self.space.list_collections():
            coll = self.space[self.coll_name]
            coll.delete()

        self.coll = self.space.create(self.coll_name)

        N = 5
        self.ts_name = fake.obj_name()
        self.ts = self.coll.create(self.ts_name, Freq.Quarterly, DType.float64)
        pts_time = pd.period_range('1950-01', periods=N, freq='Q')
        val = np.random.randn(N)
        x = pd.Series(val, index=pts_time)

        vx = self.ts.save(x)
コード例 #6
0
ファイル: test_api_key.py プロジェクト: chronosdb/pychronos
    def test_init___ok(self):

        x = pychronos.init(username=username,
                           password=password,
                           host=host,
                           port=port)
        self.assertIsInstance(x, Chronos)
コード例 #7
0
ファイル: test_space.py プロジェクト: chronosdb/pychronos
 def setUpClass(cls):
     cls.space_name = "test_space"
     # self.chronos = pychronos.init(username="******", password="******", host="https://tshub-dev.appspot.com", port=443)
     cls.chronos = pychronos.init(username="******",
                                  password="******",
                                  host="http://localhost",
                                  port=9090)
コード例 #8
0
    def test_login_different_user___ok(self):
        # when
        chronos = pychronos.init(username="******",
                                 password="******",
                                 host="http://localhost",
                                 port=9090,
                                 base_path='/api')

        chronos.logout()

        with self.assertRaises(Exception) as e:
            pychronos._user_api_instance.app_api_user_ping()

        self.assertEqual(401, e.exception.status)

        chronos.login(username="******", password="******")

        print(pychronos._user_api_instance.app_api_user_ping())
コード例 #9
0
    def setUp(self):

        self.space_name = "test_space"
        self.coll_name = "test_collection"

        self.chronos = pychronos.init(username="******",
                                      password="******",
                                      host=HOST,
                                      port=PORT)
        if self.space_name in self.chronos.list_spaces():
            self.space = self.chronos[self.space_name]
            self.space.delete()

        self.space = self.chronos.create(self.space_name)

        if self.coll_name in self.space.list_collections():
            coll = self.space[self.coll_name]
            coll.delete()

        self.coll = self.space.create(self.coll_name)
コード例 #10
0
    def setUp(self):

        self.space_name = "test_space"
        self.coll_name = "test_collection"
        # HOST = 'https://tshub-dev.appspot.com'
        # PORT = 443
        HOST = "http://localhost"
        PORT = 9090

        self.chronos = pychronos.init(username="******",
                                      password="******",
                                      host=HOST,
                                      port=PORT)
        if self.space_name in self.chronos.list_spaces():
            self.space = self.chronos[self.space_name]
            self.space.delete()

        self.space = self.chronos.create(self.space_name)

        if self.coll_name in self.space.list_collections():
            coll = self.space[self.coll_name]
            coll.delete()

        self.coll = self.space.create(self.coll_name)
コード例 #11
0
ファイル: test_api_key.py プロジェクト: chronosdb/pychronos
 def setUpClass(cls):
     cls.chronos = pychronos.init(username=username,
                                  password=password,
                                  host="http://localhost",
                                  port=9090,
                                  base_path='/api')
コード例 #12
0
        x = pd.Series(val, index=pts_time)

        v_name = "blabla"
        v_description = "my description"
        v_metadata = {"a": 1, "b": [1, 2], "c": {"x": 1, "y": 2}}
        vt = pychronos.Vintage(name=v_name,
                               description=v_description,
                               metadata=v_metadata)
        vx = ts.save(x, vintage=vt)

        ts2 = self.coll.create("xyz2", Freq.Quarterly, DType.float64)
        pts_time2 = pd.period_range('1970-01', periods=N, freq='Q')
        val2 = np.random.randn(N)
        x2 = pd.Series(val2, index=pts_time2)

        # try saving with the same vintage name
        with self.assertRaises(ValueError) as e:
            vx2 = ts2.save(x2, vintage=vt)

        print(e)

    def test_history(self):
        pass


if False:
    import pychronos
    chronos = pychronos.init(username='******', password='******')
    chronos.list_spaces()
    sd = chronos['sample_data']
コード例 #13
0
ファイル: test_init.py プロジェクト: chronosdb/pychronos
    def test_init___ok(self):
        chronos = pychronos.init(api_key="Sl1QW1xb8ocz0lkYTEa18tpaZaZl65AxDgWkZqh8",
                                 host="http://localhost", port=9090,
                                 base_path='/api')

        chronos.list_spaces()