feat: SOQLBuilderのテスト追加
This commit is contained in:
parent
ec74a8cf46
commit
9af0d9dd5c
0
ecs/crm-datafetch/tests/salesforce/__init__.py
Normal file
0
ecs/crm-datafetch/tests/salesforce/__init__.py
Normal file
104
ecs/crm-datafetch/tests/salesforce/test_soql_builder.py
Normal file
104
ecs/crm-datafetch/tests/salesforce/test_soql_builder.py
Normal file
@ -0,0 +1,104 @@
|
||||
|
||||
from src.config.objects import ExecuteDateTime, LastFetchDatetime, TargetObject
|
||||
from src.salesforce.soql_builder import SOQLBuilder
|
||||
|
||||
|
||||
class TestSOQLBuilder:
|
||||
|
||||
def test_create_count_soql(self):
|
||||
test_target_object_json = {
|
||||
'object_name': 'Account',
|
||||
'columns': [
|
||||
'Id',
|
||||
'Name',
|
||||
'SystemModstamp',
|
||||
'LastModifiedDate',
|
||||
'CustomItem1__c',
|
||||
'CustomItem2__c',
|
||||
'CustomItem3__c',
|
||||
'CustomItem4__c',
|
||||
'CustomItem5__c',
|
||||
'CustomItem6__c',
|
||||
'CustomItem7__c',
|
||||
'CustomItem8__c'
|
||||
]
|
||||
}
|
||||
|
||||
test_last_fetch_datetime_json = {
|
||||
'last_fetch_datetime_from': '1999-01-01T00:00:00.000Z',
|
||||
'last_fetch_datetime_to': '2000-01-01T00:00:00.000Z',
|
||||
}
|
||||
|
||||
execute_datetime = ExecuteDateTime()
|
||||
target_object = TargetObject(test_target_object_json, execute_datetime)
|
||||
test_last_fetch_datetime = LastFetchDatetime(test_last_fetch_datetime_json, execute_datetime)
|
||||
|
||||
sut = SOQLBuilder(target_object, test_last_fetch_datetime)
|
||||
actual = sut.create_count_soql()
|
||||
|
||||
expect = """SELECT
|
||||
COUNT(Id)
|
||||
FROM
|
||||
Account
|
||||
WHERE
|
||||
SystemModstamp > 1999-01-01T00:00:00.000Z AND
|
||||
SystemModstamp <= 2000-01-01T00:00:00.000Z
|
||||
"""
|
||||
|
||||
assert actual.replace('\n', '').replace(' ', '') == expect.replace('\n', '').replace(' ', '')
|
||||
|
||||
def test_create_fetch_soql(self):
|
||||
test_target_object_json = {
|
||||
'object_name': 'Account',
|
||||
'columns': [
|
||||
'Id',
|
||||
'Name',
|
||||
'SystemModstamp',
|
||||
'LastModifiedDate',
|
||||
'CustomItem1__c',
|
||||
'CustomItem2__c',
|
||||
'CustomItem3__c',
|
||||
'CustomItem4__c',
|
||||
'CustomItem5__c',
|
||||
'CustomItem6__c',
|
||||
'CustomItem7__c',
|
||||
'CustomItem8__c'
|
||||
]
|
||||
}
|
||||
|
||||
test_last_fetch_datetime_json = {
|
||||
'last_fetch_datetime_from': '1999-01-01T00:00:00.000Z',
|
||||
'last_fetch_datetime_to': '2000-01-01T00:00:00.000Z',
|
||||
}
|
||||
|
||||
execute_datetime = ExecuteDateTime()
|
||||
target_object = TargetObject(test_target_object_json, execute_datetime)
|
||||
test_last_fetch_datetime = LastFetchDatetime(test_last_fetch_datetime_json, execute_datetime)
|
||||
|
||||
sut = SOQLBuilder(target_object, test_last_fetch_datetime)
|
||||
actual = sut.create_fetch_soql()
|
||||
|
||||
expect = """SELECT
|
||||
Id,
|
||||
Name,
|
||||
SystemModstamp,
|
||||
LastModifiedDate,
|
||||
CustomItem1__c,
|
||||
CustomItem2__c,
|
||||
CustomItem3__c,
|
||||
CustomItem4__c,
|
||||
CustomItem5__c,
|
||||
CustomItem6__c,
|
||||
CustomItem7__c,
|
||||
CustomItem8__c
|
||||
FROM
|
||||
Account
|
||||
WHERE
|
||||
SystemModstamp > 1999-01-01T00:00:00.000Z AND
|
||||
SystemModstamp <= 2000-01-01T00:00:00.000Z
|
||||
"""
|
||||
|
||||
print('actual', actual)
|
||||
print('expect', expect)
|
||||
|
||||
assert actual.replace('\n', '').replace(' ', '') == expect.replace('\n', '').replace(' ', '')
|
||||
Loading…
x
Reference in New Issue
Block a user