
import os
import hashlib
import bse
from bse import curate

data_dir = bse.default_data_dir

def test_get_metadata():
    bse.get_metadata()


def test_metadata_uptodate():
    old_metadata = os.path.join(data_dir, 'METADATA.json')
    new_metadata = os.path.join(data_dir, 'METADATA.json.new')
    curate.create_metadata_file(new_metadata, data_dir)

    with open(old_metadata, 'rb') as f:
        old_hash = hashlib.sha1(f.read()).hexdigest()
    with open(new_metadata, 'rb') as f:
        new_hash = hashlib.sha1(f.read()).hexdigest()

    os.remove(new_metadata)

    if old_hash != new_hash:
        print("Old hash: ", old_hash)
        print("New hash: ", new_hash)
        raise RuntimeError("Metadata does not appear to be up to date")


import os
import bse
import json
from bse import curate

data_dir = bse.default_data_dir

def test_get_metadata():
    bse.get_metadata()


def test_metadata_uptodate():
    old_metadata = os.path.join(data_dir, 'METADATA.json')
    new_metadata = os.path.join(data_dir, 'METADATA.json.new')
    curate.create_metadata_file(new_metadata, data_dir)

    with open(old_metadata, 'r') as f:
        old_data = json.load(f)
    with open(new_metadata, 'r') as f:
        new_data = json.load(f)

    os.remove(new_metadata)

    if old_data != new_data:
        raise RuntimeError("Metadata does not appear to be up to date")

Fix testing of metadata - hashing is too strict
Fix testing of metadata - hashing is too strict

  
  import os
- import hashlib
  import bse
+ import json
  from bse import curate
  
  data_dir = bse.default_data_dir
  
  def test_get_metadata():
      bse.get_metadata()
  
  
  def test_metadata_uptodate():
      old_metadata = os.path.join(data_dir, 'METADATA.json')
      new_metadata = os.path.join(data_dir, 'METADATA.json.new')
      curate.create_metadata_file(new_metadata, data_dir)
  
-     with open(old_metadata, 'rb') as f:
+     with open(old_metadata, 'r') as f:
-         old_hash = hashlib.sha1(f.read()).hexdigest()
+         old_data = json.load(f)
-     with open(new_metadata, 'rb') as f:
+     with open(new_metadata, 'r') as f:
-         new_hash = hashlib.sha1(f.read()).hexdigest()
+         new_data = json.load(f)
  
      os.remove(new_metadata)
  
-     if old_hash != new_hash:
+     if old_data != new_data:
-         print("Old hash: ", old_hash)
-         print("New hash: ", new_hash)
          raise RuntimeError("Metadata does not appear to be up to date")
  
Fix testing of metadata - hashing is too strict
## Code Before:

import os
import hashlib
import bse
from bse import curate

data_dir = bse.default_data_dir

def test_get_metadata():
    bse.get_metadata()


def test_metadata_uptodate():
    old_metadata = os.path.join(data_dir, 'METADATA.json')
    new_metadata = os.path.join(data_dir, 'METADATA.json.new')
    curate.create_metadata_file(new_metadata, data_dir)

    with open(old_metadata, 'rb') as f:
        old_hash = hashlib.sha1(f.read()).hexdigest()
    with open(new_metadata, 'rb') as f:
        new_hash = hashlib.sha1(f.read()).hexdigest()

    os.remove(new_metadata)

    if old_hash != new_hash:
        print("Old hash: ", old_hash)
        print("New hash: ", new_hash)
        raise RuntimeError("Metadata does not appear to be up to date")

## Instruction:
Fix testing of metadata - hashing is too strict
## Code After:

import os
import bse
import json
from bse import curate

data_dir = bse.default_data_dir

def test_get_metadata():
    bse.get_metadata()


def test_metadata_uptodate():
    old_metadata = os.path.join(data_dir, 'METADATA.json')
    new_metadata = os.path.join(data_dir, 'METADATA.json.new')
    curate.create_metadata_file(new_metadata, data_dir)

    with open(old_metadata, 'r') as f:
        old_data = json.load(f)
    with open(new_metadata, 'r') as f:
        new_data = json.load(f)

    os.remove(new_metadata)

    if old_data != new_data:
        raise RuntimeError("Metadata does not appear to be up to date")
