Skip to content

Commit

Permalink
renaming sql to csv in source files
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitri-schmidt committed May 19, 2015
1 parent cebcdf6 commit 3f4f63d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions sqlScriptBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import re
import csv

class sqlScriptBuilder:
class csvScriptBuilder:

MAX_PROPERTY_NUMBER = 2000

Expand Down Expand Up @@ -97,7 +97,7 @@ def write_multiple_lines(self, property_number, constraint_name):
self.parameters.pop('item', None)
self.reset_parameter()

def write_line_in_sql_file(self, property_number, constraint_name):
def write_line_in_csv_file(self, property_number, constraint_name):
if self.list_parameter != 'NULL':
self.write_multiple_lines(property_number, constraint_name)
else:
Expand Down Expand Up @@ -243,7 +243,7 @@ def process_constraint_part(self, constraint_part, property_number):
constraint_parameters = constraint_string[delimiter_index+1:]
self.add_all_parameters(constraint_parameters)

self.write_line_in_sql_file(property_number, self.constraint_name)
self.write_line_in_csv_file(property_number, self.constraint_name)

constraint_string, remaining_constraint = self.split_constraint_block(remaining_constraint)

Expand All @@ -262,7 +262,7 @@ def process_property_talk_page(self, property_number):
self.process_constraint_part(constraintPart, property_number)


# only purpose: Build SQL-Statement to fill table with constraints
# only purpose: Build csv-Statement to fill table with constraints
# fetches constraints from property talk pages
# nonetheless: use table layout that will suit the new way of storing
# constraints as statements on properties
Expand All @@ -278,7 +278,7 @@ def run(self):


def main():
builder = sqlScriptBuilder()
builder = csvScriptBuilder()
builder.run()

if __name__ == "__main__": main()
14 changes: 7 additions & 7 deletions test_sqlScriptBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
import os.path
import csv

from sqlScriptBuilder import sqlScriptBuilder
from sqlScriptBuilder import csvScriptBuilder
import uuid


class TestSqlScriptBuilder():
class TestCsvScriptBuilder():

def setup_method(self, method):
# setup_method is invoked befor every test method of a class
self.builder = sqlScriptBuilder()
self.builder = csvScriptBuilder()
self.csv_file = open("test_constraints.csv", "wb")
self.builder.csv_writer = csv.writer(self.csv_file)

Expand Down Expand Up @@ -453,24 +453,24 @@ def test_add_relation_whitespace(self):
assert self.builder.parameters['relation'] == expected_result


def test_write_line_in_sql_file_null(self):
def test_write_line_in_csv_file_null(self):
self.builder.write_multiple_lines = Mock()
self.builder.write_one_line = Mock()
self.builder.list_parameter = 'NULL'
test_property_number = 1234
test_constraint_name = 'Constraint Name'
self.builder.write_line_in_sql_file(test_property_number, test_constraint_name)
self.builder.write_line_in_csv_file(test_property_number, test_constraint_name)
assert self.builder.write_multiple_lines.call_count == 0
self.builder.write_one_line.assert_called_once_with(1234, 'Constraint Name')


def test_write_line_in_sql_file_not_null(self):
def test_write_line_in_csv_file_not_null(self):
self.builder.write_multiple_lines = Mock()
self.builder.write_one_line = Mock()
self.builder.list_parameter = 'not Null'
test_property_number = 4321
test_constraint_name = 'Another Constraint Name'
self.builder.write_line_in_sql_file(test_property_number, test_constraint_name)
self.builder.write_line_in_csv_file(test_property_number, test_constraint_name)
self.builder.write_multiple_lines.assert_called_once_with(4321, 'Another Constraint Name')
assert self.builder.write_one_line.call_count == 0

Expand Down

0 comments on commit 3f4f63d

Please sign in to comment.