async def get(self): slug = self.request.match_info['slug'] score = usecases.GetScoreBySlug(env.SCORES_DIR, slug).exec() if not score: raise web.HTTPNotFound return {'score': score}
def test_score_by_slug_one_page(self, fs): header = r'''\header { title = "Test" url = "https://www.instagram.com/test" } ''' fs.create_file('/scores/test/test.ly', contents=header) fs.create_file('/scores/test/test.png') score = usecases.GetScoreBySlug('/scores/', 'test').exec() url = 'https://github.com/dmitrvk/mymusichere/tree/master/scores/test' assert score.pdf_path == '/static/scores/test/test.pdf' assert score.github_url == url assert score.pages_paths == ('/static/scores/test/test.png', ) assert score.url == 'https://www.instagram.com/test' assert score.title == 'Test'
def test_multiple_pages(self, fs): header = r'''\header { title = "Test" url = "https://www.instagram.com/test" } ''' fs.create_file('/scores/test/test.ly', contents=header) fs.create_file('/scores/test/test-page1.png') fs.create_file('/scores/test/test-page2.png') fs.create_file('/scores/test/test-page3.png') score = usecases.GetScoreBySlug('/scores/', 'test').exec() assert score.pages_paths == ( '/static/scores/test/test-page1.png', '/static/scores/test/test-page2.png', '/static/scores/test/test-page3.png', )
def test_no_url(self, fs): header = r'\header { title = "Test" }' fs.create_file('/scores/test/test.ly', contents=header) fs.create_file('/scores/test/test.png') score = usecases.GetScoreBySlug('/scores/', 'test').exec() assert score.url == ''
def test_not_exists(self, fs): fs.create_dir('/scores/') assert usecases.GetScoreBySlug('/scores/', 'test').exec().slug == ''