Skip to content

Commit b93a951

Browse files
committed
can speicfy tests to run
1 parent d2dfa31 commit b93a951

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

aragorm/columns.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def format_value(self, value):
4444
Takes the raw Python value and return a string usable in the database
4545
query.
4646
"""
47+
value = value if value else 'null'
4748
return f'{value}'
4849

4950
def __lt__(self, value) -> 'Where':
@@ -90,8 +91,10 @@ def __init__(self, length: int = 255, default: str = None,
9091
super().__init__(**kwargs)
9192

9293
def format_value(self, value):
94+
value = value if value else 'null'
95+
import ipdb; ipdb.set_trace()
9396
if type(value) != str:
94-
raise ValueError('Varchar only accepts strings')
97+
raise ValueError(f'{self.name} - Varchar only accepts strings')
9598
# TODO sanitize input
9699
return f"'{value}'"
97100

aragorm/table.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def __init__(self, **kwargs):
7070
column.default
7171
) else column.default
7272
else:
73-
if column.required:
73+
if not column.null:
7474
raise ValueError(f"{column.name} wasn't provided")
7575
self.value = value
7676

@@ -81,7 +81,8 @@ def __getitem__(self, key: str):
8181
return getattr(self, key)
8282

8383
def __str__(self):
84-
row = ", ".join([
84+
import ipdb; ipdb.set_trace()
85+
row = ",".join([
8586
column.format_value(
8687
self[column.name]
8788
) for column in self.Meta.columns

run-tests.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
#!/bin/bash
2-
python -m pytest -s .
3-
2+
python -m pytest -s $1

tests/table/test_instance.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from ..base import DBTestCase
2+
from ..example_project.tables import Pokemon
3+
4+
5+
class TestInstance(DBTestCase):
6+
"""
7+
Test instantiating Table instances
8+
"""
9+
10+
def test_insert(self):
11+
pikachu = Pokemon(name="pikachu")
12+
print(pikachu)

0 commit comments

Comments
 (0)