Skip to content

Commit

Permalink
oops. forgot to update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aminusfu committed Oct 16, 2024
1 parent 3a58aee commit d523f35
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
30 changes: 22 additions & 8 deletions scrunch/tests/test_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ def test_create_numeric(self, mocked_process):
'body': {
'alias': 'monthly_rent',
'name': 'Monthly rent',
"derived": False,
'derivation': {
'function': '/',
'args': [
Expand Down Expand Up @@ -398,7 +399,8 @@ def test_rollup(self, mocked_process):
'body': {
'alias': 'new_rolledup_var',
'name': 'new_rolledup_var',
'expr': {
"derived": False,
'derivation': {
'function': 'rollup',
'args': [
{'variable': 'https://test.crunch.io/api/datasets/123456/variables/001/'},
Expand Down Expand Up @@ -1483,7 +1485,7 @@ def getitem(key):
assert not var_tuple.entity.edit.called

# check we call `edit` for derived variables
body['derived'] = True
body["derived"] = True
var.integrate()
var_tuple.entity.edit.assert_called_once_with(derived=False)

Expand Down Expand Up @@ -2150,6 +2152,7 @@ def test_recode_w_fill(self):
"element": "shoji:entity",
"body": {
"alias": "filled",
"derived": False,
"derivation": fill_expr,
"name": "Filled var",
"description": ""
Expand Down Expand Up @@ -2208,6 +2211,7 @@ def test_else_code(self):
"element": "shoji:entity",
"body": {
"alias": "filled",
"derived": False,
"derivation": fill_expr,
"name": "Filled var",
"description": ""
Expand Down Expand Up @@ -2266,6 +2270,7 @@ def test_else_var(self):
"element": "shoji:entity",
"body": {
"alias": "filled",
"derived": False,
"derivation": fill_expr,
"name": "Filled var",
"description": ""
Expand Down Expand Up @@ -2332,7 +2337,8 @@ def test_recode_single_categorical(self):
'notes': '',
'alias': 'cat',
'name': 'My cat',
'expr': {
"derived": False,
'derivation': {
'function': 'case',
'args': [{
'column': [1, 2, 3, -1],
Expand Down Expand Up @@ -2452,6 +2458,7 @@ def test_recode_multiple_response(self):
'description': '',
'notes': '',
'name': 'my mr',
"derived": False,
'derivation': {
'function': 'array',
'args': [{
Expand Down Expand Up @@ -2625,7 +2632,8 @@ def test_create_categorical_else_case(self):
"body": {
"alias": "agerange",
"name": "Age Range",
"expr": {
"derived": False,
"derivation": {
"function": "case",
"args": [
{
Expand Down Expand Up @@ -2777,12 +2785,13 @@ def test_create_2_multiple_response_else_case(self):
}
}
ds.resource.variables.create.assert_called_with({
"element": "shoji:entity",
"element": "shoji:entity",
"body": {
"name": "Age range multi",
"alias": "agerange_multi",
"description": "",
"notes": "",
"derived": False,
"derivation": {
"function": "array",
"args": [
Expand Down Expand Up @@ -2970,6 +2979,7 @@ def test_create_3_multiple_response_else_case(self):
"description": "",
"notes": "",
"uniform_basis": False,
"derived": False,
"derivation": {
"function": "array",
"args": [
Expand Down Expand Up @@ -3351,6 +3361,7 @@ def test_create_categorical_missing_case(self):
"description": "",
"notes": "",
"uniform_basis": False,
"derived": False,
"derivation": {
"function": "array",
"args": [
Expand Down Expand Up @@ -3595,6 +3606,7 @@ def test_derive_multiple_response(self):
'description': '',
'notes': '',
'uniform_basis': False,
"derived": False,
'derivation': {
'function': 'array',
'args': [{
Expand Down Expand Up @@ -3691,7 +3703,7 @@ def test_base_variable(self):
var_res.entity.body = {'type': 'numeric'}

def getitem(key):
if key == 'derived':
if key == "derived":
return False
var_res.__getitem__.side_effect = getitem
var_res.entity.self = '/variable/url/'
Expand All @@ -3703,6 +3715,7 @@ def getitem(key):
'body': {
'alias': 'copy',
'name': 'copy',
"derived": False,
'derivation': {
'function': 'copy_variable',
'args': [{'variable': '/variable/url/'}]
Expand All @@ -3715,7 +3728,7 @@ def test_derived_variable(self):
var_res = mock.MagicMock()

def getitem(key):
if key == 'derived':
if key == "derived":
return True
var_res.__getitem__.side_effect = getitem
var_res.entity.body = {
Expand Down Expand Up @@ -3745,6 +3758,7 @@ def getitem(key):
'body': {
'alias': 'copy',
'name': 'copy',
"derived": False,
'derivation': {
'function': 'array',
'args': [{
Expand Down Expand Up @@ -6694,7 +6708,7 @@ class TestHeadingSubtotals(TestDatasetBase):
'categories': TEST_CATEGORIES(),
'is_subvar': False,
'view': {},
'derived': False,
"derived": False,
},
}

Expand Down
6 changes: 5 additions & 1 deletion scrunch/tests/test_recodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def mr_in(mr_self, mr_alias, groups, parent_subvariables):
'element': 'shoji:entity',
'body': {
'alias': 'alias',
"derived": False,
'derivation': {
'function': 'combine_categories',
'args': [
Expand All @@ -76,6 +77,7 @@ def mr_in(mr_self, mr_alias, groups, parent_subvariables):
'name': 'name',
'description': '',
'alias': 'alias',
"derived": False,
'derivation': {
'function': 'combine_responses',
'args': [
Expand Down Expand Up @@ -351,7 +353,8 @@ def test_recode_categoricals(self, get_dataset_mock):
'alias': 'sexuality2',
'description': '',
'notes': '',
'expr': {
"derived": False,
'derivation': {
'function': 'case',
'args': [{
'column': [1, 2, -1],
Expand Down Expand Up @@ -491,6 +494,7 @@ def test_recode_multiple_responses(self, get_dataset_mock):
'description': '',
'notes': '',
'alias': 'Q1_recoded',
"derived": False,
'derivation': {
'function': 'array',
'args': [{
Expand Down

0 comments on commit d523f35

Please sign in to comment.