# Path: pupa/scrape/popolo.py
# class Post(BaseModel, LinkMixin, ContactDetailMixin):
#     """
#     A popolo-style Post
#     """
# 
#     _type = 'post'
#     _schema = post_schema
# 
#     def __init__(self, *, label, role, organization_id=None, chamber=None,
#                  division_id=None, start_date='', end_date='',
#                  maximum_memberships=1):
#         super(Post, self).__init__()
#         self.label = label
#         self.role = role
#         self.organization_id = pseudo_organization(organization_id, chamber)
#         self.division_id = division_id
#         self.start_date = start_date
#         self.end_date = end_date
#         self.maximum_memberships = maximum_memberships
# 
#     def __str__(self):
#         return self.label


import pytest
import datetime
from pupa.scrape import Post as ScrapePost
from pupa.importers import PostImporter, OrganizationImporter
from opencivicdata.core.models import Organization, Post, Division, Jurisdiction

    # get person from db and assert it imported correctly
    p = Post.objects.get()
    assert 'ocd-post' in p.id
    assert p.label == post.label
    assert p.role == post.role
    assert p.organization_id == org.id
    assert p.maximum_memberships == 2

    assert p.contact_details.all()[0].type == 'phone'
    assert p.contact_details.all()[0].value == '555-555-1234'
    assert p.contact_details.all()[0].note == 'this is fake'

    assert p.links.all()[0].url == 'http://example.com/link'

    assert p.start_date == '2015-05-18'
    assert p.end_date == '2015-05-19'


@pytest.mark.django_db
def test_deduplication():
    create_jurisdictions()
    Organization.objects.create(id='us', name="United States Executive Branch",
                                classification="executive", jurisdiction_id="us")
    Organization.objects.create(id='nc', name="North Carolina Executive Branch",
                                classification="executive", jurisdiction_id="nc")
    pres = ScrapePost(label='executive', role='President',
                      organization_id='~{"classification": "executive"}')
    vp = ScrapePost(label='vice-executive', role='Vice President',
                    organization_id='~{"classification": "executive"}')

# Path: pupa/scrape/popolo.py
# class Post(BaseModel, LinkMixin, ContactDetailMixin):
#     """
#     A popolo-style Post
#     """
# 
#     _type = 'post'
#     _schema = post_schema
# 
#     def __init__(self, *, label, role, organization_id=None, chamber=None,
#                  division_id=None, start_date='', end_date='',
#                  maximum_memberships=1):
#         super(Post, self).__init__()
#         self.label = label
#         self.role = role
#         self.organization_id = pseudo_organization(organization_id, chamber)
#         self.division_id = division_id
#         self.start_date = start_date
#         self.end_date = end_date
#         self.maximum_memberships = maximum_memberships
# 
#     def __str__(self):
#         return self.label


# Path: pupa/tests/importers/test_post_importer.py
import pytest
import datetime
from pupa.scrape import Post as ScrapePost
from pupa.importers import PostImporter, OrganizationImporter
from opencivicdata.core.models import Organization, Post, Division, Jurisdiction


    # get person from db and assert it imported correctly
    p = Post.objects.get()
    assert 'ocd-post' in p.id
    assert p.label == post.label
    assert p.role == post.role
    assert p.organization_id == org.id
    assert p.maximum_memberships == 2

    assert p.contact_details.all()[0].type == 'phone'
    assert p.contact_details.all()[0].value == '555-555-1234'
    assert p.contact_details.all()[0].note == 'this is fake'

    assert p.links.all()[0].url == 'http://example.com/link'

    assert p.start_date == '2015-05-18'
    assert p.end_date == '2015-05-19'


@pytest.mark.django_db
def test_deduplication():
    create_jurisdictions()
    Organization.objects.create(id='us', name="United States Executive Branch",
                                classification="executive", jurisdiction_id="us")
    Organization.objects.create(id='nc', name="North Carolina Executive Branch",
                                classification="executive", jurisdiction_id="nc")
    pres = ScrapePost(label='executive', role='President',
                      organization_id='~{"classification": "executive"}')
    vp = ScrapePost(label='vice-executive', role='Vice President',
                    organization_id='~{"classification": "executive"}')

    gov = ScrapePost(label='executive', role='Governor',