epogrebnyak / data-rosstat-kep

Time series dataset of Rosstat Short-term Economic Indicators ("KEP") publication
http://www.gks.ru/wps/wcm/connect/rosstat_main/rosstat/ru/statistics/publications/catalog/doc_1140080765391
6 stars 6 forks source link

Testing: finish tests by doing import_csv("data/2015/ind10/") #68

Closed epogrebnyak closed 8 years ago

epogrebnyak commented 8 years ago

Note: may also change DATA_FOLDER constant in tests to CURRENT_MONTH_DATA_FOLDER.

epogrebnyak commented 8 years ago

Must finish tests with following to guarantee the database is filled with most recent data:

from kep.importer.parser.csv2db import import_csv
from kep.paths import CURRENT_MONTH_DATA_FOLDER
import_csv(CURRENT_MONTH_DATA_FOLDER)

is this possible?

Data may be destroyed by some tests. Alternative: use different sqlite file as database in tests, this also should save some time.

epogrebnyak commented 8 years ago

Also discussed at https://github.com/epogrebnyak/rosstat-kep-data/issues/48#issuecomment-164548243

alexanderlukanin13 commented 8 years ago

@epogrebnyak I totally agree that using a separate test database is a good idea. I'll implement it.

epogrebnyak commented 8 years ago

Please tell what is your design idea for that first

alexanderlukanin13 commented 8 years ago

@epogrebnyak 1) Change few occurrences where DB_FILE is used like this:

import kep.paths
...
def get_unique_labels(db_file=None):
    if db_file is None:
        db_file = kep.paths.DB_FILE
    con = sqlite3.connect(db_file)
    ...

2) Patch kep.paths.DB_FILE in the beginning of pytest session, using session fixture

This is not the most nice solution, but it's simple and quite safe.

epogrebnyak commented 8 years ago

There is much more occurenxirs than 'few". One has to pass it to functions like to_database() and many others.

For code above consider a function get_dbfile(), based on a global flag USE_PRODUCTION_DB_FILE = True, override this flag in testing, if possible. It breaks a bit a rule of passing args to function explicitly, but many functions will preserve clean interfaces then.

пн, 21 дек. 2015, 20:15, Alexander Lukanin notifications@github.com:

@epogrebnyak https://github.com/epogrebnyak 1) Change few occurrences where DB_FILE is used like this:

import kep.paths ... def get_unique_labels(db_file=None): if db_file is None: db_file = kep.paths.DB_FILE con = sqlite3.connect(db_file) ...

2) Patch kep.paths.DB_FILE in the beginning of pytest session, using session fixture http://stackoverflow.com/a/20057171

This is not the most nice solution, but it's simple and quite safe.

— Reply to this email directly or view it on GitHub https://github.com/epogrebnyak/rosstat-kep-data/issues/68#issuecomment-166363315 .

alexanderlukanin13 commented 8 years ago

@epogrebnyak No, only a few occurrences because we override global settings in kep.paths. In fact, I already have a working prototype. Believe me, it's the simplest and cleanest thing we can do: no API changes at all.

epogrebnyak commented 8 years ago

Ok then, pull it for me to familiarize with

пн, 21 дек. 2015, 20:38, Alexander Lukanin notifications@github.com:

@epogrebnyak https://github.com/epogrebnyak No, only a few occurrences because we override global settings in kep.paths. In fact, I already have a working prototype. Believe me, it's the simplest and cleanest thing we can do: no API changes at all.

— Reply to this email directly or view it on GitHub https://github.com/epogrebnyak/rosstat-kep-data/issues/68#issuecomment-166369342 .

epogrebnyak commented 8 years ago

Also referenced in #20