Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
Failing test for an npm sync regression
Browse files Browse the repository at this point in the history
  • Loading branch information
chadwhitacre committed Nov 9, 2016
1 parent 6f01508 commit faba8b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
9 changes: 5 additions & 4 deletions gratipay/package_managers/readmes.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ def http_fetch(package_name):


def Fetcher(db):
def fetch(dirty, fetch=http_fetch):
def fetch(dirty, _fetch=http_fetch):
"""Update all info for one package.
"""
log(dirty.name)
full = fetch(dirty.name)
full = _fetch(dirty.name)

if not full:
return
Expand Down Expand Up @@ -86,15 +86,16 @@ def process(dirty):
return process


def fetch(db):
def fetch(db, _fetch=http_fetch):
dirty = db.all('SELECT package_manager, name '
'FROM packages WHERE readme_raw IS NULL '
'ORDER BY package_manager DESC, name DESC')
threaded_map(Fetcher(db), dirty, 4)
threaded_map(Fetcher(db, _fetch), dirty, 4)


def process(db):
dirty = db.all('SELECT id, package_manager, name, description, readme_raw '
'FROM packages WHERE readme_needs_to_be_processed'
'ORDER BY package_manager DESC, name DESC')
threaded_map(Processor(db), dirty, 4)

8 changes: 2 additions & 6 deletions tests/py/test_npm_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,10 @@ def test_rf_fetches_a_readme(self):
self.db.run("INSERT INTO packages (package_manager, name, description, emails) "
"VALUES ('npm', 'foo-package', 'A package', ARRAY[]::text[])")

class DirtyPackage:
package_manager = 'npm'
name = 'foo-package'

def fetch(name):
return {'name': 'foo-package', 'readme': '# Greetings, program!'}

readmes.Fetcher(self.db)(DirtyPackage(), fetch=fetch)
readmes.fetch(self.db, fetch)

package = self.db.one('SELECT * FROM packages')
assert package.name == 'foo-package'
Expand Down Expand Up @@ -125,7 +121,7 @@ class DirtyPackage:
package_manager = 'npm'
name = 'foo-package'

readmes.Processor(self.db)(DirtyPackage())
readmes.process(self.db)

package = self.db.one('SELECT * FROM packages')
assert package.name == 'foo-package'
Expand Down

0 comments on commit faba8b1

Please sign in to comment.