def test_variable_group_is_exported_as_dict(self): # Given variable_group = VariableGroup(db_variable_group1) # When variable_group_dict = variable_group.to_dict() # Then assert isinstance(variable_group_dict, dict) assert variable_group_dict == db_variable_group1
def test_variable_group_is_printed_with_classname(self): # Given variable_group = VariableGroup(db_variable_group1) # When variable_group_str = str(variable_group) # Then assert variable_group_str == 'VariableGroup({dict_str})'.format( dict_str=str(db_variable_group1))
def test_variable_group_is_represented_with_classname_and_slug(self): # Given variable_group = VariableGroup(db_variable_group1) # When variable_group_repr = repr(variable_group) # Then assert variable_group_repr == "<VariableGroup.get('{id}')>".format( id=db_variable_group1['slug'])
def test_get_variable_group_by_id(self, mocked_repo): # Given mocked_repo.return_value = test_variable_group1 # When variable_group = VariableGroup.get(test_variable_group1.id) # Then assert isinstance(variable_group, object) assert isinstance(variable_group, VariableGroup) assert variable_group == test_variable_group1
def test_get_all_variables_groups(self, mocked_repo): # Given mocked_repo.return_value = test_variables_groups # When variables_groups = VariableGroup.get_all() # Then assert isinstance(variables_groups, list) assert isinstance(variables_groups, CatalogList) assert variables_groups == test_variables_groups
def test_variable_group_properties(self): # Given variable_group = VariableGroup(db_variable_group1) # When variable_group_id = variable_group.id slug = variable_group.slug name = variable_group.name dataset = variable_group.dataset # Then assert variable_group_id == db_variable_group1['id'] assert slug == db_variable_group1['slug'] assert name == db_variable_group1['name'] assert dataset == db_variable_group1['dataset_id']
def test_missing_fields_are_mapped_as_None(self, mocked_repo): # Given mocked_repo.return_value = [{'id': 'variable_group1'}] repo = VariableGroupRepository() expected_variables_groups = CatalogList([ VariableGroup({ 'id': 'variable_group1', 'slug': None, 'name': None, 'dataset_id': None }) ]) # When variables_groups = repo.get_all() # Then assert variables_groups == expected_variables_groups
db_variable_group1 = { 'id': 'carto-do.variable_group.vargroup1', 'slug': 'vargroup1', 'name': 'Population', 'dataset_id': 'dataset1', 'starred': True } db_variable_group2 = { 'id': 'carto-do.variable_group.vargroup2', 'slug': 'vargroup2', 'name': 'Date', 'dataset_id': 'dataset1', 'starred': False } test_variable_group1 = VariableGroup(db_variable_group1) test_variable_group2 = VariableGroup(db_variable_group2) test_variables_groups = CatalogList( [test_variable_group1, test_variable_group2]) test_subscription_info = { 'id': 'id', 'estimated_delivery_days': 0, 'subscription_list_price': 100, 'tos': 'tos', 'tos_link': 'tos_link', 'licenses': 'licenses', 'licenses_link': 'licenses_link', 'rights': 'rights' }