コード例 #1
0
def test_edit_archival_object():
    client = AtomClient(**AUTH)
    original = client.get_record('second-subfonds')
    assert original['title'] == 'Second subfonds'
    assert original['dates'][0]['end'] == '2015-01-01'
    assert not original['notes']
    new_record = {
        'slug': 'second-subfonds',
        'title': 'Test edited subfonds',
        'start_date': '2014-11-01',
        'end_date': '2015-11-01',
        'date_expression': 'November, 2014 to November, 2015',
        'notes': [{
            'type': 'general',
            'content': 'This is a test note'
        }],
    }
    client.edit_record(new_record)
    updated = client.get_record('second-subfonds')
    assert updated['title'] == new_record['title']
    assert updated['dates'][0]['begin'] == new_record['start_date']
    assert updated['dates'][0]['end'] == new_record['end_date']
    assert updated['dates'][0]['expression'] == new_record['date_expression']
    assert updated['notes'][0]['type'] == new_record['notes'][0]['type']
    assert updated['notes'][0]['content'] == new_record['notes'][0]['content']
コード例 #2
0
def test_delete_record_resource():
    client = AtomClient(**AUTH)
    slug = "another-subfonds"
    assert client.get_record(slug)
    r = client.delete_record(slug)
    assert r["status"] == "Deleted"
    with pytest.raises(CommunicationError):
        client.get_record(slug)
コード例 #3
0
def test_delete_record_resource():
    client = AtomClient(**AUTH)
    slug = 'another-subfonds'
    assert client.get_record(slug)
    r = client.delete_record(slug)
    assert r['status'] == 'Deleted'
    with pytest.raises(CommunicationError):
        client.get_record(slug)
コード例 #4
0
def test_edit_record_empty_note():
    client = AtomClient(**AUTH)
    original = client.get_record("second-subfonds")
    assert original["notes"]
    new_record = {
        "slug": "second-subfonds",
        "title": "Test edited subseries w/ empty note",
        "start_date": "2014-11-01",
        "end_date": "2015-11-01",
        "date_expression": "November, 2014 to November, 2015",
        "notes": [{"type": "general", "content": ""}],
    }
    client.edit_record(new_record)
    updated = client.get_record("second-subfonds")
    assert not updated["notes"]
コード例 #5
0
def test_posting_contentless_note():
    client = AtomClient(**AUTH)
    slug = client.add_child('test-fonds',
                           title='Yet another subfonds',
                           level='subfonds',
                           notes=[{'type': 'general', 'content': ''}])
    assert client.get_record(slug)['notes'] == []
コード例 #6
0
def test_posting_contentless_note():
    client = AtomClient(**AUTH)
    slug = client.add_child(
        "test-fonds",
        title="Yet another subfonds",
        level="subfonds",
        notes=[{"type": "general", "content": ""}],
    )
    assert client.get_record(slug)["notes"] == []
コード例 #7
0
def test_edit_record_empty_note():
    client = AtomClient(**AUTH)
    original = client.get_record('second-subfonds')
    assert original['notes']
    new_record = {
        'slug': 'second-subfonds',
        'title': 'Test edited subseries w/ empty note',
        'start_date': '2014-11-01',
        'end_date': '2015-11-01',
        'date_expression': 'November, 2014 to November, 2015',
        'notes': [{
            'type': 'general',
            'content': ''
        }],
    }
    client.edit_record(new_record)
    updated = client.get_record('second-subfonds')
    assert not updated['notes']
コード例 #8
0
def test_edit_archival_object():
    client = AtomClient(**AUTH)
    original = client.get_record("second-subfonds")
    assert original["title"] == "Second subfonds"
    assert original["dates"][0]["end"] == "2015-01-01"
    assert not original["notes"]
    new_record = {
        "slug": "second-subfonds",
        "title": "Test edited subfonds",
        "start_date": "2014-11-01",
        "end_date": "2015-11-01",
        "date_expression": "November, 2014 to November, 2015",
        "notes": [{"type": "general", "content": "This is a test note"}],
    }
    client.edit_record(new_record)
    updated = client.get_record("second-subfonds")
    assert updated["title"] == new_record["title"]
    assert updated["dates"][0]["begin"] == new_record["start_date"]
    assert updated["dates"][0]["end"] == new_record["end_date"]
    assert updated["dates"][0]["expression"] == new_record["date_expression"]
    assert updated["notes"][0]["type"] == new_record["notes"][0]["type"]
    assert updated["notes"][0]["content"] == new_record["notes"][0]["content"]