예제 #1
0
def test_sets_extent():
    doc = StringIO('<metadata></metadata>')
    r = FGDC(doc)
    r.set_extent((1, 2, 3, 4))
    assert r.doc.find('idinfo/spdom/bounding/westbc').text == '1'
    assert r.doc.find('idinfo/spdom/bounding/eastbc').text == '2'
    assert r.doc.find('idinfo/spdom/bounding/southbc').text == '3'
    assert r.doc.find('idinfo/spdom/bounding/northbc').text == '4'
예제 #2
0
def test_sets_extent():
    doc = StringIO('<metadata></metadata>')
    r = FGDC(doc)
    r.set_extent((1, 2, 3, 4))
    assert r.doc.find('idinfo/spdom/bounding/westbc').text == '1'
    assert r.doc.find('idinfo/spdom/bounding/eastbc').text == '2'
    assert r.doc.find('idinfo/spdom/bounding/southbc').text == '3'
    assert r.doc.find('idinfo/spdom/bounding/northbc').text == '4'
예제 #3
0
def test_sets_restricted_access():
    r = FGDC(StringIO("""
        <metadata>
          <idinfo>
            <accconst>Foobar</accconst>
          </idinfo>
         </metadata>"""))
    r.set_restricted_access()
    assert r.doc.find('idinfo/accconst').text == "Restricted Access Online: Access granted to Licensee only. Available only to MIT affiliates."
예제 #4
0
def test_does_not_overwrite_distribution():
    r = FGDC(StringIO("""
        <metadata>
          <distinfo>
            <distliab>Something</distliab>
          </distinfo>
        </metadata>"""))
    r.set_distribution()
    distliabs = [e.text[:8] for e in r.doc.findall('distinfo/distliab')]
    assert all([t in distliabs for t in ['Although', 'Somethin']])
예제 #5
0
def test_does_not_overwrite_distribution():
    r = FGDC(
        StringIO("""
        <metadata>
          <distinfo>
            <distliab>Something</distliab>
          </distinfo>
        </metadata>"""))
    r.set_distribution()
    distliabs = [e.text[:8] for e in r.doc.findall('distinfo/distliab')]
    assert all([t in distliabs for t in ['Although', 'Somethin']])
예제 #6
0
def test_sets_restricted_access():
    r = FGDC(
        StringIO("""
        <metadata>
          <idinfo>
            <accconst>Foobar</accconst>
          </idinfo>
         </metadata>"""))
    r.set_restricted_access()
    assert r.doc.find(
        'idinfo/accconst'
    ).text == "Restricted Access Online: Access granted to Licensee only. Available only to MIT affiliates."
예제 #7
0
def test_does_not_overwrite_name():
    doc = StringIO("""
        <metadata>
            <idinfo>
                <citation>
                    <citeinfo>
                        <ftname>foobaz</ftname>
                    </citeinfo>
                </citation>
            </idinfo>
        </metadata>""")
    r = FGDC(doc)
    r.set_name('foobar')
    assert r.doc.find('idinfo/citation/citeinfo/ftname').text == 'foobaz'
예제 #8
0
def test_does_not_overwrite_name():
    doc = StringIO("""
        <metadata>
            <idinfo>
                <citation>
                    <citeinfo>
                        <ftname>foobaz</ftname>
                    </citeinfo>
                </citation>
            </idinfo>
        </metadata>""")
    r = FGDC(doc)
    r.set_name('foobar')
    assert r.doc.find('idinfo/citation/citeinfo/ftname').text == 'foobaz'
예제 #9
0
def test_does_not_overwrite_metadata_contact():
    r = FGDC(StringIO("""
        <metadata>
          <metainfo>
            <metc>
              <cntinfo>
                <cntorgp>
                  <cntorg>Foobar</cntorg>
                </cntorgp>
              </cntinfo>
            </metc>
          </metainfo>
        </metadata>"""))
    r.set_metadata_contact()
    assert r.doc.find('metainfo/metc/cntinfo/cntorgp/cntorg').text == \
        "Foobar"
예제 #10
0
def test_adds_keyword_thesauri():
    r = FGDC(StringIO("""
        <metadata>
          <idinfo>
            <keywords>
              <theme>
                <themekey>Foo</themekey>
              </theme>
              <place>
                <placekey>Bar</placekey>
              </place>
            </keywords>
          </idinfo>
        </metadata>"""))
    r.add_keywords()
    assert len(r.doc.findall('idinfo/keywords/theme/themekt')) == 1
    assert len(r.doc.findall('idinfo/keywords/place/placekt')) == 1
예제 #11
0
def test_does_not_overwrite_metadata_contact():
    r = FGDC(
        StringIO("""
        <metadata>
          <metainfo>
            <metc>
              <cntinfo>
                <cntorgp>
                  <cntorg>Foobar</cntorg>
                </cntorgp>
              </cntinfo>
            </metc>
          </metainfo>
        </metadata>"""))
    r.set_metadata_contact()
    assert r.doc.find('metainfo/metc/cntinfo/cntorgp/cntorg').text == \
        "Foobar"
예제 #12
0
def test_does_not_overwrite_attributes():
    doc = StringIO("""
        <metadata>
            <eainfo>
                <detailed>
                    <attr>
                        <attrlabl>FOO</attrlabl>
                    </attr>
                    <attr>
                        <attrlabl>BAR</attrlabl>
                    </attr>
                </detailed>
            </eainfo>
        </metadata>""")
    r = FGDC(doc)
    r.set_attributes(['baz', 'gaz'])
    atrb = [e.text for e in r.root.iterfind('eainfo/detailed/attr/attrlabl')]
    assert atrb == ['FOO', 'BAR']
예제 #13
0
def test_does_not_overwrite_attributes():
    doc = StringIO("""
        <metadata>
            <eainfo>
                <detailed>
                    <attr>
                        <attrlabl>FOO</attrlabl>
                    </attr>
                    <attr>
                        <attrlabl>BAR</attrlabl>
                    </attr>
                </detailed>
            </eainfo>
        </metadata>""")
    r = FGDC(doc)
    r.set_attributes(['baz', 'gaz'])
    atrb = [e.text for e in r.root.iterfind('eainfo/detailed/attr/attrlabl')]
    assert atrb == ['FOO', 'BAR']
예제 #14
0
def test_adds_keyword_thesauri():
    r = FGDC(
        StringIO("""
        <metadata>
          <idinfo>
            <keywords>
              <theme>
                <themekey>Foo</themekey>
              </theme>
              <place>
                <placekey>Bar</placekey>
              </place>
            </keywords>
          </idinfo>
        </metadata>"""))
    r.add_keywords()
    assert len(r.doc.findall('idinfo/keywords/theme/themekt')) == 1
    assert len(r.doc.findall('idinfo/keywords/place/placekt')) == 1
예제 #15
0
def test_does_not_overwrite_extent():
    doc = StringIO("""
        <metadata>
          <idinfo>
            <spdom>
              <bounding>
                <westbc>5</westbc>
                <eastbc>6</eastbc>
                <southbc>7</southbc>
                <northbc>8</northbc>
              </bounding>
            </spdom>
          </idinfo>
        </metadata>""")
    r = FGDC(doc)
    r.set_extent((1, 2, 3, 4))
    assert r.doc.find('idinfo/spdom/bounding/westbc').text == '5'
    assert r.doc.find('idinfo/spdom/bounding/eastbc').text == '6'
    assert r.doc.find('idinfo/spdom/bounding/southbc').text == '7'
    assert r.doc.find('idinfo/spdom/bounding/northbc').text == '8'
예제 #16
0
def test_does_not_overwrite_extent():
    doc = StringIO("""
        <metadata>
          <idinfo>
            <spdom>
              <bounding>
                <westbc>5</westbc>
                <eastbc>6</eastbc>
                <southbc>7</southbc>
                <northbc>8</northbc>
              </bounding>
            </spdom>
          </idinfo>
        </metadata>""")
    r = FGDC(doc)
    r.set_extent((1, 2, 3, 4))
    assert r.doc.find('idinfo/spdom/bounding/westbc').text == '5'
    assert r.doc.find('idinfo/spdom/bounding/eastbc').text == '6'
    assert r.doc.find('idinfo/spdom/bounding/southbc').text == '7'
    assert r.doc.find('idinfo/spdom/bounding/northbc').text == '8'
예제 #17
0
def test_sets_attributes():
    doc = StringIO("<metadata/>")
    r = FGDC(doc)
    r.set_attributes(['foo', 'bar'])
    atrb = [e.text for e in r.root.iterfind('eainfo/detailed/attr/attrlabl')]
    assert atrb == ['foo', 'bar']
예제 #18
0
def test_sets_distribution():
    r = FGDC(StringIO('<metadata/>'))
    r.set_distribution()
    assert r.doc.find('distinfo/distliab').text.startswith("Although this")
예제 #19
0
def test_sets_metadata_contact():
    r = FGDC(StringIO('<metadata/>'))
    r.set_metadata_contact()
    assert r.doc.find('metainfo/metc/cntinfo/cntorgp/cntorg').text == \
        "GIS Lab, MIT Libraries"
예제 #20
0
def test_ensures_elements_exist():
    r = FGDC(StringIO('<metadata/>'))
    r.ensure_elements()
    assert r.doc.find('idinfo/citation/citeinfo/origin') is not None
예제 #21
0
def test_ensures_elements_exist():
    r = FGDC(StringIO('<metadata/>'))
    r.ensure_elements()
    assert r.doc.find('idinfo/citation/citeinfo/origin') is not None
예제 #22
0
def test_sets_metadata_contact():
    r = FGDC(StringIO('<metadata/>'))
    r.set_metadata_contact()
    assert r.doc.find('metainfo/metc/cntinfo/cntorgp/cntorg').text == \
        "GIS Lab, MIT Libraries"
예제 #23
0
def test_sets_distribution():
    r = FGDC(StringIO('<metadata/>'))
    r.set_distribution()
    assert r.doc.find('distinfo/distliab').text.startswith("Although this")
예제 #24
0
def test_sets_attributes():
    doc = StringIO("<metadata/>")
    r = FGDC(doc)
    r.set_attributes(['foo', 'bar'])
    atrb = [e.text for e in r.root.iterfind('eainfo/detailed/attr/attrlabl')]
    assert atrb == ['foo', 'bar']
예제 #25
0
def test_sets_name():
    doc = StringIO("<metadata/>")
    r = FGDC(doc)
    r.set_name('foobar')
    assert r.doc.find('idinfo/citation/citeinfo/ftname').text == 'foobar'
예제 #26
0
def test_sets_name():
    doc = StringIO("<metadata/>")
    r = FGDC(doc)
    r.set_name('foobar')
    assert r.doc.find('idinfo/citation/citeinfo/ftname').text == 'foobar'