Move code to code dir
Follow yoda
This commit is contained in:
parent
e18669065e
commit
1084d78c3e
15 changed files with 12 additions and 5 deletions
0
code/tests/__init__.py
Normal file
0
code/tests/__init__.py
Normal file
10
code/tests/test_validate_date_col.py
Normal file
10
code/tests/test_validate_date_col.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import dataframely as dy
|
||||
import polars as pl
|
||||
|
||||
|
||||
class DateSchema(dy.Schema):
|
||||
date: dy.Date = dy.Date(nullable=False)
|
||||
|
||||
@dy.rule()
|
||||
def minimum_starting_date() -> pl.Expr:
|
||||
return pl.col("date") > pl.date(2018, 5, 8)
|
||||
24
code/tests/test_validate_files.py
Normal file
24
code/tests/test_validate_files.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import dataframely as dy
|
||||
import polars as pl
|
||||
|
||||
from tests.test_validate_date_col import DateSchema
|
||||
|
||||
|
||||
class FilesSchema(DateSchema):
|
||||
filename: dy.String = dy.String(nullable=False)
|
||||
mtime: dy.Float = dy.Float(nullable=False)
|
||||
filesize: dy.Integer = dy.Integer(nullable=False)
|
||||
|
||||
|
||||
def test_files_schema():
|
||||
_ = FilesSchema.validate(
|
||||
pl.scan_csv(
|
||||
"output/files.csv",
|
||||
schema={
|
||||
"date": pl.Date,
|
||||
"filename": pl.String,
|
||||
"mtime": pl.Float32,
|
||||
"filesize": pl.UInt32,
|
||||
},
|
||||
).collect(engine="streaming")
|
||||
)
|
||||
22
code/tests/test_validate_kernels.py
Normal file
22
code/tests/test_validate_kernels.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import dataframely as dy
|
||||
import polars as pl
|
||||
|
||||
from tests.test_validate_date_col import DateSchema
|
||||
|
||||
|
||||
class KernelsSchema(DateSchema):
|
||||
kernel: dy.String = dy.String(nullable=False)
|
||||
downloads: dy.Integer = dy.Integer(nullable=False)
|
||||
|
||||
|
||||
def test_kernels_schema():
|
||||
_ = KernelsSchema.validate(
|
||||
pl.scan_csv(
|
||||
"output/kernels.csv",
|
||||
schema={
|
||||
"date": pl.Date,
|
||||
"kernel": pl.String,
|
||||
"downloads": pl.UInt32,
|
||||
},
|
||||
).collect(engine="streaming")
|
||||
)
|
||||
24
code/tests/test_validate_packages.py
Normal file
24
code/tests/test_validate_packages.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import dataframely as dy
|
||||
import polars as pl
|
||||
|
||||
from tests.test_validate_date_col import DateSchema
|
||||
|
||||
|
||||
class PackagesSchema(DateSchema):
|
||||
package: dy.String = dy.String(nullable=False)
|
||||
version: dy.String = dy.String(nullable=False)
|
||||
count: dy.Integer = dy.Integer(nullable=False)
|
||||
|
||||
|
||||
def test_packages_schema():
|
||||
_ = PackagesSchema.validate(
|
||||
pl.scan_csv(
|
||||
"output/packages.csv",
|
||||
schema={
|
||||
"date": pl.Date,
|
||||
"package": pl.String,
|
||||
"version": pl.String,
|
||||
"count": pl.UInt16,
|
||||
},
|
||||
).collect(engine="streaming")
|
||||
)
|
||||
24
code/tests/test_validate_unique_installs.py
Normal file
24
code/tests/test_validate_unique_installs.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import dataframely as dy
|
||||
import polars as pl
|
||||
|
||||
from tests.test_validate_date_col import DateSchema
|
||||
|
||||
|
||||
class UniquesSchema(DateSchema):
|
||||
unique: dy.Integer = dy.Integer(nullable=False)
|
||||
|
||||
@dy.rule()
|
||||
def cannot_be_zero() -> pl.Expr:
|
||||
return pl.col("unique") > 0
|
||||
|
||||
|
||||
def test_uniques_schema():
|
||||
_ = UniquesSchema.validate(
|
||||
pl.scan_csv(
|
||||
"output/unique_installs.csv",
|
||||
schema={
|
||||
"date": pl.Date,
|
||||
"unique": pl.UInt16,
|
||||
},
|
||||
).collect(engine="streaming")
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue