|
1
|
|
|
import unittest |
|
2
|
|
|
|
|
3
|
|
|
from binstar_client.errors import BinstarError |
|
4
|
|
|
from binstar_client.utils.notebook import notebook_url, parse, has_environment |
|
5
|
|
|
from binstar_client.utils.test.utils import data_dir |
|
6
|
|
|
|
|
7
|
|
|
|
|
8
|
|
|
class ParseTestCase(unittest.TestCase): |
|
9
|
|
|
def test_parse(self): |
|
10
|
|
|
self.assertEqual(parse("user/notebook-ipynb")[0], 'user') |
|
11
|
|
|
self.assertEqual(parse("user/notebook-ipynb")[1], 'notebook-ipynb') |
|
12
|
|
|
|
|
13
|
|
|
self.assertIsNone(parse("notebook")[0]) |
|
14
|
|
|
self.assertEqual(parse("notebook")[1], 'notebook') |
|
15
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
class NotebookURLTestCase(unittest.TestCase): |
|
18
|
|
|
def test_anaconda_org_installation(self): |
|
19
|
|
|
upload_info = {'url': 'http://anaconda.org/darth/deathstart-ipynb'} |
|
20
|
|
|
url = 'http://notebooks.anaconda.org/darth/deathstart-ipynb' |
|
21
|
|
|
self.assertEqual(notebook_url(upload_info), url) |
|
22
|
|
|
|
|
23
|
|
|
def test_anaconda_server_installation(self): |
|
24
|
|
|
upload_info = {'url': 'http://custom/darth/deathstart-ipynb'} |
|
25
|
|
|
url = 'http://custom/notebooks/darth/deathstart-ipynb' |
|
26
|
|
|
self.assertEqual(notebook_url(upload_info), url) |
|
27
|
|
|
|
|
28
|
|
|
|
|
29
|
|
|
class HasEnvironmentTestCase(unittest.TestCase): |
|
30
|
|
|
def test_has_no_environment(self): |
|
31
|
|
|
self.assertFalse(has_environment(data_dir('notebook.ipynb'))) |
|
32
|
|
|
|
|
33
|
|
|
def test_has_environment(self): |
|
34
|
|
|
self.assertTrue(has_environment(data_dir('notebook_with_env.ipynb'))) |
|
35
|
|
|
|
|
36
|
|
|
def test_no_file(self): |
|
37
|
|
|
self.assertFalse(has_environment("no-file")) |
|
38
|
|
|
|
|
39
|
|
|
|
|
40
|
|
|
if __name__ == '__main__': |
|
41
|
|
|
unittest.main() |
|
42
|
|
|
|