Esempio n. 1
0
    def test_get_singleton_document_fails_when_more_than_one_documents_exist(self):
        tu.save_document({'_id': uuid.uuid4(), 'type': 'marathon'})
        tu.save_document({'_id': uuid.uuid4(), 'type': 'marathon'})
        with pytest.raises(DocumentConfigurationError) as exception_info:
            tu.get_singleton_document('marathon')

        error_string = 'more than one document found of type marathon, expected singleton'
        assert error_string in str(exception_info.value)
Esempio n. 2
0
    def test_get_singleton_document_fails_when_more_than_one_documents_exist(
            self):
        tu.save_document({'_id': uuid.uuid4(), 'type': 'marathon'})
        tu.save_document({'_id': uuid.uuid4(), 'type': 'marathon'})
        with pytest.raises(DocumentConfigurationError) as exception_info:
            tu.get_singleton_document('marathon')

        error_string = 'more than one document found of type marathon, expected singleton'
        assert error_string in str(exception_info.value)
Esempio n. 3
0
    def test_get_singleton_document_fails_when_zero_documents_exist(self):
        doc_id = uuid.uuid4()
        dict_in = {'_id': doc_id, 'type': 'twix'}
        tu.save_document(dict_in)
        with pytest.raises(NotFoundError) as exception_info:
            tu.get_singleton_document('skittles')

        error_string = 'no document found of type skittles, expected singleton'
        assert error_string in str(exception_info.value)
Esempio n. 4
0
    def test_get_singleton_document_fails_when_zero_documents_exist(self):
        doc_id = uuid.uuid4()
        dict_in = {'_id': doc_id,
                   'type': 'twix'}
        tu.save_document(dict_in)
        with pytest.raises(NotFoundError) as exception_info:
            tu.get_singleton_document('skittles')

        error_string = 'no document found of type skittles, expected singleton'
        assert error_string in str(exception_info.value)
Esempio n. 5
0
    def test_get_singleton_document_succeeds_when_one_document_is_found(self):
        doc_id = uuid.uuid4()
        tu.save_document({'_id': doc_id, 'type': 'zagnut'})
        the_dict = tu.get_singleton_document('zagnut')

        assert the_dict
        assert the_dict['_id'] == str(doc_id)
Esempio n. 6
0
    def test_get_singleton_document_succeeds_when_one_document_is_found(self):
        doc_id = uuid.uuid4()
        tu.save_document({'_id': doc_id, 'type': 'zagnut'})
        the_dict = tu.get_singleton_document('zagnut')

        assert the_dict
        assert the_dict['_id'] == str(doc_id)
Esempio n. 7
0
def get_settings_document():
    '''
    Fetches the settings document (a singleton)
    '''
    try:
        settings_dict = get_singleton_document('settings')
    except NotFoundError as e:
        settings_dict = create_default_settings_and_group_documents()
    return settings_dict
Esempio n. 8
0
def get_settings_document():
    """
    Fetches the settings document (a singleton)
    """
    try:
        settings_dict = get_singleton_document("settings")
    except NotFoundError as e:
        settings_dict = create_default_settings_and_group_documents()
    return settings_dict