
from d1lod.dataone import extractIdentifierFromFullURL as extract

def test_extracting_identifiers_from_urls():
    # Returns None when it should
    assert extract('asdf') is None
    assert extract(1) is None
    assert extract('1') is None
    assert extract('http://google.com') is None

    # Extracts the right thing
    assert extract('https://cn.dataone.org/cn/v1/meta/some_pid') == 'some_pid'
    assert extract('https://cn.dataone.org/cn/v1/meta/kgordon.23.30') == 'kgordon.23.30'
    assert extract('https://cn.dataone.org/cn/v1/resolve/kgordon.23.30') == 'kgordon.23.30'
    assert extract('https://cn.dataone.org/cn/v1/object/kgordon.23.30') == 'kgordon.23.30'
    assert extract('https://cn.dataone.org/cn/v2/object/kgordon.23.30') == 'kgordon.23.30'


from d1lod import dataone

def test_parsing_resource_map():
    pid = 'resourceMap_df35d.3.2'

    aggd_pids = dataone.getAggregatedIdentifiers(pid)

    assert len(aggd_pids) == 7

def test_extracting_identifiers_from_urls():
    # Returns None when it should
    assert dataone.extractIdentifierFromFullURL('asdf') is None
    assert dataone.extractIdentifierFromFullURL(1) is None
    assert dataone.extractIdentifierFromFullURL('1') is None
    assert dataone.extractIdentifierFromFullURL('http://google.com') is None

    # Extracts the right thing
    assert dataone.extractIdentifierFromFullURL('https://cn.dataone.org/cn/v1/meta/some_pid') == 'some_pid'
    assert dataone.extractIdentifierFromFullURL('https://cn.dataone.org/cn/v1/meta/kgordon.23.30') == 'kgordon.23.30'
    assert dataone.extractIdentifierFromFullURL('https://cn.dataone.org/cn/v1/resolve/kgordon.23.30') == 'kgordon.23.30'
    assert dataone.extractIdentifierFromFullURL('https://cn.dataone.org/cn/v1/object/kgordon.23.30') == 'kgordon.23.30'
    assert dataone.extractIdentifierFromFullURL('https://cn.dataone.org/cn/v2/object/kgordon.23.30') == 'kgordon.23.30'

Change imports in dataone test and add test for resource map parsing
Change imports in dataone test and add test for resource map parsing

  
- from d1lod.dataone import extractIdentifierFromFullURL as extract
+ from d1lod import dataone
+ 
+ def test_parsing_resource_map():
+     pid = 'resourceMap_df35d.3.2'
+ 
+     aggd_pids = dataone.getAggregatedIdentifiers(pid)
+ 
+     assert len(aggd_pids) == 7
  
  def test_extracting_identifiers_from_urls():
      # Returns None when it should
-     assert extract('asdf') is None
-     assert extract(1) is None
-     assert extract('1') is None
+     assert dataone.extractIdentifierFromFullURL('asdf') is None
+     assert dataone.extractIdentifierFromFullURL(1) is None
+     assert dataone.extractIdentifierFromFullURL('1') is None
-     assert extract('http://google.com') is None
+     assert dataone.extractIdentifierFromFullURL('http://google.com') is None
  
      # Extracts the right thing
-     assert extract('https://cn.dataone.org/cn/v1/meta/some_pid') == 'some_pid'
+     assert dataone.extractIdentifierFromFullURL('https://cn.dataone.org/cn/v1/meta/some_pid') == 'some_pid'
-     assert extract('https://cn.dataone.org/cn/v1/meta/kgordon.23.30') == 'kgordon.23.30'
+     assert dataone.extractIdentifierFromFullURL('https://cn.dataone.org/cn/v1/meta/kgordon.23.30') == 'kgordon.23.30'
-     assert extract('https://cn.dataone.org/cn/v1/resolve/kgordon.23.30') == 'kgordon.23.30'
+     assert dataone.extractIdentifierFromFullURL('https://cn.dataone.org/cn/v1/resolve/kgordon.23.30') == 'kgordon.23.30'
-     assert extract('https://cn.dataone.org/cn/v1/object/kgordon.23.30') == 'kgordon.23.30'
+     assert dataone.extractIdentifierFromFullURL('https://cn.dataone.org/cn/v1/object/kgordon.23.30') == 'kgordon.23.30'
-     assert extract('https://cn.dataone.org/cn/v2/object/kgordon.23.30') == 'kgordon.23.30'
+     assert dataone.extractIdentifierFromFullURL('https://cn.dataone.org/cn/v2/object/kgordon.23.30') == 'kgordon.23.30'
  
Change imports in dataone test and add test for resource map parsing
## Code Before:

from d1lod.dataone import extractIdentifierFromFullURL as extract

def test_extracting_identifiers_from_urls():
    # Returns None when it should
    assert extract('asdf') is None
    assert extract(1) is None
    assert extract('1') is None
    assert extract('http://google.com') is None

    # Extracts the right thing
    assert extract('https://cn.dataone.org/cn/v1/meta/some_pid') == 'some_pid'
    assert extract('https://cn.dataone.org/cn/v1/meta/kgordon.23.30') == 'kgordon.23.30'
    assert extract('https://cn.dataone.org/cn/v1/resolve/kgordon.23.30') == 'kgordon.23.30'
    assert extract('https://cn.dataone.org/cn/v1/object/kgordon.23.30') == 'kgordon.23.30'
    assert extract('https://cn.dataone.org/cn/v2/object/kgordon.23.30') == 'kgordon.23.30'

## Instruction:
Change imports in dataone test and add test for resource map parsing
## Code After:

from d1lod import dataone

def test_parsing_resource_map():
    pid = 'resourceMap_df35d.3.2'

    aggd_pids = dataone.getAggregatedIdentifiers(pid)

    assert len(aggd_pids) == 7

def test_extracting_identifiers_from_urls():
    # Returns None when it should
    assert dataone.extractIdentifierFromFullURL('asdf') is None
    assert dataone.extractIdentifierFromFullURL(1) is None
    assert dataone.extractIdentifierFromFullURL('1') is None
    assert dataone.extractIdentifierFromFullURL('http://google.com') is None

    # Extracts the right thing
    assert dataone.extractIdentifierFromFullURL('https://cn.dataone.org/cn/v1/meta/some_pid') == 'some_pid'
    assert dataone.extractIdentifierFromFullURL('https://cn.dataone.org/cn/v1/meta/kgordon.23.30') == 'kgordon.23.30'
    assert dataone.extractIdentifierFromFullURL('https://cn.dataone.org/cn/v1/resolve/kgordon.23.30') == 'kgordon.23.30'
    assert dataone.extractIdentifierFromFullURL('https://cn.dataone.org/cn/v1/object/kgordon.23.30') == 'kgordon.23.30'
    assert dataone.extractIdentifierFromFullURL('https://cn.dataone.org/cn/v2/object/kgordon.23.30') == 'kgordon.23.30'
