Skip to content

Commit

Permalink
Split test module in two.
Browse files Browse the repository at this point in the history
Plus other minor tweaks
  • Loading branch information
codeinthehole committed Jun 27, 2012
1 parent 6d72e7f commit bcb2f96
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 1,026 deletions.
10 changes: 6 additions & 4 deletions adaptor/model.py
Expand Up @@ -44,7 +44,8 @@ def __init__(self, line, field_error, model, value):
CsvDataException.__init__(self, line, field_error=field_error)


class SkipRow(Exception): pass
class SkipRow(Exception):
pass


class BaseModel(object):
Expand Down Expand Up @@ -82,7 +83,6 @@ def get_value(self, attr_name, field, value):
self.field_matching_name = field.__dict__.get("match", attr_name)
return field.get_prep_value(value)


def update_object(self, dict_values, object, update_dict):
new_dict_values = {}
if 'update' in update_dict:
Expand All @@ -93,7 +93,7 @@ def update_object(self, dict_values, object, update_dict):
else:
new_dict_values = dict_values
for field_name in new_dict_values:
attr = setattr(object, field_name, new_dict_values[field_name])
setattr(object, field_name, new_dict_values[field_name])
object.save()

def base_create_model(self, model, **dict_values):
Expand Down Expand Up @@ -236,7 +236,6 @@ def construct_obj_from_data(self, data):
self.validate()
values = {}
silent_failure = self.cls.silent_failure()
load_failed = False
self.multiple_creation_field = None
composed_fields = []
index_offset = 0
Expand Down Expand Up @@ -310,6 +309,7 @@ def get_exclusion_fields(cls):
list_exclusion.append('id')
return list_exclusion


class XMLModel(BaseModel):
_exclude_data_fields = ['root']

Expand Down Expand Up @@ -340,6 +340,7 @@ def construct_obj_from_data(self, data):
def get_importer(cls, *args):
return XMLImporter(model=cls)


class XMLImporter(object):
def __init__(self, model):
self.model = model
Expand Down Expand Up @@ -375,6 +376,7 @@ def process_line(self, lines, line, model, delimiter):
lines.append(value)
return value


class TabularLayout(object):
def __init__(self):
self.line_no = 0
Expand Down
1 change: 1 addition & 0 deletions runtests.py
Expand Up @@ -14,6 +14,7 @@
INSTALLED_APPS=[
'tests.test_app',
],
NOSE_ARGS=['-s'],
)

from django_nose import NoseTestSuiteRunner
Expand Down
6 changes: 1 addition & 5 deletions tests/csv_tests.py
Expand Up @@ -3,7 +3,7 @@
from adaptor.fields import *
from adaptor.model import CsvModel, CsvDbModel, ImproperlyConfigured,\
CsvException, CsvDataException, TabularLayout, SkipRow,\
GroupedCsvModel, XMLModel,CsvFieldDataException
GroupedCsvModel, CsvFieldDataException
from tests.test_app.models import *


Expand Down Expand Up @@ -671,7 +671,3 @@ class Meta:
self.assertEquals(test.taille, my_obj.taille)

self.assertEquals(test.export(), u"Jojo;18;1.8")




0 comments on commit bcb2f96

Please sign in to comment.